noaa-oar-arl / monetio

The Model and ObservatioN Evaluation Tool I/O package
https://monetio.readthedocs.io
MIT License
17 stars 29 forks source link

The pip installer seems to be going for the wrong path #190

Closed blychs closed 2 months ago

blychs commented 2 months ago

When monetio is installed as suggested by the docs in MELODIES-MONET, using pip, it goes for the wrong path. I. e., it is looking for the base directory monetio instead of monetio/monetio. Therefore, it does not find the __init__.py, and the only solution seems to be to import monetio.monetio.

After tinkering with it a bit, I was able to make it work (by comparing it with my installation of melodies-monet), but it required editing line 16 of /glade/work/plichtig/conda-envs/melodies-monet-test/lib/python3.11/site-packages/__editable___monet_2_2_10_finder.py

from def find_spec(cls, fullname: str, path=None, target=None) -> ModuleSpec | None: # type: ignore to def find_spec(cls, fullname: str, _path=None, _target=None) -> ModuleSpec | None: # type: ignore

and line 62 from def find_spec(cls, fullname: str, target=None) -> ModuleSpec | None: # type: ignore to def find_spec(cls, fullname: str, _target=None) -> ModuleSpec | None: # type: ignore

This seems to me as a bug with (my version of?) pip and/or conda.

maybe @dwfncar or @zmoon have some insight? Do we need to force some version of pip and/or conda?

I have no clue about why this problem showed up only now, considering I've been using this for a while. I did reinstall everything with pip though, while testing changing repos, but I don't think I updated anything else

zmoon commented 2 months ago

@blychs what is your pip version?

I just tried with a new env, which got pip 24.2 and setuptools 73.0.1, and had no issue.

blychs commented 2 months ago

pip 22.0 mamba 1.5.8 conda 24.5.0

I did use mamba to create the environment and install the initial packages, but as far as I'm aware, mamba is wrapping conda, and since this packages are installed with pip, that shouldn't make a difference

zmoon commented 2 months ago

What is the setuptools version in your env?

blychs commented 2 months ago

setuptools 70.0.0

zmoon commented 2 months ago

Do you want to try removing all traces of the installed monetio (pip uninstall + checking none of those site-packages stuff remains), upgrading pip/setuptools with conda/mamba, and trying editable install again?

blychs commented 2 months ago

Hi Zach. I just created a new environment from scratch and still see the same problem (pip 24.2, setuptools 73.0.0). An important note: I don't get any problem if I am in the monetio directory, it gets imported well. But if I am anywhere else, this happens. I installed all of the environment with conda this time, to make sure mamba wasn't messing things up. I have no clue why this happened.

Just another note (which I assume by your answers that you got right, but just in case anyone else looks here), I am talking about the installation of the developer's branch as editable.

zmoon commented 2 months ago

And what you did was run pip install --force-reinstall --no-deps --editable . inside the root of the monetio repo? What messages do you get if you do, at the root of the monetio repo,

pip uninstall monetio && pip install --no-deps --editable .
What I see ``` > pip uninstall monetio && pip install --no-deps --editable . Found existing installation: monetio 0.2.6 Uninstalling monetio-0.2.6: Would remove: /home/zmoon/mambaforge/envs/test/lib/python3.11/site-packages/__editable__.monetio-0.2.6.pth /home/zmoon/mambaforge/envs/test/lib/python3.11/site-packages/__editable___monetio_0_2_6_finder.py /home/zmoon/mambaforge/envs/test/lib/python3.11/site-packages/monetio-0.2.6.dist-info/* Proceed (Y/n)? y Successfully uninstalled monetio-0.2.6 Obtaining file:///home/zmoon/scratch/monetio Installing build dependencies ... done Checking if build backend supports build_editable ... done Getting requirements to build editable ... done Preparing editable metadata (pyproject.toml) ... done Building wheels for collected packages: monetio Building editable for monetio (pyproject.toml) ... done Created wheel for monetio: filename=monetio-0.2.6-0.editable-py3-none-any.whl size=4380 sha256=7cadbbcdf5063aee0595068bed99c61743614a5059ddaa119eb2d32a57737062 Stored in directory: /tmp/pip-ephem-wheel-cache-xhnsi948/wheels/38/e5/ae/608ddb64b30bcc082967e63c1e3a815c5bd7968b8b45ea80fb Successfully built monetio Installing collected packages: monetio Successfully installed monetio-0.2.6 ```
blychs commented 2 months ago
(melodies-monet-testinstaller) plichtig@derecho7:~/melodies-monet-testinstaller> git clone git@github.com:noaa-oar-arl/monetio.git
Cloning into 'monetio'...
remote: Enumerating objects: 4108, done.
remote: Counting objects: 100% (1546/1546), done.
remote: Compressing objects: 100% (395/395), done.
remote: Total 4108 (delta 1231), reused 1169 (delta 1151), pack-reused 2562 (from 1)
Receiving objects: 100% (4108/4108), 11.40 MiB | 9.36 MiB/s, done.
Resolving deltas: 100% (2792/2792), done.
(melodies-monet-testinstaller) plichtig@derecho7:~/melodies-monet-testinstaller> cd monetio
(melodies-monet-testinstaller) plichtig@derecho7:~/melodies-monet-testinstaller/monetio> git checkout develop
branch 'develop' set up to track 'origin/develop'.
Switched to a new branch 'develop'
(melodies-monet-testinstaller) plichtig@derecho7:~/melodies-monet-testinstaller/monetio> pip install --force-reinstall --no-deps --editable .
Obtaining file:///glade/u/home/plichtig/melodies-monet-testinstaller/monetio
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: monetio
  Building editable for monetio (pyproject.toml) ... done
  Created wheel for monetio: filename=monetio-0.2.6-0.editable-py3-none-any.whl size=4395 sha256=ab463723669254b6cd3cb7e62e7d153e36e7fb9ec63994624597e6fcb65706dc
  Stored in directory: /glade/derecho/scratch/plichtig/tmp/pip-ephem-wheel-cache-ypblguny/wheels/c1/fc/00/31f98fae183b3f9baa141db8f257570414c83564277ed00eb9
Successfully built monetio
Installing collected packages: monetio
  Attempting uninstall: monetio
    Found existing installation: monetio 0.2.6
    Uninstalling monetio-0.2.6:
      Successfully uninstalled monetio-0.2.6
Successfully installed monetio-0.2.6

However, I logged out from the system (I do everything in NCAR's hpc system), logged back in again and now it seems to be working, which makes me even more confused. I'll keep testing and let you know what goes on. I think that we could close this issue, and I'll reopen it if I get any new input. I am extremely confused by it, and it might just have been a sum of bad luck. However, I started testing this because a coworker had had this same issue. She had it both in her desktop computer and in NCAR's HPC system.