Skip to content

Enable testing on Python 3.12 #400

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 6 commits into from
Dec 1, 2023
Merged

Enable testing on Python 3.12 #400

merged 6 commits into from
Dec 1, 2023

Conversation

musicinmybrain
Copy link
Contributor

Issue #, if available:

Description of changes:

Added an explicitly dependency on setuptools, since a test imports pkg_resources.

Added Python 3.12 versions of all the tox environments that supported Python 3.11.

Added Python 3.12 to GitHub unit testing workflow.

I did not add Python 3.12 to the trove classifiers, but I’m happy to add this if it’s wanted.

Additional information:

Testing this PR requires #399.

It may also be necessary to use a very recent version of pip:

python3.12 -m venv _e
. _e/bin/activate
pip install --upgrade pip tox
tox

Most tests pass. Some HTTP tests seem to fail or flake in all Python versions due to transient issues at https://httpbin.org/. At a glance, regressions specific to Python 3.12 appear to be due to certain dependencies not being ready.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@musicinmybrain musicinmybrain requested a review from a team as a code owner August 8, 2023 12:54
@musicinmybrain
Copy link
Contributor Author

Compare to: #376

@musicinmybrain
Copy link
Contributor Author

The motivation for this PR is:

  • I am adding aws-xray-sdk-python to Fedora Linux, which already has Python 3.12 in the development version (Rawhide) and will release Fedora 39 with Python 3.12 this fall.
  • Since test dependencies are generated from (Python-version-specific) tox environments, I needed to patch in Python 3.12 versions of the existing environments to generate the proper dependencies for the RPM build process.
  • Offering necessary changes upstream is good practice.

py{37,38,39,310,311,312}: pytest-asyncio

; For pkg_resources
py{37,38,39,310,311,312}: setuptools
Copy link
Contributor

Choose a reason for hiding this comment

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

I am still not very clear on why this dependency is needed. You mentioned it was added since a test imports pkg_resources, which test are you referring to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The pkg_resources module is deprecated, but this test appears to be intentionally and specifically verifying compatibility with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably only “necessary” on Python 3.12 though:

gh-95299: Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the activated virtual environment.

https://docs.python.org/3.12/whatsnew/3.12.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps, but it’s not harmful on others. The dependency is still real; it’s just allowed to be implicit. I guess I can change to py312 only if implicit is better than explicit.

@@ -16,13 +16,14 @@ jobs:
py39: 3.9
py310: '3.10'
py311: '3.11'
py312: '3.12'
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: Should have worked at the time with 3.12.0-beta - 3.12. But it's available now, see https://github.com/actions/python-versions/blob/main/versions-manifest.json

Maybe rebase to trigger a rerun?

@musicinmybrain
Copy link
Contributor Author

Hmm, I’m not sure why this is failing on Python 3.12 with ModuleNotFoundError: No module named 'setuptools' from setup.py. In local testing with tox, the added dependency on setuptools in tox.ini works as expected.

@michael-k
Copy link
Contributor

run: pip install "tox<=3.27.1" -U tox-factor should install setuptools as well. The added dependency is only available inside the venv that tox creates. But it's required outside as well to build the sdist.

- name: Install tox
run: pip install "tox<=3.27.1" -U tox-factor

@musicinmybrain
Copy link
Contributor Author

run: pip install "tox<=3.27.1" -U tox-factor should install setuptools as well. The added dependency is only available inside the venv that tox creates. But it's required outside as well to build the sdist.

Thanks. Hopefully 2a682c9 is correct and sufficient.

@srprash srprash merged commit 2e07898 into aws:master Dec 1, 2023
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.

4 participants