Starfish-develop / Starfish

Tools for Flexible Spectroscopic Inference
https://starfish.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
68 stars 22 forks source link

Starfish.grid_tools not found in non-editable installation. #126

Closed jason-neal closed 5 years ago

jason-neal commented 5 years ago

I am having issues accessing functions in grid_tools module after the recent changes. Is this just something I have missed?

As an exmaple

pip install https://github.com/iancze/Starfish/archive/develop.zip#egg=astrostarfish
python -c "from Starfish.grid_tools import *"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'Starfish.grid_tools'

or

python -c "from Starfish.grid_tools.interfaces import download_PHOENIX_models"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'Starfish.grid_tools'

In this environment I only installed Starfish using the pip line above (no repo clone).

If I clone the repo and run pip install -e . from the starfish repo then the commands above do work.

I assume there would be a simple change to __init__.py would possibly solve this. As to what the change is I am not sure.

I think this would also be a problem with pip install astrostarfish when it is uploaded to PyPI.

mileslucas commented 5 years ago

I can reproduce the problem using the python:latest docker image. This is odd, at first glance, since the folder structure follows the python package schema correctly as far as I can tell. I will investigate further tomorrow.

e: After pip-installing the package from the develop branch, the site-packages folder for Starfish does not even contain grid_tools... time to dive even deeper into the confused mess of python packaging practices 😄

mileslucas commented 5 years ago

Turns out the fix was easier than I thought! I managed to execute the code below without issue:

$ docker run --rm -ti python:latest bash
/# pip install git+https://github.com/iancze/starfish@develop#egg=astrostarfish
/# python -c "from Starfish.grid_tools import *"
/# python -c "from Starfish.grid_tools.interfaces import download_PHOENIX_models"

If the issue continues, open this back up @jason-neal, but hopefully it is solved!

PS: good catch. I struggle with bugs like these because they never come up in my development cycle!

jason-neal commented 5 years ago

Thanks, find_packages() did the trick.