jterrace / pyssim

A Python module for computing the Structural Similarity Image Metric (SSIM)
MIT License
339 stars 62 forks source link

Explicitly list dependencies in setup.py #20

Closed asottile closed 8 years ago

asottile commented 8 years ago

Currently I can do the following:

virtualenv venv
venv/bin/pip install numpy scipy pillow
venv/bin/pip wheel pyssim -w .

This will build a wheel of pyssim.

Then I will attempt to install that wheel in another virtualenv

virtualenv venv2
venv2/bin/pip install pyssim-0.3-py2-none-any.whl

Then I try and use pyssim:

$ ./venv2/bin/python -c 'import ssim'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/foo/venv2/local/lib/python2.7/site-packages/ssim/__init__.py", line 5, in <module>
    from ssim.ssimlib import SSIM
  File "/tmp/foo/venv2/local/lib/python2.7/site-packages/ssim/ssimlib.py", line 9, in <module>
    import numpy as np
ImportError: No module named numpy

BOOM

The reasoning for this: You should specify your dependencies statically in setup.py and not optionally based on imports :)

jterrace commented 8 years ago

The problem is that some modules can come from different places. For example, scipy bundles numpy, PIL can come from PIL or Pillow, etc.

asottile commented 8 years ago

scipy does not bundle numpy:

$ pip install scipy
Collecting scipy
  Using cached scipy-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: scipy
Successfully installed scipy-0.17.1
$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy

PIL is dead and no longer maintained, I would just depend on Pillow directly.