Skip to content

Commit

Permalink
Add support for CPython 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Mulugruntz committed Dec 3, 2023
1 parent c916564 commit b9662f1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
architecture: x64
- id: set-matrix
env:
PY_VERSIONS: "[\"3.7\", \"3.8\", \"3.9\", \"3.10\", \"3.11\", \"pypy-3.8-v7.3.11\", \"pypy-3.9-v7.3.11\"]"
PY_VERSIONS: "[\"3.7\", \"3.8\", \"3.9\", \"3.10\", \"3.11\", \"3.12\", \"pypy-3.8\", \"pypy-3.9\"]"
OS_NAMES: "[\"ubuntu-20.04\"]" #, windows-latest, macOS-latest]
CELERY_VERSIONS: "[\">=4.0.0,<5.0.0\", \">=5.0.0,<6.0.0\"]"
run: |
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/resolve_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ def process_matrix(args: Namespace) -> None:
# This is because inspect.getfullargspec has been removed in Python 3.11
# and `vine.five` 4.x was depending on it. This is fixed in 5.x.
n == "celery"
and c.replace(".", "").startswith("311")
and (
c.replace(".", "").startswith("311")
or c.replace(".", "").startswith("312")
)
and all(cv.startswith("4") for cv in compatible_versions)
):
if is_inverted:
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Publish and Subscribe with Celery
| 3.9 | ![][badge-m_linux_3.9_celery3] ![][badge-t_linux_3.9_celery3] | ![][badge-m_linux_3.9_celery4] ![][badge-t_linux_3.9_celery4] | ![][badge-m_linux_3.9_celery5] ![][badge-t_linux_3.9_celery5] |
| 3.10 | ![][badge-m_linux_3.10_celery3] ![][badge-t_linux_3.10_celery3] | ![][badge-m_linux_3.10_celery4] ![][badge-t_linux_3.10_celery4] | ![][badge-m_linux_3.10_celery5] ![][badge-t_linux_3.10_celery5] |
| 3.11 | ![][badge-m_linux_3.11_celery3] ![][badge-t_linux_3.11_celery3] | ![][badge-m_linux_3.11_celery4] ![][badge-t_linux_3.11_celery4] | ![][badge-m_linux_3.11_celery5] ![][badge-t_linux_3.11_celery5] |
| 3.12 | ![][badge-m_linux_3.12_celery3] ![][badge-t_linux_3.12_celery3] | ![][badge-m_linux_3.12_celery4] ![][badge-t_linux_3.12_celery4] | ![][badge-m_linux_3.12_celery5] ![][badge-t_linux_3.12_celery5] |
| pypy 3.8 | ![][badge-m_linux_pypy3.8_celery3] ![][badge-t_linux_pypy3.8_celery3] | ![][badge-m_linux_pypy3.8_celery4] ![][badge-t_linux_pypy3.8_celery4] | ![][badge-m_linux_pypy3.8_celery5] ![][badge-t_linux_pypy3.8_celery5] |
| pypy 3.9 | ![][badge-m_linux_pypy3.9_celery3] ![][badge-t_linux_pypy3.9_celery3] | ![][badge-m_linux_pypy3.9_celery4] ![][badge-t_linux_pypy3.9_celery4] | ![][badge-m_linux_pypy3.9_celery5] ![][badge-t_linux_pypy3.9_celery5] |

Expand Down Expand Up @@ -105,7 +106,7 @@ celery_pubsub.publish('some.very.good.test', 42) # task 3 only
* Drop support for Pypy 2.7 and 3.6.
* Drop support for Celery 3.
* Add support for Pypy 3.8 and 3.9.
* Add support for CPython 3.11.
* Add support for CPython 3.11 and 3.12.
* Type hints are now directly in the code. No more stubs files.
* 1.0.2
* Add stubs file for type hinting.
Expand Down Expand Up @@ -183,6 +184,10 @@ celery_pubsub.publish('some.very.good.test', 42) # task 3 only
[badge-m_linux_3.11_celery4]: https://byob.yarr.is/Mulugruntz/celery-pubsub/m_linux_3.11_celery4/shields
[badge-m_linux_3.11_celery5]: https://byob.yarr.is/Mulugruntz/celery-pubsub/m_linux_3.11_celery5/shields

