@@ -533,28 +533,22 @@ def get_config_vars(*args):
533533 # the init-function.
534534 _CONFIG_VARS ['userbase' ] = _getuserbase ()
535535
536- if 'srcdir' not in _CONFIG_VARS :
537- _CONFIG_VARS ['srcdir' ] = _PROJECT_BASE
538- else :
539- _CONFIG_VARS ['srcdir' ] = _safe_realpath (_CONFIG_VARS ['srcdir' ])
540-
541- # Convert srcdir into an absolute path if it appears necessary.
542- # Normally it is relative to the build directory. However, during
543- # testing, for example, we might be running a non-installed python
544- # from a different directory.
545- if _PYTHON_BUILD and os .name == "posix" :
546- base = _PROJECT_BASE
547- try :
548- cwd = os .getcwd ()
549- except OSError :
550- cwd = None
551- if (not os .path .isabs (_CONFIG_VARS ['srcdir' ]) and
552- base != cwd ):
553- # srcdir is relative and we are not in the same directory
554- # as the executable. Assume executable is in the build
555- # directory and make srcdir absolute.
556- srcdir = os .path .join (base , _CONFIG_VARS ['srcdir' ])
557- _CONFIG_VARS ['srcdir' ] = os .path .normpath (srcdir )
536+ # Always convert srcdir to an absolute path
537+ srcdir = _CONFIG_VARS .get ('srcdir' , _PROJECT_BASE )
538+ if os .name == 'posix' :
539+ if _PYTHON_BUILD :
540+ # If srcdir is a relative path (typically '.' or '..')
541+ # then it should be interpreted relative to the directory
542+ # containing Makefile.
543+ base = os .path .dirname (get_makefile_filename ())
544+ srcdir = os .path .join (base , srcdir )
545+ else :
546+ # srcdir is not meaningful since the installation is
547+ # spread about the filesystem. We choose the
548+ # directory containing the Makefile since we know it
549+ # exists.
550+ srcdir = os .path .dirname (get_makefile_filename ())
551+ _CONFIG_VARS ['srcdir' ] = _safe_realpath (srcdir )
558552
559553 # OS X platforms require special customization to handle
560554 # multi-architecture, multi-os-version installers
0 commit comments