cpython icon indicating copy to clipboard operation
cpython copied to clipboard

Remove bundled setuptools

Open sbidoul opened this issue 3 years ago • 3 comments

Feature or enhancement

Remove the bundled setuptools so that ensurepip and python -m venv only installs pip.

Context

The setup.py install command of setuptools is deprecated.

However, in an environment where setuptools is installed but wheel is not (such as one created with python -m venv), pip falls back on running the deprecated and non-standard setup.py install.

Since version 22.1 pip works correctly by default in environments where setuptools is not installed, by enabling its PEP 517 mode automatically, leading to unsurprising installations in most cases.

So, in order to progressively expose more users to standard-based installation workflows, we (the pip team) would like that virtual environments are created without setuptools by default.

Users faced with failing installations following this change (likely due to packages with customized setup.py that do not support building a wheel) can easily pip install setuptools to solve the issue.

Previous discussion

https://github.com/pypa/pip/issues/8102#issuecomment-1195566597 and following comments has some more context.

sbidoul avatar Jul 26 '22 20:07 sbidoul

@pablogsal do you think it is still acceptable to do this in 3.11? If positive we can likely land a PR on time for RC1.

sbidoul avatar Jul 26 '22 20:07 sbidoul

Unfortunately I don't feel comfortable landing this so late in the release cycle, specially so close to RC1 and given the current stability of 3.11 :(

This will need to wait until 3.12.

pablogsal avatar Jul 26 '22 20:07 pablogsal

It feels strange that setuptools is included when using -m venv, but wheel is not included.

rafrafek avatar Nov 07 '22 15:11 rafrafek

I've filed #101039 for this (almost had a number with three 0s), targetting 3.12.

pradyunsg avatar Jan 14 '23 22:01 pradyunsg

Since version 22.1 pip works correctly by default in environments where setuptools is not installed, by enabling its PEP 517 mode automatically, leading to unsurprising installations in most cases.

Do you have some examples of cases where the PEP 517 mode doesn't work for legacy packages? :-)

edmorley avatar Feb 23 '23 12:02 edmorley

PEP 517 is backwards compatible, it should work on legacy packages, the opposite is the issue, pip trying to use the legacy path for packages that need PEP 517.

FFY00 avatar Mar 04 '23 08:03 FFY00

https://docs.python.org/3.12/library/venv.html#an-example-of-extending-envbuilder is the final piece of work here -- that example needs to be updated to use something more modern or otherwise behave differently to showcase extending behaviours of the class.

pradyunsg avatar Apr 18 '23 04:04 pradyunsg

I am looking into updating the example ExtendedEnvBuilder.

systematicguy avatar Jul 23 '23 14:07 systematicguy

Given that https://github.com/python/cpython/pull/101039 having merged for 3.12 and the only blocker to closing this being a documentation update, I've filed #110548 for tracking the documentation change.

Let's close this! Thanks for the reviews and the work around this folks! ^.^

pradyunsg avatar Oct 09 '23 12:10 pradyunsg