[Python-Dev] Dodgy code in distutils/sysconfig.py

Michael Hudson mwh@python.net
09 Jul 2002 15:37:38 +0100


I'm curious about this bit of code from Lib/distutils/sysconfig.py:

,-----------------------------------------------------------------------
| # 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
`-----------------------------------------------------------------------

Well, curious is a bit weak.  It's broken, and breaks (eg) the snake
farm's builds (because that is set up to build python in a directory
far away and over the hills from the source directory).

Why isn't it just

,-----------------------------------------------------------------------
| # 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")
| 
| python_build = os.path.isfile(landmark):
| 
| del argv0_path, landmark
`-----------------------------------------------------------------------

?  What cases does that get wrong?  I'd have changed it already, but I
have this feeling I must be missing something.

Cheers,
M.

-- 
  The meaning of "brunch" is as yet undefined.
                                             -- Simon Booth, ucam.chat