Page MenuHomeFreeBSD

Use a proper argument list in PYDISTUTILS_SETUP

Authored by mva on Jun 23 2014, 11:35 AM.


Group Reviewers

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

Diff Detail

Lint Skipped
Unit Tests Skipped

Event Timeline

mva updated this revision to Diff 466.Jun 23 2014, 11:35 AM
mva retitled this revision from to Use a proper argument list in PYDISTUTILS_SETUP.
mva updated this object.
mva edited the test plan for this revision. (Show Details)
mva added a reviewer: Python.
mva set the repository for this revision to rP FreeBSD ports repository.
wg added a subscriber: wg.Jun 23 2014, 11:41 AM

Sounds good to me.

mva accepted this revision.Jun 23 2014, 11:46 AM
mva added a reviewer: mva.
This revision is now accepted and ready to land.Jun 23 2014, 11:46 AM
sbz accepted this revision.Jun 23 2014, 11:50 AM
sbz added a reviewer: sbz.
sbz added a subscriber: sbz.


koobs accepted this revision.Jun 23 2014, 12:13 PM
koobs added a reviewer: koobs.
koobs added a subscriber: koobs.

Looks good @mva, do we want to submit a PR upstream too?

mva added a comment.Jun 23 2014, 12:27 PM
In D270#13, @koobs wrote:

Looks good @mva, do we want to submit a PR upstream too?

pip ( might need the PR, it does not seem to be relevant for the default distutils implementation or setuptools. I did not check the 500 outstanding pip issues for a related one, though. We might just add another issue with our way of fixing things for adoption.

mva closed this revision.Jun 28 2014, 7:04 AM


koobs added a comment.Jul 8 2019, 2:41 AM

Fixed in pypa/pip today:

Unsure of distutils/setuptools status, but it would 'be nice' to get rid of this hack eventually