[badge-m_linux_3.12_celery3]: https://byob.yarr.is/Mulugruntz/celery-pubsub/m_linux_3.12_celery3/shields
[badge-m_linux_3.12_celery4]: https://byob.yarr.is/Mulugruntz/celery-pubsub/m_linux_3.12_celery4/shields
[badge-m_linux_3.12_celery5]: https://byob.yarr.is/Mulugruntz/celery-pubsub/m_linux_3.12_celery5/shields

[badge-m_linux_pypy3.8_celery3]: https://byob.yarr.is/Mulugruntz/celery-pubsub/m_linux_pypy-3.8_celery3/shields
[badge-m_linux_pypy3.8_celery4]: https://byob.yarr.is/Mulugruntz/celery-pubsub/m_linux_pypy-3.8_celery4/shields
[badge-m_linux_pypy3.8_celery5]: https://byob.yarr.is/Mulugruntz/celery-pubsub/m_linux_pypy-3.8_celery5/shields
Expand Down Expand Up @@ -212,6 +217,10 @@ celery_pubsub.publish('some.very.good.test', 42) # task 3 only
[badge-t_linux_3.11_celery4]: https://byob.yarr.is/Mulugruntz/celery-pubsub/2.0.0-beta3_linux_3.11_celery4/shields
[badge-t_linux_3.11_celery5]: https://byob.yarr.is/Mulugruntz/celery-pubsub/2.0.0-beta3_linux_3.11_celery5/shields

[badge-t_linux_3.12_celery3]: https://byob.yarr.is/Mulugruntz/celery-pubsub/2.0.0-beta3_linux_3.12_celery3/shields
[badge-t_linux_3.12_celery4]: https://byob.yarr.is/Mulugruntz/celery-pubsub/2.0.0-beta3_linux_3.12_celery4/shields
[badge-t_linux_3.12_celery5]: https://byob.yarr.is/Mulugruntz/celery-pubsub/2.0.0-beta3_linux_3.12_celery5/shields

[badge-t_linux_pypy3.8_celery3]: https://byob.yarr.is/Mulugruntz/celery-pubsub/2.0.0-beta3_linux_pypy-3.8_celery3/shields
[badge-t_linux_pypy3.8_celery4]: https://byob.yarr.is/Mulugruntz/celery-pubsub/2.0.0-beta3_linux_pypy-3.8_celery4/shields
[badge-t_linux_pypy3.8_celery5]: https://byob.yarr.is/Mulugruntz/celery-pubsub/2.0.0-beta3_linux_pypy-3.8_celery5/shields
Expand Down
25 changes: 23 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,28 @@
from celery import Task

from celery_pubsub import subscribe
from pkg_resources import get_distribution, parse_version
from packaging.version import parse, Version


# TODO: Simplify this when we drop support for Python 3.7.
if typing.TYPE_CHECKING:

def get_distribution_version(distribution_name: str) -> Version:
...

else:

def get_distribution_version(distribution_name: str) -> Version:
try:
from importlib.metadata import distribution

return parse(distribution(distribution_name).version)
except ImportError:
# Fallback for Python < 3.8. Remove when we drop support for Python 3.7.
from pkg_resources import get_distribution

return parse(get_distribution(distribution_name).version)


P = ParamSpec("P")
R = TypeVar("R")
Expand All @@ -39,7 +60,7 @@ def celery_config():
"broker_transport_options": {"polling_interval": 0.05},
}

if get_distribution("celery").parsed_version >= parse_version("5.0.0"):
if get_distribution_version("celery") >= parse("5.0.0"):
pytest_plugins = ["celery.contrib.pytest"]


Expand Down

0 comments on commit b9662f1

Please sign in to comment.