Skip to content
Advertisement

Numpy install requirement on package fails on pip install from PyPI but not from .whl

I recently build my first python package and tried to test distribution with test.pypi.org (Github repo Test PyPI)

Code for building the dist:

python setup.py sdist bdist_wheel

Code for uploading to Test PyPI:

twine upload --repository testpypi dist/*

Then I created and empty conda env to test the installation with:

conda create --prefix ./envs --no-default-packages python=3.6

In this enviroment I used succesfully pip install with wheel file:

pip install mathsom-0.1.1-py3-none-any.whl

But if I try to install it from Test PyPI numpy installation fails (it is in install_requirements en setup.cfg file). Code:

pip install -i https://test.pypi.org/simple/ mathsom

Setup.cfg code:

[metadata]
name = mathsom
author = Oliver Mohr B.
author_email = oliver.mohr.b@gmail.com
version = 0.1.1
description = Personal library for math related problems
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/oliverm91/mathsom
license_files = LICENSE
keywords = solvers, solver, interpolations, interpolation, numerics, derivatives, integrals

[options]
package_dir=
    = src
packages=find:
setup_requires = 
    numpy
install_requires =
    numpy
    scipy

[options.packages.find]
where=src

Setup.py

from setuptools import setup
if __name__ == '__main__':
    setup()

First lines of error (extremly long error msg): enter image description here

Advertisement

Answer

If you look at your error message, you can see

Downloading ... mathsom-0.1.1-py3-none-any.whl

So it is also using a whl file. However, the way numpy is installed differs. In your error message, it is clear that numpy is trying to compile from source, which is not suprising, since you set the index to https://test.pypi.org/simple/ and there is only source distributions of numpy under that index. If you allow that the dependencies can be pulled from pypi, by setting test.pypi as an extra-index with --extra-index-url then everything works (tested in a fresh conda env created with the command you have provided):

pip install --extra-index-url https://test.pypi.org/simple/ mathsom
Looking in indexes: https://pypi.org/simple, https://test.pypi.org/simple/
Collecting mathsom
  Downloading https://test-files.pythonhosted.org/packages/4b/b3/76e6bbaa6c1da9f6f032e114af7f5724077154a28b5fc7069330185f2bc8/mathsom-0.1.1-py3-none-any.whl (18 kB)
Collecting scipy
  Downloading scipy-1.5.4-cp36-cp36m-win_amd64.whl (31.2 MB)
     |████████████████████████████████| 31.2 MB 393 kB/s
Collecting numpy
  Downloading numpy-1.19.5-cp36-cp36m-win_amd64.whl (13.2 MB)
     |████████████████████████████████| 13.2 MB ...
Installing collected packages: numpy, scipy, mathsom
Successfully installed mathsom-0.1.1 numpy-1.19.5 scipy-1.5.4
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement