Skip to content
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

Bug: can't install without NumPy #364

Closed
mruffalo opened this issue Mar 18, 2020 · 4 comments
Closed

Bug: can't install without NumPy #364

mruffalo opened this issue Mar 18, 2020 · 4 comments
Assignees

Comments

@mruffalo
Copy link

Describe the bug
The install instructions at https://github.com/taoliu/MACS/blob/5e742732e32f6e5648b2bd5466d50e32f66f8ad0/INSTALL.md#install-through-pypi say that "PyPI will
install Numpy automatically if it is absent."

This doesn't work, because setup.py imports NumPy directly: https://github.com/taoliu/MACS/blob/5e742732e32f6e5648b2bd5466d50e32f66f8ad0/setup.py#L16

This is easy to work around, and most people probably won't ever encounter this -- I assume most installations of MACS2 are in an existing Python environment that already includes NumPy. It's easy to hit this when building a Docker image though, with the common practice of creating a requirements.txt file, COPYing that to the container, then running pip install -r requirements.txt.

In any case, this should probably either be fixed or the installation instructions should be modified. (It's also more accurate to say "pip will install NumPy automatically ..." instead of "PyPI ..." if modifying those instructions.)

To Reproduce

$ docker run -it --rm python:3 /bin/bash
root@e8aafde9f328:/# pip install MACS2==2.2.6
Collecting MACS2==2.2.6
  Downloading MACS2-2.2.6.tar.gz (2.0 MB)
     |████████████████████████████████| 2.0 MB 4.5 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-a0ddbdtm/MACS2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-a0ddbdtm/MACS2/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 /tmp/pip-install-a0ddbdtm/MACS2/pip-egg-info
         cwd: /tmp/pip-install-a0ddbdtm/MACS2/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-a0ddbdtm/MACS2/setup.py", line 16, in <module>
        from numpy import get_include as numpy_get_include
    ModuleNotFoundError: No module named 'numpy'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Even if NumPy and MACS2 are both listed in a requirements.txt file, installation of MACS2 will still fail, because pip imports this setup.py between downloading and installing packages:

$ docker run -it --rm python:3 /bin/bash
root@ef1339bcaf4e:/# echo 'numpy==1.18.2' > requirements.txt
root@ef1339bcaf4e:/# echo 'MACS2==2.2.6' >> requirements.txt 
root@ef1339bcaf4e:/# pip install -r requirements.txt 
Collecting numpy==1.18.2
  Downloading numpy-1.18.2-cp38-cp38-manylinux1_x86_64.whl (20.6 MB)
     |████████████████████████████████| 20.6 MB 4.6 MB/s 
Collecting MACS2==2.2.6
  Downloading MACS2-2.2.6.tar.gz (2.0 MB)
     |████████████████████████████████| 2.0 MB 33.1 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-88yrb2td/MACS2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-88yrb2td/MACS2/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 /tmp/pip-install-88yrb2td/MACS2/pip-egg-info
         cwd: /tmp/pip-install-88yrb2td/MACS2/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-88yrb2td/MACS2/setup.py", line 16, in <module>
        from numpy import get_include as numpy_get_include
    ModuleNotFoundError: No module named 'numpy'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Expected behavior
NumPy would be installed as a dependency of MACS2, instead of setup.py failing due to the lack of this package.

System (please complete the following information):

  • OS: python:3 Docker image
  • Python version: 3.8.2 as of writing this, but also encountered this under 3.6.9 on Ubuntu 18.04
  • Numpy version: None - that's the problem
  • MACS Version 2.2.6
@taoliu taoliu self-assigned this Apr 6, 2020
@taoliu
Copy link
Contributor

taoliu commented Apr 6, 2020

I will work on this. To reproduce:

$ python3 -m venv TestEnv
$ source TestEnv/bin/activate
$ git clone https://github.com/taoliu/MACS.git
$ cd MACS
$ python setup.py install
Traceback (most recent call last):
  File "setup.py", line 16, in <module>
    from numpy import get_include as numpy_get_include
ModuleNotFoundError: No module named 'numpy'

I need to write a more sophisticated setup script...

@taoliu
Copy link
Contributor

taoliu commented Apr 9, 2020

Addressed in PR #378. I will see if it can solve the pip install issue, but at least it can pass the way I described before.

@taoliu
Copy link
Contributor

taoliu commented Apr 12, 2020

Please let me know if you still have the same issue to install the new version v2.2.7.1. @mruffalo

@taoliu
Copy link
Contributor

taoliu commented Apr 12, 2020

PR #378 + the tweaks in pyproject.toml (83df604) should solve the problem:

https://github.com/taoliu/MACS/blob/83df604e759f0422219aac8571fef49621ab7270/pyproject.toml#L1-L2

@taoliu taoliu closed this as completed Apr 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants