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

ENH: Modernize package setup #56

Merged
merged 2 commits into from
Dec 4, 2024

Conversation

jhlegarreta
Copy link
Contributor

Modernize packate setup:

  • Adopt PEP621 to store project metadata in pyproject.toml. Remove the setup.py file.
  • Adopt PEP518 to specify the build system requirements for the package.
  • Adopt PEP631 to specify the package dependencies in the pyproject.toml file, and remove the requirements,txt.
  • Transition to setuptools_scm dynamic versioning system.

Change the GHA package test workflow file accordingly.

Add the _version.py file to the .gitignore file list.

Documentation:
https://peps.python.org/pep-0621/
https://packaging.python.org/en/latest/specifications/pyproject-toml/#pyproject-toml-spec https://peps.python.org/pep-0518/
https://peps.python.org/pep-0631/
https://setuptools.pypa.io/en/latest/index.html
https://setuptools-scm.readthedocs.io/en/latest/

@jhlegarreta jhlegarreta force-pushed the ModernizePackageSetup branch from 6482726 to e03d5cc Compare December 3, 2024 17:52
@jhlegarreta jhlegarreta marked this pull request as ready for review December 3, 2024 17:55
Modernize packate setup:
- Adopt PEP621 to store project metadata in `pyproject.toml`. Remove the
  `setup.py` file.
- Adopt PEP518 to specify the build system requirements for the
  package.
- Adopt PEP631 to specify the package dependencies in the
  `pyproject.toml` file, and remove the `requirements,txt`.
- Transition to `setuptools_scm` dynamic versioning system.

Change the GHA package test workflow file accordingly.

Add the `_version.py` file to the `.gitignore` file list.

Documentation:
https://peps.python.org/pep-0621/
https://packaging.python.org/en/latest/specifications/pyproject-toml/#pyproject-toml-spec
https://peps.python.org/pep-0518/
https://peps.python.org/pep-0631/
https://setuptools.pypa.io/en/latest/index.html
https://setuptools-scm.readthedocs.io/en/latest/
@jhlegarreta jhlegarreta force-pushed the ModernizePackageSetup branch 3 times, most recently from 41a7bf4 to 82a2b0a Compare December 3, 2024 21:04
Require a more recent version of `NumPy`: require any version greater or
equal to 1.19.5 but lower than 2.0.0. `NumPy` 1.19.5 was the first
release supporting Python 3.9.

Fixes:
```
    from distutils.msvccompiler import get_build_version as get_build_msvc_version
ModuleNotFoundError: No module named 'distutils.msvccompiler'
```

raised for example at:
https://github.com/demianw/tract_querier/actions/runs/12145326696/job/33866697673#step:5:806
@jhlegarreta jhlegarreta force-pushed the ModernizePackageSetup branch from 82a2b0a to 62f028c Compare December 3, 2024 21:32
@jhlegarreta
Copy link
Contributor Author

With commit 62f028c Python 3.9 both minimal and latest are installing the package correctly, but the tests are failing because the NiBabel version is too old with respect to the NumPy version:

For minimal 4 out of 47 tests fail:

tract_querier.tractography.tests.test_saveload_trk ... ERROR
tract_querier.tractography.tests.test_saveload ... ERROR
tract_querier.tractography.tests.test_tractography.test_saveload_trk ... ERROR
tract_querier.tractography.tests.test_tractography.test_saveload ... ERROR

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/nose/util.py", line 620, in newfunc
    return func(*arg, **kw)
  File "/home/runner/work/tract_querier/tract_querier/tract_querier/tractography/tests/test_tractography.py", line 201, in test_saveload_trk
    new_tractography = tractography_from_trackvis_file(fname)
  File "/home/runner/work/tract_querier/tract_querier/tract_querier/tractography/trackvis.py", line 79, in tractography_from_trackvis_file
    tracts_and_data, header = trackvis.read(filename, points_space='rasmm')
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/nibabel/trackvis.py", line 233, in read
    streamlines = list(streamlines)
RuntimeError: generator raised StopIteration

and for latest:

  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/nibabel/quaternions.py", line 31, in <module>
    MAX_FLOAT = np.maximum_sctype(np.float)
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/numpy/__init__.py", line 324, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Python 3.10 is failing because the minimal version requires a more recent NumPy version (NumPy started supporting Python 3.10 starting 1.21.0), and because nose is not packaged for the last few Python releases:

  File "/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/nose/suite.py", line 106, in _set_tests
    if isinstance(tests, collections.Callable) and not is_suite:
AttributeError: module 'collections' has no attribute 'Callable'

So first is to update NiBabel to a more recent version. This will involve refactoring/removing the tract_querier.trackvis module and the related methods/tests, as NiBabel deprecated its trackvis module in 3.0.0.

@demianw demianw merged commit 983e359 into demianw:master Dec 4, 2024
0 of 8 checks passed
@jhlegarreta jhlegarreta deleted the ModernizePackageSetup branch December 4, 2024 13:25
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 this pull request may close these issues.

2 participants