You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
3.2's sysconfig doesn't work with virtualenv #54952
>> import sysconfig; sysconfig.get_paths('purelib')
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 332, in _init_posix
_parse_makefile(makefile, vars)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 220, in _parse_makefilewithopen(filename, errors="surrogateescape") as f:
IOError: [Errno 2] No such file or directory: '/tmp/e/lib/python3.2/config-3.2m/Makefile'
$ source t/bin/activate
$ python3.2 -c 'import distutils.sysconfig;print(distutils.sysconfig.get_makefile_filename())'
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config-3.2m/Makefile
$ python3.2 -c 'import sysconfig;print(sysconfig.get_makefile_filename())'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 332, in _init_posix
_parse_makefile(makefile, vars)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 220, in _parse_makefilewithopen(filename, errors="surrogateescape") as f:
IOError: [Errno 2] No such file or directory: '/Users/nad/t/lib/python3.2/config-3.2m/Makefile'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 322, in get_makefile_filenamereturn os.path.join(get_path('stdlib'),
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 451, in get_pathreturn get_paths(scheme, vars, expand)[name]
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 442, in get_pathsreturn _expand_vars(scheme, vars)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 168, in _expand_vars
_extend_dict(vars, get_config_vars())
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 487, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 337, in _init_posixraiseIOError(msg)
BTW, your example will fail in any case since get_paths takes a scheme name; "purelib" is a path name.
I have investigated the problem and it turns out virtualenv patches distutils.sysconfig behavior by adding to the sys module a "real_prefix" attribute that points to the global Python install and is used instead of sys.prefix that points to the virtualenv local install, when some distutils.sysconfig APIs are used.
The fix is to change virtualenv so it patches sysconfig the same way it does for distutils.sysconfig.
To simulate this patch, just change how _EXEC_PREFIX and _PREFIX are set in sysconfig, by setting them to sys.real_prefix instead of sys.prefix/sys.exec_prefix when using virtualenv.
I suggest to Georg that this bug gets resolved to "invalid" and that we move it to the virtualenv bitbucket tracker.
I think that this issue needs to be reopened... since it never has been resolved...
I just downloaded the new version of Python 3.2 and tried to compile, install and use it on Redhat Linux.
Installation went fine (configure with --prefix=/usr/mysoft/python32)...
But when using Python I get the following error message:
Traceback (most recent call last):
File "/usr/mysoft/python32/lib/python3.2/sysconfig.py", line 332, in _init_posix
_parse_makefile(makefile, vars)
File "/usr/mysoft/python32/lib/python3.2/sysconfig.py", line 220, in _parse_makefilewithopen(filename, errors="surrogateescape") as f:
IOError: [Errno 2] No such file or directory: 'lib/python3.2/config-3.2m/Makefile'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/mysoft/python32/lib/python3.2/site.py", line 529, in <module>
main()
File "/usr/mysoft/python32/lib/python3.2/site.py", line 517, in main
known_paths = addusersitepackages(known_paths)
File "/usr/mysoft/python32/lib/python3.2/site.py", line 263, in addusersitepackages
user_site = getusersitepackages()
File "/usr/mysoft/python32/lib/python3.2/site.py", line 238, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/mysoft/python32/lib/python3.2/site.py", line 228, in getuserbaseUSER_BASE= get_config_var('userbase')
File "/usr/mysoft/python32/lib/python3.2/sysconfig.py", line 590, in get_config_varreturn get_config_vars().get(name)
File "/usr/mysoft/python32/lib/python3.2/sysconfig.py", line 487, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/usr/mysoft/python32/lib/python3.2/sysconfig.py", line 337, in _init_posixraiseIOError(msg)
IOError: invalid Python installation: unable to open lib/python3.2/config-3.2m/Makefile (No such file or directory)
... I never heard about virtualenv before and I don't know what is the impact of that library, but I guess a just released version of Python should work out of the box?!? (Final 3.2 release)
(I was using Python 3.1.3 on the same machine without any hitch...)
palmkevin commented on Feb 25, 2011
palmkevinmannequin
Mannequin
More actions
Please find here a small C app embedding python that shows how to reproduce the problem (It turned out that the problem is caused by the new method "Py_SetPath"):
Please find here a small C app embedding python that shows how to
reproduce the problem (It turned out that the problem is caused by the
new method "Py_SetPath"):
Can you open a separate issue?
Also, please include your error message.
I think that this issue needs to be reopened... since it never has been
resolved... I just downloaded the new version of Python 3.2 and tried to
compile, install and use it on Redhat Linux.
Installation went fine (configure with --prefix=/usr/mysoft/python32)...
On Ubuntu 10.10, I built Python 3.2 from the svn head with
--prefix=/tmp/prefix, did a 'make install' and then ran
/tmp/prefix/bin/python. It worked fine and I did not get the exception.
palmkevin commented on Feb 25, 2011
palmkevinmannequin
Mannequin
More actions
@barry: Yes python runs correctly.
The problem arises when you embed python in a C application when calling the Py_SetPath-method (see the follow up issue bpo-11320)
Activity
srid commentedon Dec 20, 2010
From http://code.google.com/p/virtualenv5/issues/detail?id=6 - it seems that the
sysconfigmodule is looking for Makefile in wrong directory, while ideally it must be looking into the base Python install.>> import sysconfig; sysconfig.get_paths('purelib') Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 332, in _init_posix _parse_makefile(makefile, vars) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/sysconfig.py", line 220, in _parse_makefile with open(filename, errors="surrogateescape") as f: IOError: [Errno 2] No such file or directory: '/tmp/e/lib/python3.2/config-3.2m/Makefile'ned-deily commentedon Dec 20, 2010
That does seem to be a regression since distutils.sysconfig works correctly in a virtualenv:
but in a virtualenv:
BTW, your example will fail in any case since get_paths takes a scheme name; "purelib" is a path name.
ned-deily commentedon Dec 20, 2010
Setting to deferred blocker for 3.2 release manager evaluation.
pitrou commentedon Dec 21, 2010
Agreed it should probably be a release blocker. I guess it has to do with (not) following symlinks, right?
birkenfeld commentedon Dec 21, 2010
OK, let's make this one. Tarek to the rescue!
tarekziade commentedon Dec 21, 2010
Will do tonight
tarekziade commentedon Dec 23, 2010
I have investigated the problem and it turns out virtualenv patches distutils.sysconfig behavior by adding to the sys module a "real_prefix" attribute that points to the global Python install and is used instead of sys.prefix that points to the virtualenv local install, when some distutils.sysconfig APIs are used.
The fix is to change virtualenv so it patches sysconfig the same way it does for distutils.sysconfig.
To simulate this patch, just change how _EXEC_PREFIX and _PREFIX are set in sysconfig, by setting them to sys.real_prefix instead of sys.prefix/sys.exec_prefix when using virtualenv.
I suggest to Georg that this bug gets resolved to "invalid" and that we move it to the virtualenv bitbucket tracker.
srid commentedon Dec 23, 2010
Sounds good, but this doesn't belong to the virtualenv bug tracker (virtualenv does even support Python 3). Instead, it belongs to the virtualenv5 tracker: http://code.google.com/p/virtualenv5/issues/detail?id=6
palmkevin commentedon Feb 25, 2011
I think that this issue needs to be reopened... since it never has been resolved...
I just downloaded the new version of Python 3.2 and tried to compile, install and use it on Redhat Linux.
Installation went fine (configure with --prefix=/usr/mysoft/python32)...
... I never heard about virtualenv before and I don't know what is the impact of that library, but I guess a just released version of Python should work out of the box?!? (Final 3.2 release)
(I was using Python 3.1.3 on the same machine without any hitch...)
palmkevin commentedon Feb 25, 2011
Please find here a small C app embedding python that shows how to reproduce the problem (It turned out that the problem is caused by the new method "Py_SetPath"):
--> Python crashes on Py_Initialize... only if the Py_SetPath is executed...
pitrou commentedon Feb 25, 2011
Le vendredi 25 février 2011 à 13:58 +0000, Palm Kevin a écrit :
Can you open a separate issue?
Also, please include your error message.
palmkevin commentedon Feb 25, 2011
Done: bpo-11320
warsaw commentedon Feb 25, 2011
On Feb 25, 2011, at 01:16 PM, Palm Kevin wrote:
On Ubuntu 10.10, I built Python 3.2 from the svn head with
--prefix=/tmp/prefix, did a 'make install' and then ran
/tmp/prefix/bin/python. It worked fine and I did not get the exception.
palmkevin commentedon Feb 25, 2011
@barry: Yes python runs correctly.
The problem arises when you embed python in a C application when calling the Py_SetPath-method (see the follow up issue bpo-11320)