uwmadison-chm / bioread

Utilities to work with files from BIOPAC's AcqKnowlege software
MIT License
66 stars 23 forks source link

Installation fails unless Numpy already installed #30

Closed pvelasco closed 4 years ago

pvelasco commented 4 years ago

Hi,

When trying to install bioread on a clean python installation (Docker image python:3.7-slim) via pip:

pip install bidsphysio

it gives the following error:

    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-urju6r4l/bioread/setup.py", line 13, in <module>
        metadata = get_locals(os.path.join('bioread', '_metadata.py'))
      File "/tmp/pip-install-urju6r4l/bioread/setup.py", line 10, in get_locals
        exec(open(filename, 'r').read(), {}, l)
      File "<string>", line 13, in <module>
      File "/tmp/pip-install-urju6r4l/bioread/bioread/__init__.py", line 13, in <module>
        from bioread import reader
      File "/tmp/pip-install-urju6r4l/bioread/bioread/reader.py", line 18, in <module>
        import numpy as np
    ModuleNotFoundError: No module named 'numpy'
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-urju6r4l/bioread/

setup.py runs bioread/_metadata.py. _metadata.py, tries to import bioread/version.py: https://github.com/uwmadison-chm/bioread/blob/4641503e0c97df51551be224ceddcbad6963080f/bioread/_metadata.py#L13 Importing bioread/version.py runs bioread/__init__.py, which in turn imports bioread/reader.py: https://github.com/uwmadison-chm/bioread/blob/4641503e0c97df51551be224ceddcbad6963080f/bioread/__init__.py#L13 And, finally, bioread/reader.py imports numpy: https://github.com/uwmadison-chm/bioread/blob/4641503e0c97df51551be224ceddcbad6963080f/bioread/reader.py#L18

So, basically, to install bioread you need numpy installed; it is not enough to include it in the install_requires.

I guess the way to fix this would be to either read the version from a file not in the bioread folder (so that bioread/__init__.py doesn't get executed), or to remove the import reader from bioread/__init__.py.

njvack commented 4 years ago

Hi,

Thanks for writing! Gah, I'd hoped that the exec() trick would keep from running __init__.py but I guess not. I think another fix would be to just get rid of version.py and put the version number in _metadata.py.

I've also been contacted (just today! Maybe by someone in your group?) by someone who may have another fix for this; regardless, though, I don't want to be importing stuff in setup.py.

I'll give a try to fixing this (and also see what the other PR has) and let you know what turns out.

njvack commented 4 years ago

Okay, I think this is closed by 414ddf7a6ec3050203a05741ac43180ebb6e915f and will be further addressed by PR #32. We'll get a new release up once we've got everything merged and cleaned up.