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

[Bug report] Add support for Python 3.12 #3176

Closed
wants to merge 4 commits into from
Closed

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Sep 8, 2023

The second and final Python 3.12 release candidate is out! 🚀

Call to action

We strongly encourage maintainers of third-party Python projects to prepare their projects for 3.12 compatibilities during this phase, and where necessary publish Python 3.12 wheels on PyPI to be ready for the final release of 3.12.0.

See also https://dev.to/hugovk/help-test-python-312-beta-1508/

The full Python 3.12.0 release is in under a month: 2023-10-02.

Bug report

Consider this a PR a bug report, the Python 3.12 build fails:

________________ ERROR collecting tests/unit/ssladapter_test.py ________________
ImportError while importing test module '/home/runner/work/docker-py/docker-py/tests/unit/ssladapter_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.12.0-rc.2/x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/unit/ssladapter_test.py:2: in <module>
    from ssl import match_hostname, CertificateError
E   ImportError: cannot import name 'match_hostname' from 'ssl' (/opt/hostedtoolcache/Python/3.12.0-rc.2/x64/lib/python3.12/ssl.py)

This is because ssl.match_hostname was removed in Python 3.12 after being deprecated in 3.7:

Replacements

Here's how a couple of other projects dealt with it:

Feel free to use this PR as a starting point for fixing it as you see best, or close this as needed.

Thanks!

Signed-off-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Signed-off-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Signed-off-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Signed-off-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
@milas milas self-assigned this Sep 29, 2023
@milas milas added this to the v7 milestone Sep 29, 2023
@milas milas self-requested a review September 29, 2023 20:44
@Jamim
Copy link

Jamim commented Nov 16, 2023

Hello @milas,

I'd like to gently remind that Python 3.12 was released on October 2, 2023.
It would be great if you find time to take a look at this PR.

Thanks!

@milas
Copy link
Contributor

milas commented Nov 21, 2023

Thanks for getting the ball rolling here! I extended this branch with #3185 to resolve the compatibility issues.

Changes from this branch have been merged via that PR (with attribution).

@milas milas closed this Nov 21, 2023
sthagen pushed a commit to sthagen/docker-docker-py that referenced this pull request Nov 21, 2023
…er#3185)

Add support for Python 3.12.

`match_hostname` is gone in Python 3.12 and has been unused by
Python since 3.7.

The custom SSL adapter allows passing a specific SSL version; this
was first introduced a looong time ago to handle some SSL issues
at the time.

Closes docker#3176.

---------

Signed-off-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
@milas
Copy link
Contributor

milas commented Nov 21, 2023

I just tagged 7.0.0b1 which adds Python 3.12 support among other changes.

It's a major version because there are some light breaking changes.

See the release for details: https://github.com/docker/docker-py/releases/tag/7.0.0b1


Will plan on a stable release in a week or so pending verification in moby/moby and any reported regressions here. Thanks!

@hugovk hugovk deleted the add-3.12 branch November 21, 2023 18:41
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.

3 participants