mosdef-hub / mbuild

A hierarchical, component based molecule builder
https://mbuild.mosdef.org
Other
171 stars 79 forks source link

Plugins error when creating anaconda environment with python 3.12 #1175

Closed chrisjonesBSU closed 5 months ago

chrisjonesBSU commented 5 months ago

Bug summary

If I create an anaconda environment that installs mbuild along with python 3.12, I get errors when trying to import mbuild.

Note, pinning python to 3.12 gives me mbuild 0.16.4 If I pin python to 3.11, I get mbuild 0.17. If I pin both mbuild=0.17 and python=3.12 then the packages are incompatible

The following packages are incompatible
├─ mbuild 0.17**  is installable and it requires
│  └─ python >=3.8,<=3.11 , which can be installed;

Code to reproduce the behavior

mamba create -n mbuild -c conda-forge mbuild "python=3.12"
mamba activate mbuild

python -c "import mbuild"

Gives this error:

/home/chris/miniconda3/envs/mbuild/lib/python3.12/site-packages/mdtraj/utils/unit/__init__.py:57: DeprecationWarning: ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead
  ast.Pow, ast.Div, ast.Mult, ast.Num]
/home/chris/miniconda3/envs/mbuild/lib/python3.12/site-packages/mdtraj/formats/__init__.py:6: DeprecationWarning: 'xdrlib' is deprecated and slated for removal in Python 3.13
  from .xtc import XTCTrajectoryFile
/home/chris/miniconda3/envs/mbuild/lib/python3.12/site-packages/mdtraj/geometry/order.py:25: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import parse_version
/home/chris/miniconda3/envs/mbuild/lib/python3.12/site-packages/pkg_resources/__init__.py:2832: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)
Traceback (most recent call last):
  File "/home/chris/miniconda3/envs/mbuild/lib/python3.12/importlib/metadata/__init__.py", line 285, in __getitem__
    return next(iter(self.select(name=name)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/chris/miniconda3/envs/mbuild/lib/python3.12/site-packages/mbuild/__init__.py", line 11, in <module>
    from mbuild.recipes import recipes
  File "/home/chris/miniconda3/envs/mbuild/lib/python3.12/site-packages/mbuild/recipes/__init__.py", line 13, in <module>
    entry_points = metadata.entry_points()["mbuild.plugins"]
                   ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/chris/miniconda3/envs/mbuild/lib/python3.12/importlib/metadata/__init__.py", line 287, in __getitem__
    raise KeyError(name)
KeyError: 'mbuild.plugins'

Software versions

daico007 commented 5 months ago

Yes, I bumped into this issue too, and I think I had introduced a fix for it here https://github.com/mosdef-hub/mbuild/pull/1169/files#diff-3a5085d6be9766a5e783d6cc4745a042ee1939f2de22fc8e21bbd8600f1c1a87L13-L14. Sorry it was masked in a docs fix PR. Also, it's probably time for us to introduce python 3.12 to the test matrix.

chrisjonesBSU commented 5 months ago

Ok cool, thanks! Do we need to also pin the python version in the mbuild conda-forge feedstock, since that is where conda looks rather than the .yml files in the repo.

daico007 commented 5 months ago

Good point! I will update the conda-forge recipe to pin the python version when install from conda/mamba

daico007 commented 5 months ago

FYI, I just checked our feedstock and the python versions have already been pinned there to be between 3.8 and 1.11

chrisjonesBSU commented 5 months ago

Ok yeah, I see that now. If I pull mbuild from conda-forge I get mbuild 0.17.0 and python 3.11. I think the problem is if I pull mbuild 0.16.4 from conda-forge, I get python 3.12, and the import errors. Is it possible to change previous version's dependencies on conda-forge? Using 0.17 fixes this, but I think I was having some issues building a mosdef environment packages were wanting python 3.12, so mbuild 0.16.4 was being used instead of 0.17. I think we can close this, but it might be worth checking if the python version can be changed for 0.16.4 as well.

daico007 commented 5 months ago

I am not sure if we can update the python of past package (one solution I can think of is having a build, using the old sh256 and version number, but I am worry it may mess up the feed stock and the stack hosted on conda-forge). Would releasing mbuild 0.17.1 (so with the fix) sound appealing to you? I can try to have a release out tomorrow?

chrisjonesBSU commented 5 months ago

I don't think we need to do anything right now, I can't seem to re-create the issue anymore (where I was getting mbuild 0.16.4 instead of 0.17), and it sounds like this should be fixed for the latest release. Thanks!