[Python-checkins] r69374 - python/trunk/Lib/distutils/sysconfig.py

neil.schemenauer python-checkins at python.org
Fri Feb 6 22:33:45 CET 2009


Author: neil.schemenauer
Date: Fri Feb  6 22:33:45 2009
New Revision: 69374

Log:
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.


Modified:
   python/trunk/Lib/distutils/sysconfig.py

Modified: python/trunk/Lib/distutils/sysconfig.py
==============================================================================
--- python/trunk/Lib/distutils/sysconfig.py	(original)
+++ python/trunk/Lib/distutils/sysconfig.py	Fri Feb  6 22:33:45 2009
@@ -530,6 +530,20 @@
         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])


More information about the Python-checkins mailing list