Skip to content

DEP: drop support for Python 3.11, require 3.12+ - #20223

Merged
astrofrog merged 1 commit into
astropy:mainfrom
neutrinoceros:dep/drop-cp311
Sep 3, 2026
Merged

astrofrog merged 1 commit into
astropy:mainfrom
neutrinoceros:dep/drop-cp311

Conversation

@neutrinoceros

@neutrinoceros neutrinoceros commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

As discussed in

close #18229
close #20184

After merge

  • Admin to update branch protection rules (carefully)
  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@neutrinoceros neutrinoceros added this to the v8.1.0 milestone Aug 8, 2026
@neutrinoceros neutrinoceros added Python 3.11 dependencies Pull requests that update a dependency file labels Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@neutrinoceros
neutrinoceros force-pushed the dep/drop-cp311 branch 4 times, most recently from 46db999 to fa7a591 Compare August 8, 2026 08:17
@neutrinoceros

neutrinoceros commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor Author

oldestdeps is failing with

ModuleNotFoundError: No module named 'six.moves'

(from cycler via matplotlib)
I don't understand it yet. six is actually installed there, as a declared dependency to cycler

edit: resolved by constraining six >= 0.16.0, which is the oldest version I cannot reproduce this error with.

@neutrinoceros
neutrinoceros force-pushed the dep/drop-cp311 branch 3 times, most recently from 2582b4c to b504b8f Compare August 8, 2026 11:09
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

Still hitting this error, and still getting six==1.9.0 despite the constraint. I'm suspecting a cache invalidation issue with tox, tox-uv, or OpenAstronomy/github-actions-workflows, but nothing conclusive yet.

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

The cached .tox actually isn't the (only ?) problem. I'm able to reproduce the issue locally without a .tox, and installing with uv directly gives me yet another version of six (1.5.0). That is, despite the resolver's logs clearly seeing my constraint:

DEBUG Adding transitive dependency for python-dateutil==2.7.0: six>=1.5
DEBUG Adding transitive dependency for python-dateutil==2.7.0: six>=0.16.0

This looks like something is broken in uv's resolver itself, but there's an additional source of error in the tox/tox-uv layer. Let's see if I can at least work around it for now by adding a direct requirement on six.

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

Nevermind, my constraint just contained a typo. The fix was

diff --git a/pyproject.toml b/pyproject.toml
index 7436fe9f2d..c3bfa6efb6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -829,7 +829,7 @@ required-environments = [
 constraint-dependencies = [
     "asdf>=2.15.1",
     "asdf-coordinates-schemas>=0.2.0",
-    "six>=0.16.0", # for Python 3.12+ compat
+    "six>=1.16.0", # for Python 3.12+ compat

     # via pytest
     # iniconfig 1.0.1 is the first version with proper wheels

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much! I had been considering doing it myself and now realize how much I would've missed... Two comments, neither of which is essential.

Comment thread astropy/wcs/src/astropy_wcs.c Outdated
}

Py_INCREF(Py_None);
return Py_None;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could replace (here and below) with Py_RETURN_NONE - which I like in that the reference counting is just hidden (i.e., one does not have to know Py_None is immortal).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call. I'll push out a separate commit just in case and will squash it if everything stays green.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

squashed

Comment thread .github/workflows/ci_workflows.yml Resolved
@pllim

This comment was marked as resolved.

@taldcroft taldcroft left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for table

@neutrinoceros
neutrinoceros marked this pull request as ready for review August 27, 2026 11:59
@neutrinoceros
neutrinoceros force-pushed the dep/drop-cp311 branch 3 times, most recently from e100f38 to 21543cc Compare August 27, 2026 13:47
Comment thread .github/workflows/ci_workflows.yml Resolved
Comment thread .ruff.toml

# pyupgrade (UP)
# temporarily delay upgrades to Python 3.12's PEP 695 typevars
# https://github.com/astropy/astropy/issues/20225

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xref #20225

@pllim

pllim commented Aug 27, 2026

Copy link
Copy Markdown
Member

@mcara do you want to have a look at the WCS stuff? Thanks!

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now. Thanks!

I will let you decide when to merge after a final comment period.

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

How about next week ? I just remembered this merger needs coordination with an owner anyway so I think it's best if you can handle it :)
thank you !

@astrofrog

Copy link
Copy Markdown
Member

For the record I have updated the branch protection rules, and am doing a final review of this PR.

@astrofrog astrofrog left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! A few small comments - once these are addressed I can approve and merge:

  • Check the docs for any instances of py311 - I think e.g. the test guide might mention it
  • I think codeql-analysis.yml should be updated to use Python 3.12 or later?
  • I think there are some references to Python 3.11 (check for "3.11") in astropy/config/paths.py
  • Should we update the minimum Python version in the scripts in scripts/?

}

Py_INCREF(Py_None);
result = Py_None;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be removed and replaced with Py_RETURN_NONE?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel confortable with this one; an early return would skip the exit block and leak a bunch of references

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok np let's leave as-is

Comment thread pyproject.toml Outdated

# see https://github.com/astropy/astropy/issues/18292
"array-api-strict<2.4 ; python_version<'3.12'",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure it's worth another round of CI so if that's the only request left I'll let you decide if you want to push it yourself

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are also a few comments in the top-level review, would you rather do these in a follow-up?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I wrote this before I saw them. I should have addressed everything now

@github-project-automation github-project-automation Bot moved this from Reviewer approved to Review in progress in Cosmology, the Expansion Sep 3, 2026
@neutrinoceros
neutrinoceros requested a review from saimn as a code owner September 3, 2026 11:39
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

Should we update the minimum Python version in the scripts in scripts/?

I don't see a need for it. Running these scripts with older python versions than supported by the package is still possible, even if unlikely to be needed.

@github-project-automation github-project-automation Bot moved this from Review in progress to Reviewer approved in Cosmology, the Expansion Sep 3, 2026
@astrofrog
astrofrog merged commit dde7834 into astropy:main Sep 3, 2026
43 of 45 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in Cosmology, the Expansion Sep 3, 2026
@neutrinoceros
neutrinoceros deleted the dep/drop-cp311 branch September 3, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Drop python 3.11? RFC: reminder to remove PyINCREF(Py_None) when support for Python 3.11 is dropped

7 participants