Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nptyping's numpy<2 constraint breaks pynrrd when installed with numpy>2 #152

Closed
eleftherioszisis opened this issue Oct 4, 2024 · 2 comments · Fixed by #154
Closed

nptyping's numpy<2 constraint breaks pynrrd when installed with numpy>2 #152

eleftherioszisis opened this issue Oct 4, 2024 · 2 comments · Fixed by #154

Comments

@eleftherioszisis
Copy link
Contributor

eleftherioszisis commented Oct 4, 2024

nptyping has an upper constraint on the numpy version:
https://github.com/ramonhagenaars/nptyping/blob/785cd07e65f992f47256398fd01f62067928d29c/dependencies/requirements.txt#L2

which results in picking an old version of nptyping that doesn't have that constraint when installed with numpy>=2.0.0

pip install 'numpy>=2.0' 'pynrrd>=1.0.0'
Collecting numpy>=2.0
  Using cached numpy-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.3 MB)
Collecting pynrrd>=1.0.0
  Downloading pynrrd-1.0.0-py2.py3-none-any.whl (19 kB)
Collecting nptyping
  Downloading nptyping-2.5.0-py3-none-any.whl (37 kB)
Collecting typing-extensions
  Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Collecting nptyping
  Downloading nptyping-2.4.1-py3-none-any.whl (36 kB)
  Downloading nptyping-2.4.0-py3-none-any.whl (35 kB)
  Downloading nptyping-2.3.1-py3-none-any.whl (32 kB)
  Downloading nptyping-2.3.0-py3-none-any.whl (32 kB)
  Downloading nptyping-2.2.0-py3-none-any.whl (31 kB)
  Downloading nptyping-2.1.3-py3-none-any.whl (31 kB)
  Downloading nptyping-2.1.2-py3-none-any.whl (31 kB)
  Downloading nptyping-2.1.1-py3-none-any.whl (30 kB)
  Downloading nptyping-2.1.0-py3-none-any.whl (29 kB)
  Downloading nptyping-2.0.1-py3-none-any.whl (19 kB)
Installing collected packages: typing-extensions, numpy, nptyping, pynrrd
Successfully installed nptyping-2.0.1 numpy-2.1.1 pynrrd-1.0.0 typing-extensions-4.12.2

This is however an issue because of deprecated types present in that old version of nptyping:

python -c "import nrrd"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/eleftherios/Projects/v310-test/lib/python3.10/site-packages/nrrd/__init__.py", line 2, in <module>
    from nrrd.formatters import *
  File "/home/eleftherios/Projects/v310-test/lib/python3.10/site-packages/nrrd/formatters.py", line 3, in <module>
    import nptyping as npt
  File "/home/eleftherios/Projects/v310-test/lib/python3.10/site-packages/nptyping/__init__.py", line 30, in <module>
    from nptyping.ndarray import NDArray
  File "/home/eleftherios/Projects/v310-test/lib/python3.10/site-packages/nptyping/ndarray.py", line 32, in <module>
    from nptyping.shape_expression import (
  File "/home/eleftherios/Projects/v310-test/lib/python3.10/site-packages/nptyping/shape_expression.py", line 35, in <module>
    from nptyping.typing_ import Literal
  File "/home/eleftherios/Projects/v310-test/lib/python3.10/site-packages/nptyping/typing_.py", line 66, in <module>
    Bool8: TypeAlias = np.bool8
  File "/home/eleftherios/Projects/v310-test/lib/python3.10/site-packages/numpy/__init__.py", line 414, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'bool8'. Did you mean: 'bool'?

Is it worth considering removing nptyping as a dependency?

@addisonElliott
Copy link
Collaborator

Is it worth considering removing nptyping as a dependency?

I think it's worth considering. It's not used very much in the codebase, so I think we could live with converting to numpy.typing.

If we do that, probably a new major revision and upgrading the minimum numpy version required.

If I get some time, I'll play around with migrating over.

@eleftherioszisis
Copy link
Contributor Author

@addisonElliott I took a stab at it with #154. Please let me know if that will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants