diff options
author | Emiel Wiedijk <me@aimileus.nl> | 2019-02-23 20:51:09 +0100 |
---|---|---|
committer | Emiel Wiedijk <me@aimileus.nl> | 2019-05-15 19:56:15 +0200 |
commit | 8f227af516c8c6b991c8e6c76f5bf4672f36c41e (patch) | |
tree | 23431900929dbba88644d4fca6c07b638968ac72 | |
parent | 3adda966e2e76ad59cf79fd8bdeab77fb11d308f (diff) | |
download | external_python_setuptools-8f227af516c8c6b991c8e6c76f5bf4672f36c41e.tar.gz external_python_setuptools-8f227af516c8c6b991c8e6c76f5bf4672f36c41e.tar.bz2 external_python_setuptools-8f227af516c8c6b991c8e6c76f5bf4672f36c41e.zip |
Set sys.argv[0] in build scripts run by build_meta
Some setup.py scripts, use sys.argv[0] to locate the source directory of
a project. I added this to build_meta.__legacy__ since that is focused
on backwards compatibility with old scripts. However, @pganssle said
this behaviour should not be added to setuptools.build_meta. Fixes #1628
-rw-r--r-- | setuptools/build_meta.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index 10c4b528..eb9e815e 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -232,6 +232,12 @@ class _BuildMetaLegacyBackend(_BuildMetaBackend): if script_dir not in sys.path: sys.path.insert(0, script_dir) + # Some setup.py scripts (e.g. in pygame and numpy) use sys.argv[0] to + # get the directory of the source code. They expect it to refer to the + # setup.py script. + sys_argv_0 = sys.argv[0] + sys.argv[0] = setup_script + try: super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script) @@ -242,6 +248,7 @@ class _BuildMetaLegacyBackend(_BuildMetaBackend): # the original path so that the path manipulation does not persist # within the hook after run_setup is called. sys.path[:] = sys_path + sys.argv[0] = sys_argv_0 # The primary backend _BACKEND = _BuildMetaBackend() |