MDAnalysis / cookiecutter-mdakit

Cookiecutter for Python packages based on MDAnalysis
MIT License
7 stars 5 forks source link

module not found after pip install #113

Closed orbeckst closed 5 months ago

orbeckst commented 5 months ago

I followed the MDAKit tutorial word for word and then install with either pip install -e . or pip install ..

When trying to import the rmsfkit package, I get the following import error:

(rmsfkit) deathstar:tmp oliver$ python
Python 3.12.0 | packaged by conda-forge | (main, Oct  3 2023, 08:43:38) [Clang 15.0.7 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rmsfkit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'rmsfkit'
>>>

The only relevant dir I can find in ~/anaconda3/envs/rmsfkit/lib/python3.12/site-packages/ is rmsfkit-0.0.0+3.g28a9cd7.dist-info.

Building a package with

$ mamba install build
$ python -m build

and installing with

$ pip uninstall rmsfkit
$ pip install dist/rmsfkit-0.0.0+3.g28a9cd7-py3-none-any.whl

leads to the same failure to import the package.

It appears that either I do something stupid somewhere or that somehow the package is broken.

I am on macOS 13.x on an Intel CPU.

$ mamba --version
mamba 1.4.9
conda 23.7.4

In the environment

(base) deathstar:rmsfkit oliver$ mamba activate rmsfkit
(rmsfkit) deathstar:rmsfkit oliver$ python -V
Python 3.12.0
(rmsfkit) deathstar:rmsfkit oliver$ pip --version
pip 24.0 from ~/anaconda3/envs/rmsfkit/lib/python3.12/site-packages/pip (python 3.12)
(rmsfkit) deathstar:rmsfkit oliver$ which python
~/anaconda3/envs/rmsfkit/bin/python

See also https://github.com/MDAnalysis/mdgeomkit/issues/1 .

IAlibay commented 5 months ago

Just to link back in the "solution" from the other package - we needed to explicitly define:

[tool.setuptools.packages.find]
include = ["directoryname"]

This seems like an easy enough fix, but I just don't understand why the current cookiecutter CI isn't picking it up :/

orbeckst commented 5 months ago

Is this an issue with upstream cookiecutter itself or our (or MolSSI's) template?

IAlibay commented 5 months ago

Ours I believe, we made the switch to pyproject.toml after we first forked from the molssi cookiecutter

orbeckst commented 5 months ago

When @ianmkenney made the tutorial, we must have still had a setup.py because both PR https://github.com/MDAnalysis/MDAKits/pull/140 and https://github.com/MDAnalysis/MDAKits/pull/144 removed these references after following the tutorial recently and not seeing setup.py.

orbeckst commented 5 months ago

@ljwoods2 I think you recently build a mda-cookiecutter based project. Did you run into this issue that it didn't install for you?

orbeckst commented 5 months ago

@lilyminium or @IAlibay could you please take on fixing the cookiecutter? This is reasonably high priority because we want to use the mda cookiecutter for the MDA/MolSSI workshop and the MolSSI folks need it to work soon so that they can prepare their part.

IAlibay commented 5 months ago

@orbeckst so sorry about delays, I can put this at the top of the priority list - is ~ end of the month reasonable? Depending on how much capacity others have this might be as realistic a timeline as I can give.

orbeckst commented 5 months ago

@lilyminium can you do it sooner than @IAlibay ?

orbeckst commented 5 months ago

@lilyminium and @IAlibay I apologize for my pushy comments above which, on second reading, very much sound as if I am not respecting your time.

I am happy to discuss more offline and explain my sense of urgency while also understanding the constraints that you are operating under.

ljwoods2 commented 5 months ago

@orbeckst this is how I did it for the zarrtraj mdakit

[tool.setuptools]
packages = ["zarrtraj"]
py-modules = ["__init__"]

As per: https://stackoverflow.com/questions/76663521/where-does-py-modules-go-in-pyproject-toml-setuptools

for imdreader I have just this, which also works:

[tool.setuptools]
packages = ["imdreader"]
lilyminium commented 5 months ago

@orbeckst no worries. I think @IAlibay is not available this weekend -- conversely I'll have time my Sunday + Monday (US weekend) to address issues. Happy to meet when @IAlibay's around again to work out priorities, but in the mean time I'll take getting the cookiecutter in better working condition to be the top priority for now?

orbeckst commented 5 months ago

Yes, because of the upcoming MDA/MolSSI workshop, the cookiecutter is high priority: We are asking the MolSSI folks to use our cookiecutter template (instead of the standard MolSSI cookiecutter) for teaching the MolSSI portion of the MDA/MolSSI workshop so our version really should work.

orbeckst commented 5 months ago

MANY THANKS!!!!