diff options
author | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2009-02-06 21:33:45 (GMT) |
---|---|---|
committer | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2009-02-06 21:33:45 (GMT) |
commit | aa397d180635bbab6a2f2998da396fc5006b8ced (patch) | |
tree | 808b43d4277d18f26aa301f68fdfdbda0a99d0e0 /Lib | |
parent | 4db626f95d9dbb7d52418dee9a96467da3720796 (diff) | |
download | cpython-aa397d180635bbab6a2f2998da396fc5006b8ced.zip cpython-aa397d180635bbab6a2f2998da396fc5006b8ced.tar.gz cpython-aa397d180635bbab6a2f2998da396fc5006b8ced.tar.bz2 |
Convert "srcdir" into an absolute path if that seems prudent. Currrently
the only user of this is Lib/distutils/tests/test_build_ext.py (in order
to find the source for xxmodule.c). I'm not sure if other platforms
need similar tweaks, I'm not brave enough to attempt it without being
able to test.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/distutils/sysconfig.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py index deb51a1..4e06546 100644 --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -530,6 +530,20 @@ def get_config_vars(*args): if 'srcdir' not in _config_vars: _config_vars['srcdir'] = project_base + # Convert srcdir into an absolute path if it appears necessary. + # Normally it is relative to the build directory. However, during + # testing, for example, we might be running a non-installed python + # from a different directory. + if python_build and os.name == "posix": + base = os.path.dirname(os.path.abspath(sys.executable)) + if (not os.path.isabs(_config_vars['srcdir']) and + base != os.getcwd()): + # srcdir is relative and we are not in the same directory + # as the executable. Assume executable is in the build + # directory and make srcdir absolute. + srcdir = os.path.join(base, _config_vars['srcdir']) + _config_vars['srcdir'] = os.path.normpath(srcdir) + if sys.platform == 'darwin': kernel_version = os.uname()[2] # Kernel version (8.4.3) major_version = int(kernel_version.split('.')[0]) |