popsim-consortium / stdpopsim

A library of standard population genetic models
GNU General Public License v3.0
121 stars 86 forks source link

numpy v2 and requirements.txt #1566

Open petrelharp opened 4 days ago

petrelharp commented 4 days ago

Right now, installing requirements/development.txt gets

>>> import stdpopsim

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "<stdin>", line 1, in <module>
  File "/home/peter/projects/popsim-consortium/stdpopsim/stdpopsim/__init__.py", line 12, in <module>
    from .genetic_maps import *  # NOQA
  File "/home/peter/projects/popsim-consortium/stdpopsim/stdpopsim/genetic_maps.py", line 6, in <module>
    import msprime
  File "/home/peter/micromamba/envs/stdpopsim/lib/python3.12/site-packages/msprime/__init__.py", line 28, in <module>
    from msprime._msprime import (
Traceback (most recent call last):
  File "/home/peter/micromamba/envs/stdpopsim/lib/python3.12/site-packages/numpy/core/_multiarray_umath.py", line 44, in __getattr__
    raise ImportError(msg)
ImportError: 
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/peter/projects/popsim-consortium/stdpopsim/stdpopsim/__init__.py", line 12, in <module>
    from .genetic_maps import *  # NOQA
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/peter/projects/popsim-consortium/stdpopsim/stdpopsim/genetic_maps.py", line 6, in <module>
    import msprime
  File "/home/peter/micromamba/envs/stdpopsim/lib/python3.12/site-packages/msprime/__init__.py", line 28, in <module>
    from msprime._msprime import (
ImportError: numpy.core.multiarray failed to import

Currently, tskit pins to numpy<2 in requirements/development.txt; however, not in the conda prereqs -- I'm confused.

petrelharp commented 3 days ago

We shouldn't need to do anything for this once this is fixed upstream: https://github.com/tskit-dev/msprime/pull/2287