Skip to content

tests: Test on Python 3.12 (locally and on CI) #255

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

Merged
merged 3 commits into from
Sep 13, 2023

Conversation

EliahKagan
Copy link
Contributor

@EliahKagan EliahKagan commented Aug 22, 2023

This adds Python 3.12 tox environments and a CI test job. This PR should probably be updated before being merged, so that all checks pass. There is more than one way this could be done, as detailed at the very end of this PR description.

"Experimental" status: continue-on-error, allow-prereleases

The 3.11 CI job had been marked experimental. This marks that non-experimental (like the preceding Python versions' jobs) and marks the 3.12 CI job experimental, with two effects:

  • Because experimental is used as the value of continue-on-error, if a 3.12 job fails, the workflow as a whole will still fail, but other jobs generated by the CI test matrix will not be automatically canceled.
  • In addition, this uses experimental as the value of allow-prereleases for setup-python, to allow the Python 3.12 release candidate to be used. At some point after the stable release of Python 3.12.0, that should be removed (or, equivalently, changed to the literal value false), even if continue-on-error is kept as true for longer.

Handling setuptools omission and pkg_resources deprecation

For testing purposes, the first commit (41f3d29) also temporarily adds setuptools as an explicit test dependency on 3.12, to support the pkg_resources import in conftest.py. But I recommend fixing that issue differently, by migrating from pkg_resources to importlib.resources instead, which I've submitted a patch for in #252. The second commit (94a22de) removes the explicit test dependency for setuptools, causing failure.

I recommend against merging this pull request until the tests are passing again. I've made the PR this way to allow the CI results to be inspected both for passing and failing 3.12 tests. But a more important reason is that I don't want to dictate how the pkg_resources problem is solved:

  • The approach I recommend is to merge tests: Migrate from pkg_resources to importlib.resources #252. Then this PR can be updated by merging master into it. That would eliminate the deprecated use of pkg_resources.

    (If tests: Test on multiple operating systems #251 is to be accepted, then it may make sense to merge that first, too, so that when this PR is updated it also gets 3.12 jobs on all three operating systems. Because of 3.12's current status as a prerelease, I believe platform-specific problems are more likely than usual.)

  • An alternative approach could be to drop or revert the second commit from this PR, keeping the explicit setuptools test dependency so the deprecated pkg_resources import can be retained. I would only suggest doing this if you have decided to decline or defer tests: Migrate from pkg_resources to importlib.resources #252.

This adds Python 3.12 tox environments and CI test job.

The 3.11 CI job had been marked experimental. This marks that
non-experimental (like the preceding Python versions' jobs) and
marks the 3.12 CI job experimental. If it fails, the workflow as a
whole will still fail, but the other jobs generated by the CI test
matrix will not be automatically canceled due to a 3.12 failure.

In this commit, setuptools is also added as an explicit test
dependency on 3.12, for the pkg_resources import in conftest.py.
(In 3.12, setuptools, which provides pkg_resources, is no longer
automatically installed in virtual environments.) This facilitates
testing, but it may be better to fix that issue by migrating from
pkg_resources to importlib.resources instead.
This breaks tox and CI tests on Python 3.12 unless/until
conftest.py is migrated from pkg_resources to importlib.resources.
@EliahKagan EliahKagan marked this pull request as ready for review August 22, 2023 04:53
@cwacek cwacek merged commit 47488cc into cwacek:master Sep 13, 2023
@EliahKagan EliahKagan deleted the py312 branch September 13, 2023 00:46
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