pip ignores pyproject.toml

Question:

[build-system]
requires = ["wheel", "setuptools>=18.0", "cython>=0.29.0", "numpy>=1.20"]

I package via python setup.py sdist bdist_wheel, then twine upload --repository testpypi dist/*, and

pip install -i https://test.pypi.org/simple/ mypkg==0.1.0

into a fresh virtual Anaconda environment, which starts installing numpy-1.9.3 that’s clearly below 1.20, and yields

      File "c:python38libsite-packagessetuptoolsmsvc.py", line 328, in msvc14_gen_lib_options
        if LegacyVersion(np.__version__) < LegacyVersion('1.11.2'):
    AttributeError: module 'numpy' has no attribute '__version__'
    ----------------------------------------
ERROR: Command errored out with exit status 1: 

My setup.py doesn’t have setup_requires, but does have include_dirs=[numpy.get_include()], and ext_modules=Cython.Build.cythonize(setuptools.Extension(...)). Windows 10.

Why is the requirement being ignored, and how to fix?

Asked By: OverLordGoldDragon

||

Answers:

pyproject.toml is for pip install . rather than python setup.py or pip install uploaded_pkg. It wasn’t ignored, the requirement was already satisfied in the virtual environment.

install_requires=["numpy>=1.20.0"] is what’s needed for pip install uploaded_pkg.

Answered By: OverLordGoldDragon
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.