Description
What's the problem this feature will solve?
Currently, pip has an implicit dependency on setuptools to build legacy packages (pre PEP 517). Removing setuptools from a build environment will cause builds of these packages or install of these packages from source to fail.
For example:
$ python -m venv env
$ env/bin/pip uninstall -y setuptools
$ env/bin/pip install --no-cache-dir termcolor
Collecting pytest-virtualenv
Downloading https://files.pythonhosted.org/packages/21/7f/0ec1ab9b8fcd4a3a063b97143a97d1c093d01227353b682c9027d14b14c2/pytest_virtualenv-1.7.0-py2.py3-none-any.whl
Collecting virtualenv (from pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/05/f1/2e07e8ca50e047b9cc9ad56cf4291f4e041fa73207d000a095fe478abf84/virtualenv-16.7.9-py2.py3-none-any.whl (3.4MB)
|████████████████████████████████| 3.4MB 2.0MB/s
Collecting pytest (from pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/e6/94/29b5a09edc970a2f24742e6186dfe497cd6c778e60e54693215a36852613/pytest-5.3.3-py3-none-any.whl (235kB)
|████████████████████████████████| 245kB 26.2MB/s
Collecting pytest-fixture-config (from pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/83/6e/ebc4d3d5c51cc440bdb0adcd274ff2436dc6814ed1cc2cbc6d5386aaf85c/pytest_fixture_config-1.7.0-py2.py3-none-any.whl
Collecting pytest-shutil (from pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/26/b7/ef48a8f1f81ae4cd6f22992f6ffb7e9bf030d6e6654e2e626a05aaf5e880/pytest_shutil-1.7.0-py2.py3-none-any.whl
Collecting attrs>=17.4.0 (from pytest->pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/a2/db/4313ab3be961f7a763066401fb77f7748373b6094076ae2bda2806988af6/attrs-19.3.0-py2.py3-none-any.whl
Collecting py>=1.5.0 (from pytest->pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/99/8d/21e1767c009211a62a8e3067280bfce76e89c9f876180308515942304d2d/py-1.8.1-py2.py3-none-any.whl (83kB)
|████████████████████████████████| 92kB 20.7MB/s
Collecting more-itertools>=4.0.0 (from pytest->pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/bc/e2/3206a70758a21f9878fcf9478282bb68fbc66a5564718f9ed724c3f2bb52/more_itertools-8.1.0-py3-none-any.whl (41kB)
|████████████████████████████████| 51kB 67.3MB/s
Collecting pluggy<1.0,>=0.12 (from pytest->pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/a0/28/85c7aa31b80d150b772fbe4a229487bc6644da9ccb7e427dd8cc60cb8a62/pluggy-0.13.1-py2.py3-none-any.whl
Collecting wcwidth (from pytest->pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/58/b4/4850a0ccc6f567cc0ebe7060d20ffd4258b8210efadc259da62dc6ed9c65/wcwidth-0.1.8-py2.py3-none-any.whl
Collecting packaging (from pytest->pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/d8/5b/3098db49a61ccc8583ffead6aedc226f08ff56dc03106b6ec54451e27a30/packaging-20.0-py2.py3-none-any.whl
Collecting execnet (from pytest-shutil->pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/d3/2e/c63af07fa471e0a02d05793c7a56a9f7d274a8489442a5dc4fb3b2b3c705/execnet-1.7.1-py2.py3-none-any.whl
Collecting contextlib2 (from pytest-shutil->pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/85/60/370352f7ef6aa96c52fb001831622f50f923c1d575427d021b8ab3311236/contextlib2-0.6.0.post1-py2.py3-none-any.whl
Collecting termcolor (from pytest-shutil->pytest-virtualenv)
Downloading https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
ERROR: Command errored out with exit status 1:
command: /Users/jaraco/code/public/pypa/setuptools/env/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-nsnw5epl/termcolor/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-nsnw5epl/termcolor/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-nsnw5epl/termcolor/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
This issue is often masked by the fact that pip will cache the wheel, so if the wheel was built with one environment, it might succeed in the next without setuptools due to the cache, leading to situations where the same code will run successfully in some CI environments (with cache support) but fail in others.
I encountered this issue in setuptools test suite itself, as I'm attempting to install pytest-virtualenv
which depends transitively on termcolor
, and would like to be able to install those test requirements without the need for an implicit setuptools.
Describe the solution you'd like
Why can't pip, for legacy projects, supply an implied 'pyproject.toml':
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta:__legacy__"
This would effectively build the project using those dependencies (if not already met), and would allow for old, unmaintained projects like termcolor to be installed in environments with only pip.
As an illustration:
draft $ pip freeze --all
argcomplete==1.10.0
Click==7.0
pip==19.3.1
pip-run==5.3
pipx==0.14.0.0
userpath==1.3.0
draft $ http -d https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
HTTP/1.1 200 OK
...
Downloading 3.82 kB to "termcolor-1.1.0.tar.gz"
Done. 3.82 kB in 0.00059s (6.36 MB/s)
draft $ tar xfz termcolor-1.1.0.tar.gz
draft $ cd termcolor-1.1.0/
termcolor-1.1.0 $ cat > pyproject.toml
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta:__legacy__"
termcolor-1.1.0 $ pip wheel .
Processing /Users/jaraco/draft/termcolor-1.1.0
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: termcolor
Building wheel for termcolor (PEP 517) ... done
Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4830 sha256=2ccf30d5778fdef8c1cac2d2c24697e8ffdaae5bbb99d01a39b1faaec7694251
Stored in directory: /Users/jaraco/draft/termcolor-1.1.0
Successfully built termcolor
Alternative Solutions
The alternative is that every environment needs one of:
- maintain this implicit dependency
- avoid installing legacy packages
- update all legacy packages to have wheels