sopel-irc / sopel

:robot::speech_balloon: An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
https://sopel.chat
Other
949 stars 403 forks source link

Add Python 3.12 support #2516

Closed SnoopJ closed 11 months ago

SnoopJ commented 1 year ago

Description

This changeset adds Python 3.12 support to Sopel, which mostly means some chore updating of version lists. The most notable change is the adjustment of the pinned version of setuptools to avoid a known incompatibility with 3.12.

~At one point it looked like aiohttp would be a blocker for this support (as they still have no issued a new release with a compat bugfix :grimacing:), but the problem disappeared between the last check of a Python 3.12 RC against Sopel and the official release. :shrug:~ Edit: nope, aiohttp is indeed a problem (failure in CI associated with the known upstream bug), so we will be waiting for them to do a new release after all. We can workaround the build failure by AIOHTTP_NO_EXTENSIONS=1 in the environment, but there isn't a compelling reason to do this in CI, we can just wait on upstream to do a release. See related issue, hopefully that will happen in the next week or so.

Edit: since the closure of #2523, the above no longer blocks this PR. Users who want both Python 3.12 and sopel-iplookup will be stuck waiting on aiohttp, but they can add --pre to their install command or set the above environment variable to get around it.

Closes #2457

Checklist

Supplemental checklist (from #2457)

SnoopJ commented 12 months ago

aiohttp has a pre-release version out that includes the fix for Python 3.12 support, installing Sopel with this changeset using the --pre option to pip succeeds. Looks like they are moving more slowly than usual between the pre-release and the full release to allow their users to test, keeping an eye on the relevant issue for now.

dgw commented 11 months ago

Rebasing this to fix the merge conflict from #2520 will be the perfect excuse to make GHA retest after aiohttp gets its Python 3.12 ducks lined up. Which should be any day now… right? (Lots of recent activity on aio-libs/aiohttp#7675 about some shutdown-timeout bug that seems to be holding back a stable release.)

SnoopJ commented 11 months ago

It does look like aiohttp is going to be in pre-release for a while longer. @Exirel mentioned on IRC that we could move the ip plugin (which gives us that dependency via geoip2) to an external package, which would soften how blocked we are viz. this PR. See #2523 for that changeset.

SnoopJ commented 11 months ago

The story upstream in aiohttp seems to be getting more complicated, so I think our best way forward is to get #2523 merged. Users who want 3.12 and the sopel-iplookup plugin will need to use --pre for the time being when installing the plugin, but everything else here is ready once that PR is merged.

dgw commented 11 months ago

In the interest of helping this along, I chose #2523 as one of today's merges. Based on local testing yesterday, installing and running on Python 3.12 appeared to be fine with that branch merged into this one. We're left with a bunch of deprecation warnings emitted in pytest itself—about 46,700 of them—that were resolved for me by upgrading pytest from 7.1.3 to 7.4.3.

While I didn't test the pytest upgrade against everything Python \<3.12, a cursory check showed that pytest 7.4.3 is installable all the way back to Python 3.8, and the test suite passed on py3.8.* Passing on 3.8 and 3.12 presumably means all the intermediate Python versions will work, too; we can probably just raise the requirement from pytest~=7.1.0 🡒 pytest~=7.4.0 and be fine.

* — Passed with my manually-upgraded urllib3 2.0.7. As mentioned in IRC chatter yesterday, I have a solution in mind for working around that problem as part of #2519. That'll get pushed once I steel myself for a potential unexpected ❌ from CI. 😅

Exirel commented 11 months ago

Nothing more to say than "yes, good!" to your last comment @dgw:

SnoopJ commented 11 months ago

With closure of #2523, this PR is now as final as I forsee it being. The only outstanding issue is checking on plugins external to core, but I think even if there are issues there, those will be issues with those plugins and won't affect the contents of this PR.

ghost commented 11 months ago

Can confirm Sopel installs (pip install -e .) and runs with this PR on py3.12.0. 😎

dgw commented 11 months ago

It's official, y'all: image