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.12 #42

Merged
merged 6 commits into from Nov 5, 2023
Merged

Add support for Python 3.12 #42

merged 6 commits into from Nov 5, 2023

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Sep 10, 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.

The final release is due in three weeks on 2023-10-02.


Bug report

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

=================================== FAILURES ===================================
__________________________________ test_curio __________________________________

    @pytest.mark.skipif(
        os.name == "nt" and sys.version_info >= (3, 9),
        reason="Curio breaks on Python 3.9+ on Windows. Fix was not released yet",
    )
    def test_curio():
>       import curio

../../../../venv-3.12/lib/python3.12/site-packages/sniffio/_tests/test_sniffio.py:67: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../../venv-3.12/lib/python3.12/site-packages/curio/__init__.py:6: in <module>
    from .queue import *
../../../../venv-3.12/lib/python3.12/site-packages/curio/queue.py:20: in <module>
    from . import workers
../../../../venv-3.12/lib/python3.12/site-packages/curio/workers.py:23: in <module>
    from .channel import Connection
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    # channel.py
    #
    # Support for a message passing channel that can send bytes or pickled
    # Python objects on a stream.  Compatible with the Connection class in the
    # multiprocessing module, but rewritten for a purely asynchronous runtime.
    
    __all__ = ['Channel']
    
    # -- Standard Library
    
    import os
    import pickle
    import struct
    import hmac
    import multiprocessing.connection as mpc
    import logging
    
    log = logging.getLogger(__name__)
    
    # -- Curio
    
    from . import socket
    from .errors import CurioError, TaskTimeout
    from .io import StreamBase, FileStream
    from . import thread
    from .time import timeout_after, sleep
    
    # Authentication parameters (copied from multiprocessing)
    
    AUTH_MESSAGE_LENGTH = mpc.MESSAGE_LENGTH    # 20
>   CHALLENGE = mpc.CHALLENGE                   # b'#CHALLENGE#'
E   AttributeError: module 'multiprocessing.connection' has no attribute 'CHALLENGE'. Did you mean: '_CHALLENGE'?

This is because dependency curio doesn't support Python 3.12 yet. This issue/PR has suggestions how to fix it: dabeaz/curio#361 / dabeaz/curio#363.

Further:

Important Notice: October 25, 2022

The Curio project is no longer making package releases. I'm more than happy to accept bug reports and may continue to work on it from time to time as the mood strikes. If you want the absolute latest version, you should vendor the source code from here. Curio has no dependencies other than the Python standard library. --Dave

So you'll need to either vendor and fix curio, or replace it with something else.

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

Thanks!

@codecov
Copy link

codecov bot commented Sep 10, 2023

Codecov Report

Merging #42 (d0c6b59) into master (0cfdab8) will not change coverage.
The diff coverage is n/a.

❗ Current head d0c6b59 differs from pull request most recent head d44c25b. Consider uploading reports for the commit d44c25b to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #42   +/-   ##
=======================================
  Coverage   96.51%   96.51%           
=======================================
  Files           4        4           
  Lines          86       86           
  Branches       17       15    -2     
=======================================
  Hits           83       83           
  Misses          2        2           
  Partials        1        1           

@njsmith
Copy link
Member

njsmith commented Sep 11, 2023

can you mark the test skipif(sys.version >= (3, 12), reason="curio broken on 3.12 (https://github.com/python-trio/sniffio/pull/42)"? then we could merge as-is

@hugovk
Copy link
Contributor Author

hugovk commented Sep 11, 2023

Now skipped. We could also skip installing the package for 3.12+?

Also removed the older Windows/3.9+ skip because the fix it was waiting for was released in the final curio on PyPI.

I also forgot to add 3.12 to the CI for macOS, so have added that too.

@hugovk hugovk marked this pull request as ready for review September 11, 2023 10:07
@hugovk hugovk changed the title [Bug report] Add support for Python 3.12 Add support for Python 3.12 Sep 11, 2023
@A5rocks A5rocks merged commit ef41e63 into python-trio:master Nov 5, 2023
20 checks passed
@trio-bot
Copy link

trio-bot bot commented Nov 5, 2023

Hey @hugovk, it looks like that was the first time we merged one of your PRs! Thanks so much! 🎉 🎂

If you want to keep contributing, we'd love to have you. So, I just sent you an invitation to join the python-trio organization on Github! If you accept, then here's what will happen:

  • Github will automatically subscribe you to notifications on all our repositories. (But you can unsubscribe again if you don't want the spam.)

  • You'll be able to help us manage issues (add labels, close them, etc.)

  • You'll be able to review and merge other people's pull requests

  • You'll get a [member] badge next to your name when participating in the Trio repos, and you'll have the option of adding your name to our member's page and putting our icon on your Github profile (details)

If you want to read more, here's the relevant section in our contributing guide.

Alternatively, you're free to decline or ignore the invitation. You'll still be able to contribute as much or as little as you like, and I won't hassle you about joining again. But if you ever change your mind, just let us know and we'll send another invitation. We'd love to have you, but more importantly we want you to do whatever's best for you.

If you have any questions, well... I am just a humble Python script, so I probably can't help. But please do post a comment here, or in our chat, or on our forum, whatever's easiest, and someone will help you out!

@hugovk hugovk deleted the add-3.12 branch November 5, 2023 09:15
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.

None yet

4 participants