Description
Environment
- pip version: 21.0.1
- Python version: 3.9.0
- OS: linux
Description
Using pyproject.toml build-dependencies installs the latest version of a library, even if the same pip command installs a fixed version.
in very some cases (binary compilation) this can lead to errors like the below when trying to import the dependency.
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "xxx/.venv/lib/python3.9/site-packages/utils_find_1st/__init__.py", line 3, in <module>
from .find_1st import find_1st
ImportError: numpy.core.multiarray failed to import
Expected behavior
Build process should use the pinned version of numpy (1.19.5) instead of the latest version (1.20.0 at time of writing). This way, the installation process will be coherent, and problems like this are not possible.
How to Reproduce
- create new environment
- install numpy and py_find_1st (both with pinned dependencies)
python -m venv .venv
. .venv/bin/activate
pip install -U pip
pip install --no-cache numpy==1.19.5 py_find_1st==1.1.4
python -c "import utils_find_1st"
# To make the above work, upgrade numpy to the latest version (which is the one py_find_1st is compiled against).
pip install -U numpy
Output
$ python -m venv .venv
$ . .venv/bin/activate
$ pip install -U pip
Collecting pip
Using cached pip-21.0.1-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.3
Uninstalling pip-20.2.3:
Successfully uninstalled pip-20.2.3
Successfully installed pip-21.0.1
$ pip install --no-cache numpy==1.19.5 py_find_1st==1.1.4
Collecting numpy==1.19.5
Downloading numpy-1.19.5-cp39-cp39-manylinux2010_x86_64.whl (14.9 MB)
|████████████████████████████████| 14.9 MB 10.4 MB/s
Collecting py_find_1st==1.1.4
Downloading py_find_1st-1.1.4.tar.gz (8.7 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: py-find-1st
Building wheel for py-find-1st (PEP 517) ... done
Created wheel for py-find-1st: filename=py_find_1st-1.1.4-cp39-cp39-linux_x86_64.whl size=30989 sha256=c1fa1330f733111b2b8edc447bec0c54abf3caf79cd5f386f5cbef310d41885c
Stored in directory: /tmp/pip-ephem-wheel-cache-94uzfkql/wheels/1e/11/33/aa4db0927a22de4d0edde2a401e1cc1f307bc209d1fdf5b104
Successfully built py-find-1st
Installing collected packages: numpy, py-find-1st
Successfully installed numpy-1.19.5 py-find-1st-1.1.4
$ python -c "import utils_find_1st"
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/xmatt/development/cryptos/freqtrade_copy/.venv/lib/python3.9/site-packages/utils_find_1st/__init__.py", line 3, in <module>
from .find_1st import find_1st
ImportError: numpy.core.multiarray failed to import
In verbose mode, the installation of numpy 1.20.0 can be observed, however, even with "-v", the output is VERY verbose.
....
changing mode of /tmp/pip-build-env-js9tatya/overlay/bin/f2py3.9 to 755
Successfully installed numpy-1.20.0 setuptools-52.0.0 wheel-0.36.2
Removed build tracker: '/tmp/pip-req-tracker-9anxsz9d'
Installing build dependencies ... done
....
An attached version can be found below (created with pip install --no-cache numpy==1.19.5 py_find_1st==1.1.4 -v &> numpy_install.txt
).