diff options
| author | Victor Stinner <vstinner@redhat.com> | 2019-04-25 09:59:34 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-25 09:59:34 (GMT) |
| commit | 0ef8c157e9195df0115c54ba875a5efb92ac22fb (patch) | |
| tree | 943d3a9b3d7c84d1688393acca0d35be27c80286 /Lib/distutils/sysconfig.py | |
| parent | 235e7b2b0d937ba8b4a9172aa72206187e3e1f54 (diff) | |
| download | cpython-0ef8c157e9195df0115c54ba875a5efb92ac22fb.zip cpython-0ef8c157e9195df0115c54ba875a5efb92ac22fb.tar.gz cpython-0ef8c157e9195df0115c54ba875a5efb92ac22fb.tar.bz2 | |
bpo-28552: Fix distutils.sysconfig for empty sys.executable (GH-12875)
bpo-28552, bpo-7774: Fix distutils.sysconfig if sys.executable is
None or an empty string: use os.getcwd() to initialize project_base.
Fix also the distutils build command: don't use sys.executable if
it's evaluated as false (None or empty string).
Diffstat (limited to 'Lib/distutils/sysconfig.py')
| -rw-r--r-- | Lib/distutils/sysconfig.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py index a349467..570a612 100644 --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -28,7 +28,12 @@ BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix) if "_PYTHON_PROJECT_BASE" in os.environ: project_base = os.path.abspath(os.environ["_PYTHON_PROJECT_BASE"]) else: - project_base = os.path.dirname(os.path.abspath(sys.executable)) + if sys.executable: + project_base = os.path.dirname(os.path.abspath(sys.executable)) + else: + # sys.executable can be empty if argv[0] has been changed and Python is + # unable to retrieve the real program name + project_base = os.getcwd() # python_build: (Boolean) if true, we're either building Python or |
