Skip to content

PEP 518 support: setup.py is called before build requirements have been installed #4647

@benoit-pierre

Description

@benoit-pierre
  • Pip version: 9.0.1-464-g573a5011
  • Python version: Python 3.6.2
  • Operating system: Arch Linux x86_64

Description:

I'd like to use pip' support for PEP 518, particularly to solve those 2 cases mentioned in the PEP:

  • While setuptools itself will install anything listed in this, they won't be installed until during the execution of the setup() function, which means that the only way to actually use anything added here is through increasingly complex machinations that delay the import and usage of these modules until later on in the execution of the setup() function.
  • This cannot include setuptools itself nor can it include a replacement to setuptools , which means that projects such as numpy.distutils are largely incapable of utilizing it and projects cannot take advantage of newer setuptools features until their users naturally upgrade the version of setuptools to a newer one.

For this to work I expect build requirements to be installed before any attempt at running setup.py.

What I've run:

> tmpdir="$(mktemp -d)"
> trap "cd - && rm -rf $tmpdir" EXIT
> cd "$tmpdir"
> python -m venv venv
> export PATH="$PWD/venv/bin:$PATH"
> pip install -U setuptools wheel https://github.com/pypa/pip/archive/573a50118148ff4646ae9310730f5bf6c4e8784f.zip python-xlib
Collecting https://github.com/pypa/pip/archive/573a50118148ff4646ae9310730f5bf6c4e8784f.zip
  Downloading https://github.com/pypa/pip/archive/573a50118148ff4646ae9310730f5bf6c4e8784f.zip (6.5MB)
    100% |████████████████████████████████| 6.5MB 269kB/s
Collecting setuptools
  Using cached setuptools-36.2.7-py2.py3-none-any.whl
Collecting wheel
  Using cached wheel-0.29.0-py2.py3-none-any.whl
Collecting python-xlib
  Using cached python_xlib-0.19-py2.py3-none-any.whl
Collecting six>=1.10.0 (from python-xlib)
  Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: setuptools, wheel, six, python-xlib, pip
  Found existing installation: setuptools 28.8.0
    Uninstalling setuptools-28.8.0:
      Successfully uninstalled setuptools-28.8.0
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
  Running setup.py install for pip ... done
Successfully installed pip-10.0.0.dev0 python-xlib-0.19 setuptools-36.2.7 six-1.10.0 wheel-0.29.0
> pip freeze --all
pip==10.0.0.dev0
python-xlib==0.19
setuptools==36.2.7
six==1.10.0
wheel==0.29.0
> cat >setup.py <<\EOF
from setuptools import setup
import Xlib
setup(name='project', version='0.1')
EOF
> cat >pyproject.toml <<\EOF
[build-system]
requires = ["python-xlib"]
EOF
> cat >MANIFEST.in <<\EOF
include pyproject.toml
EOF
> python setup.py sdist
running sdist
running egg_info
creating project.egg-info
writing project.egg-info/PKG-INFO
writing dependency_links to project.egg-info/dependency_links.txt
writing top-level names to project.egg-info/top_level.txt
writing manifest file 'project.egg-info/SOURCES.txt'
reading manifest file 'project.egg-info/SOURCES.txt'
writing manifest file 'project.egg-info/SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt

running check
warning: check: missing required meta-data: url

warning: check: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be supplied

creating project-0.1
creating project-0.1/project.egg-info
copying files to project-0.1...
copying setup.py -> project-0.1
copying project.egg-info/PKG-INFO -> project-0.1/project.egg-info
copying project.egg-info/SOURCES.txt -> project-0.1/project.egg-info
copying project.egg-info/dependency_links.txt -> project-0.1/project.egg-info
copying project.egg-info/top_level.txt -> project-0.1/project.egg-info
Writing project-0.1/setup.cfg
creating dist
Creating tar archive
removing 'project-0.1' (and everything under it)
> pip uninstall -y python-xlib
Uninstalling python-xlib-0.19:
  Successfully uninstalled python-xlib-0.19
> pip install dist/project-0.1.tar.gz
Processing ./dist/project-0.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-c16oxefg/setup.py", line 2, in <module>
        import Xlib
    ModuleNotFoundError: No module named 'Xlib'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-c16oxefg/

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto-lockedOutdated issues that have been locked by automationtype: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions