Skip to content

Commit b7bf07c

Browse files
author
neil.schemenauer
committed
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. git-svn-id: http://svn.python.org/projects/python/trunk@69374 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 704fab5 commit b7bf07c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lib/distutils/sysconfig.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,20 @@ def get_config_vars(*args):
530530
if 'srcdir' not in _config_vars:
531531
_config_vars['srcdir'] = project_base
532532

533+
# Convert srcdir into an absolute path if it appears necessary.
534+
# Normally it is relative to the build directory. However, during
535+
# testing, for example, we might be running a non-installed python
536+
# from a different directory.
537+
if python_build and os.name == "posix":
538+
base = os.path.dirname(os.path.abspath(sys.executable))
539+
if (not os.path.isabs(_config_vars['srcdir']) and
540+
base != os.getcwd()):
541+
# srcdir is relative and we are not in the same directory
542+
# as the executable. Assume executable is in the build
543+
# directory and make srcdir absolute.
544+
srcdir = os.path.join(base, _config_vars['srcdir'])
545+
_config_vars['srcdir'] = os.path.normpath(srcdir)
546+
533547
if sys.platform == 'darwin':
534548
kernel_version = os.uname()[2] # Kernel version (8.4.3)
535549
major_version = int(kernel_version.split('.')[0])

0 commit comments

Comments
 (0)