The PYDISTUTILS_SETUP command does not strip arguments properly, which causes setuptools and distutils to jump to wrong conclusions, since they always will receive a "-c" as first argument (sys.argv[0])
sys.argv[0] however is specified as either
- being the executed script
- "-c" for a command
We inject (enforce) a setuptools import in PYDISTUTILS_SETUP, to ensure that every python package follows the same way of being installed. The injection causes the setuptools and distutils command chain to receive "-c" as first argument instead of a setup file. At least setuptools assumes sys.argv[0] to be a file, though, which causes the well-known
warning: manifest_maker: standard file '-c' not found
warning. Some distutils commands however will handle "-c" as a different argument, which may pollute the chosen PYDISTUTILS_*ARGS.
The proposed fix will set the first argument of sys.argv to the defined setup file, which should restore the original and intended behaviour for setuptools and distutils.
On a side note: pip's subprocess calls to inject setuptools also suffer from that bug