Skip to content

install_requires does not work when with packages installed with --no-binary :all: #1281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mickeyzoox opened this issue Feb 22, 2018 · 4 comments

Comments

@mickeyzoox
Copy link

mickeyzoox commented Feb 22, 2018

In particular, when I use the requirements.txt:

numpy==1.13.3 --no-binary :all:
PyWavelets==0.5.2

pip install -r requirements.txt fails with:

root@6f026802d05f:/# pip install -r requirements.txt
Collecting numpy==1.13.3 (from -r requirements.txt (line 1))
  Downloading numpy-1.13.3.zip (5.0MB)
    100% |████████████████████████████████| 5.0MB 239kB/s
Collecting PyWavelets==0.5.2 (from -r requirements.txt (line 2))
  Downloading PyWavelets-0.5.2.tar.gz (4.4MB)
    100% |████████████████████████████████| 4.4MB 290kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-jmogkb/PyWavelets/setup.py", line 12, in <module>
        from numpy import get_include as get_numpy_include
    ImportError: No module named numpy

BUT, we see that PyWavelets 0.5.2 declares numpy with install_requires (https://github.com/PyWavelets/pywt/blob/master/setup.py#L301), and furthermore removing the --no-binary :all: modifier from numpy installation then this example works.

To reproduce (assuming you have docker):

docker run --rm -it python:2 bash
printf 'numpy==1.13.3 --no-binary :all:\nPyWavelets==0.5.2' > requirements.txt
pip install -r requirements.txt

If this is not the correct place to report this bug, could you direct me to the correct place?

@mickeyzoox mickeyzoox changed the title install_requires seems to not work when requiring a dep installed with --no-binary :all: install_requires does not work when with packages installed with --no-binary :all: Feb 22, 2018
@benoit-pierre
Copy link
Member

The problem is with the PyWavelets package:

  • numpy is unconditionally imported at the beginning of setup.py
  • numpy is missing from setup_requires (it's present in install_requires, but that does not guarantee it will be installed before building/installing from source)

@mickeyzoox
Copy link
Author

I see. Thanks!

@mattbennett
Copy link

I have the problem described in the issue title, unrelated to PyWavelet.

Example setup.py file and versions in this gist. Reproduced here for convenience:

from setuptools import setup, find_packages

setup(
    name='MyPackageName',
    version='1.0.0',
    url='https://github.com/mypackage.git',
    author='Author Name',
    author_email='[email protected]',
    description='Description of my package',
    packages=[],    
    install_requires=[
       'numpy >= 1.11.3 --no-binary :all:',
    ],
)
$ python
Python 3.7.4 (default, Aug 23 2019, 12:12:50)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
$ pip --version
pip 19.2.3 from /Users/mattbennett/.virtualenvs/tmp-1e4ec19d965b2df/lib/python3.7/site-packages/pip (python 3.7)
$ python -c "import pkg_resources; print(pkg_resources.get_distribution('setuptools').version)"
41.2.0
$ pip install .
Processing /Users/mattbennett/.virtualenvs/tmp-1e4ec19d965b2df
    ERROR: Command errored out with exit status 1:
     command: /Users/mattbennett/.virtualenvs/tmp-1e4ec19d965b2df/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/jd/c8gwfl2j40990qvpg4fl476h0000gn/T/pip-req-build-w7dcmq0h/setup.py'"'"'; __file__='"'"'/private/var/folders/jd/c8gwfl2j40990qvpg4fl476h0000gn/T/pip-req-build-w7dcmq0h/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/jd/c8gwfl2j40990qvpg4fl476h0000gn/T/pip-req-build-w7dcmq0h/
    Complete output (1 lines):
    error in MyPackageName setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'--no-bin'"
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
$ python setup.py install
error in MyPackageName setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'--no-bin'"

I can create a requirements file with the same specification

# requirements.txt
numpy >= 1.11.3 --no-binary :all:

And this installs just fine:

$ pip install -r requirements.txt
Collecting numpy>=1.11.3 (from -r reqs.text (line 1))
  Using cached https://files.pythonhosted.org/packages/ac/36/325b27ef698684c38b1fe2e546e2e7ef9cecd7037bcdb35c87efec4356af/numpy-1.17.2.zip
Skipping bdist_wheel for numpy, due to binaries being disabled for it.
Installing collected packages: numpy
  Running setup.py install for numpy ... done
Successfully installed numpy-1.17.2

As a workaround I can remove the --no-binary :all: from install_requires and run the following:

pip install . --no-binary numpy

@pganssle
Copy link
Member

pganssle commented Oct 4, 2019

@mattbennett --no-binary is a pip flag, not a valid way to specify a package. The "workaround" is the correct way to specify this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants