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

Add support for Python 3.13 and numpy 2 #27

Merged
merged 2 commits into from
Dec 15, 2024

Conversation

lukeshingles
Copy link
Member

@lukeshingles lukeshingles commented Aug 9, 2024

Hi, thanks for the very useful extinction package. We depend on it when plotting observed spectra for comparison with our models with the https://github.com/artis-mcrt/artistools package.

cpython3.13 is now in the release candidate stage, which means that the ABI is stable and wheels can now be published to PyPI. The latest version of cibuildwheel now builds py313 wheels by default.

Building extinction with the cpython 3.13 headers results in a compilation error that is resolved when updating the C standard from C99 to C11. I also updated the GitHub actions workflows to test and build wheels for python3.13.

Fixes #26 by upgrading to numpy 2 when building for cpython >= 3.9 (installation still supports numpy 1). The minimum python version increased from 3.5 to 3.6 because this is the oldest version I can get to work on GitHub actions.

@lukeshingles lukeshingles marked this pull request as ready for review August 9, 2024 10:30
@lukeshingles lukeshingles force-pushed the py313 branch 6 times, most recently from 53b79e6 to 8264312 Compare August 9, 2024 10:51
@lukeshingles lukeshingles changed the title Add support for Python 3.13 Add support for Python 3.13 and numpy 2 Aug 9, 2024
@lukeshingles lukeshingles force-pushed the py313 branch 6 times, most recently from 2e3f24b to e647b76 Compare August 12, 2024 08:05
@lukeshingles
Copy link
Member Author

@kbarbary could you please enable the CI workflow and review when possible?

@lukeshingles
Copy link
Member Author

@kbarbary cpython 3.13 is now released. Please consider merging this PR.

@temuller
Copy link

temuller commented Dec 5, 2024

Hi @lukeshingles. Have you thought about making your extinction repo available for the community? It looks like @kbarbary has not replied in years. See also sep where someone else "took over".

@lukeshingles
Copy link
Member Author

@temuller I'm on a fixed term contract, so if I leave academia, I would also end up abandoning the repository. Ideally, a permanent staff member should fork and maintain this repo.

The good news is that I am now able to pip install extinction on python3.13 and build from source successfully for whatever reason. This was probably fixed by some update to Cython, numpy, etc.

@kbarbary
Copy link
Member

kbarbary commented Dec 13, 2024

Many apologies for not replying until now. I left the field of astrophysics for industry 7 years ago. At the time in 2017, I left my widely used projects (sep and extinction) in a good up-to-date state and called them feature complete. After that, I did a good job keeping up with minor maintenance for the first few years, but as time has gone on, my life has other priorities and my paying job and personal life always seem to come ahead of maintenance tasks on my astrophysics code projects. I've been meaning to catch up with the emails and github notifications, but it's always too low on my "to do" list. I feel quite bad for the community using this project for the numpy deprecations and lack of new Python version support that I haven't addressed -- I know how annoying this stuff can be! Clearly this needs a new maintainer.

Anyway, I'm looking for someone interested in taking over support for this project, similar to what happened with sep where Peter Watson and I recently created the http://github.com/sep-developers organization and transferred ownership of the sep repo to it, along with maintainer access to the associated PyPI and readthedocs projects. I'll first inquire with the sncosmo folks in sncosmo/sncosmo#372 if the sncosmo organization wants to take over ownership. Otherwise, @lukeshingles would you be interested in taking over ownership of the repo? Alternatively, I could give PyPI access to anyone interested in creating new releases.

@kbarbary
Copy link
Member

@benjaminrose has agreed to have this package moved to the sncosmo organization. Is that an OK solution for you @lukeshingles (and @temuller)? If you're interested in managing new releases for this package, I'd imagine they'd love to add you to that org and/or the PyPI project for extinction.

Thanks for your contributions here!

@lukeshingles
Copy link
Member Author

@kbarbary Great solution, thanks! I can’t guarantee for how long I’ll be in astronomy, but would be happy to help keep the package building and installing in the meantime.

@kbarbary
Copy link
Member

@lukeshingles The repo has been transferred and I invited you to join sncosmo and the PyPI project.

@lukeshingles lukeshingles force-pushed the py313 branch 5 times, most recently from d9fc86f to 8f609f1 Compare December 14, 2024 05:45
@benjaminrose benjaminrose self-assigned this Dec 14, 2024
@lukeshingles lukeshingles merged commit f40f713 into sncosmo:main Dec 15, 2024
8 checks passed
@benjaminrose
Copy link
Member

Unless I'm mistaken, @lukeshingles pushing this merge to PyPI makes extinction not work with numpy <2.0 on modern python versions. That will break a lot of people's code, including SNCosmo. Can we discus this before merging and pushing to PyPI?

@lukeshingles
Copy link
Member Author

Unless I'm mistaken, @lukeshingles pushing this merge to PyPI makes extinction not work with numpy <2.0 on modern python versions. That will break a lot of people's code, including SNCosmo. Can we discus this before merging and pushing to PyPI?

Hello, sorry, but a new version is already uploaded to PyPI. The numpy 2.0 migration guide says that packages built with numpy 2 can be installed on environments with numpy 1.x. Can you tell me if something has become broken and I'll prioritise a fix/rollback?

@jvansanten
Copy link

Hey, I can confirm that extinction 0.4.7 from PyPI works with current sncosmo:

> tox run -e py312 -r
...
py312: commands[0] /Users/jakob/Documents/ZTF/forks/sncosmo/.tox/py312/tmp> pip freeze
...
extinction==0.4.7
...
numpy==1.26.4
...
py312: commands[1] /Users/jakob/Documents/ZTF/forks/sncosmo/.tox/py312/tmp> pytest --pyargs sncosmo
...
========= 113 passed, 13 skipped, 4 warnings in 22.03s ===========
  py312: OK (63.83=setup[37.05]+cmd[0.48,26.30] seconds)

(irrelevant lines abbreviated with ... for clarity)

As the migration guide says, the Numpy 2 ABI is backwards-compatible with Numpy 1, but Numpy 1 is not forwards-compatible with Numpy 2. This is why this PR required numpy>=2 at build time, but left the runtime requirement untouched.

@benjaminrose
Copy link
Member

Thanks @jvansanten. I missed that the numpy 2.0 was under the build requirements and not the runtime! Thanks to both you and @lukeshingles for helping get these two projects working with Numpy 2.

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.

Please add numpy2 support
5 participants