[Python-checkins] python/dist/src/Lib/distutils sysconfig.py,1.44,1.44.6.1

mwh@users.sourceforge.net mwh@users.sourceforge.net
Mon, 07 Oct 2002 03:38:35 -0700


Update of /cvsroot/python/python/dist/src/Lib/distutils
In directory usw-pr-cvs1:/tmp/cvs-serv2787/Lib/distutils

Modified Files:
      Tag: release22-maint
	sysconfig.py 
Log Message:
Backport fdrake's 
    revision 1.88 of setup.py
    revision 1.46 of Lib/distutils/sysconfig.py

When using a Python that has not been installed to build 3rd-party
modules, distutils does not understand that the build version of the
source tree is needed.

This patch fixes distutils.sysconfig to understand that the running
Python is part of the build tree and needs to use the appropriate
"shape" of the tree. This does not assume anything about the current
directory, so can be used to build 3rd-party modules using Python's
build tree as well.

This is useful since it allows us to use a non-installed debug-mode
Python with 3rd-party modules for testing. It as the side-effect that
set_python_build() is no longer needed (the hack which was added to
allow distutils to be used to build the "standard" extension modules).

This closes SF patch #547734.



Index: sysconfig.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v
retrieving revision 1.44
retrieving revision 1.44.6.1
diff -C2 -d -r1.44 -r1.44.6.1
*** sysconfig.py	6 Dec 2001 20:51:35 -0000	1.44
--- sysconfig.py	7 Oct 2002 10:38:33 -0000	1.44.6.1
***************
*** 24,40 ****
  EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
  
! # Boolean; if it's true, we're still building Python, so
! # we use different (hard-wired) directories.
! 
! python_build = 0
! 
! def set_python_build():
!     """Set the python_build flag to true.
  
!     This means that we're building Python itself.  Only called from
!     the setup.py script shipped with Python.
!     """
!     global python_build
      python_build = 1
  
  
--- 24,41 ----
  EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
  
! # python_build: (Boolean) if true, we're either building Python or
! # building an extension with an un-installed Python, so we use
! # different (hard-wired) directories.
  
! argv0_path = os.path.dirname(os.path.abspath(sys.executable))
! landmark = os.path.join(argv0_path, "Modules", "Setup")
! if not os.path.isfile(landmark):
!     python_build = 0
! elif os.path.isfile(os.path.join(argv0_path, "Lib", "os.py")):
      python_build = 1
+ else:
+     python_build = os.path.isfile(os.path.join(os.path.dirname(argv0_path),
+                                                "Lib", "os.py"))
+ del argv0_path, landmark
  
  
***************
*** 54,58 ****
      if os.name == "posix":
          if python_build:
!             return "Include/"
          return os.path.join(prefix, "include", "python" + sys.version[:3])
      elif os.name == "nt":
--- 55,66 ----
      if os.name == "posix":
          if python_build:
!             base = os.path.dirname(os.path.abspath(sys.executable))
!             if plat_specific:
!                 inc_dir = base
!             else:
!                 inc_dir = os.path.join(base, "Include")
!                 if not os.path.exists(inc_dir):
!                     inc_dir = os.path.join(os.path.dirname(base), "Include")
!             return inc_dir
          return os.path.join(prefix, "include", "python" + sys.version[:3])
      elif os.name == "nt":
***************
*** 155,159 ****
      """Return full pathname of installed Makefile from the Python build."""
      if python_build:
!         return './Makefile'
      lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
      return os.path.join(lib_dir, "config", "Makefile")
--- 163,167 ----
      """Return full pathname of installed Makefile from the Python build."""
      if python_build:
!         return os.path.join(os.path.dirname(sys.executable), "Makefile")
      lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
      return os.path.join(lib_dir, "config", "Makefile")