matejak / imreg_dft

Image registration using discrete Fourier transform.
Other
245 stars 68 forks source link

pip install will fail if dependencies are not already installed #16

Closed arve0 closed 9 years ago

arve0 commented 9 years ago

Traceback:

  Using cached imreg_dft-1.0.4.tar.gz
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/var/folders/mx/t9hzs5852cxgk0548k1vdsxr0000gn/T/pip-build-looz8ycr/imreg-dft/setup.py", line 8, in <module>
        import imreg_dft
      File "src/imreg_dft/__init__.py", line 1, in <module>
        from imreg_dft.imreg import *
      File "src/imreg_dft/imreg.py", line 42, in <module>
        import numpy as np
    ImportError: No module named 'numpy'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

      File "<string>", line 20, in <module>

      File "/var/folders/mx/t9hzs5852cxgk0548k1vdsxr0000gn/T/pip-build-looz8ycr/imreg-dft/setup.py", line 8, in <module>

        import imreg_dft

      File "src/imreg_dft/__init__.py", line 1, in <module>

        from imreg_dft.imreg import *

      File "src/imreg_dft/imreg.py", line 42, in <module>

        import numpy as np

    ImportError: No module named 'numpy'

    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /var/folders/mx/t9hzs5852cxgk0548k1vdsxr0000gn/T/pip-build-looz8ycr/imreg-dft

This PR reads __init__.py instead of importing imreg and causing the error.

matejak commented 9 years ago

I understand the problem, but I don't like the solution since it is not pythonic. I will think about it though. It seems to me that the best thing would be to defer import of numpy etc. until it is clear that they are needed. Maybe I wll break the API and cancel the import * stuff...

Anyway, there is a try - except block against ImportError around the statement and it seems not to be in effect. Also, I thought that pip is supposed to pick up requirements from the requirements.txt, which it obviously also doesn't do. Any idea about what's going on?

arve0 commented 9 years ago

Its a common misunderstanding that requirements.txt are read upon install. Its not. I would say that the whole Python packaging is broken (ref conda and wheel declarative approach). For a longer answer, see this blog post from pip developer Donald Stufft: https://caremad.io/2013/07/setup-vs-requirement/

Another approach would be to include a separate version file (like this), but that also got that certain non-pythonic feeling.

matejak commented 9 years ago

I agree with your statement that the packaging is broken, however I don't agree with some of the conclusion presented the article. Anyway, I have noticed that the current src/imreg_dft/__init__.py should not suffer from the problem - the try block has been introduced AFTER 1.0.4 (at least it looks so). So I probably should make a new release soon to remedy this.

arve0 commented 9 years ago

:+1:

  1. mai 2015 00:39 skrev "Matěj Týč" notifications@github.com:

I agree with your statement that the packaging is broken, however I don't agree with some of the conclusion presented the article. Anyway, I have noticed that the current src/imreg_dft/init.py should not suffer from the problem - the try block has been introduced AFTER 1.0.4 (at least it looks so). So I probably should make a new release soon to remedy this.

— Reply to this email directly or view it on GitHub https://github.com/matejak/imreg_dft/pull/16#issuecomment-98256503.