[Bug 5858] New: mercurial ImportError: _Py_GetArgcArgv symbol not found from osutil
mercurial-bugs at mercurial-scm.org
mercurial-bugs at mercurial-scm.org
Thu Apr 26 21:16:34 UTC 2018
https://bz.mercurial-scm.org/show_bug.cgi?id=5858
Bug ID: 5858
Summary: mercurial ImportError: _Py_GetArgcArgv symbol not
found from osutil
Product: Mercurial
Version: 4.5.3
Hardware: Macintosh
OS: Mac OS
Status: UNCONFIRMED
Severity: bug
Priority: wish
Component: Mercurial
Assignee: bugzilla at mercurial-scm.org
Reporter: bondo at opuoq.com
CC: mercurial-devel at mercurial-scm.org
In short, osutil depends on a non-public function (Py_GetArgcArgv) from the
Python interpretter that is not always available to the cext module when it is
loaded, depending on the nature of the Python installation. I was able to patch
and work around the issue for my installation, but it seems like it would be
better to either detect this condition more accurately (if possible) or rework
osutil.c so that it does not depend on a non-public function.
More Details:
I have a MAMP installation that I want to integrate with mercurial. MAMP has
its own bundled version of python (2.7.13) independent of the operating system
version.
I successfully installed pip for the MAMP python so that I could install other
packages.
Running pip install mercurial succeeded and installed version 4.5.3.
The command hg init was successful after the installation.
However, when I placed a launch script derived from contrib/hgweb.wsgi in the
source distribution, it failed. The exact error from the apache log was
ImportError:
dlopen(/Applications/MAMP/Library/lib/python2.7/site-packages/mercurial/cext/osutil.so,
2): Symbol not found: _Py_GetArgcArgv
Referenced from:
/Applications/MAMP/Library/lib/python2.7/site-packages/mercurial/cext/osutil.so
Expected in: flat namespace
in
/Applications/MAMP/Library/lib/python2.7/site-packages/mercurial/cext/osutil.so
Investigating this further, it appears that Py_GetArgcArgv is not a public
Python API method, and something about the way that the MAMP python is built
means that it is not available to osutil.so when it is loaded. Looking at the
source for osutil, there are two lines (770 and 771) that are the cause of the
issue. The local declaration indicates that this is indeed not part of the
public API for Python.
extern void Py_GetArgcArgv(int *argc, char ***argv);
Py_GetArgcArgv(&argc, &argv);
This is in a block that is skipped when SETPROCNAME_USE_NONE is defined. I was
able to create a custom source distribution by changing
osutil_cflags = []
to
osutil_cflags = ['-DSETPROCNAME_USE_NONE']
in setup.py for the mercurial source distribution, install that, and then
everything works.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Mercurial-devel
mailing list