From 6edea1fcb9ec72019fcc8125f0474bb2427c5634 Mon Sep 17 00:00:00 2001 From: Carlo Bertini Date: Mon, 11 Dec 2023 17:45:53 +0100 Subject: [PATCH 1/2] chore: use poetry --- pyproject.toml | 34 ++++++++++++++++++++++++++ setup.cfg | 6 ----- setup.py | 65 -------------------------------------------------- 3 files changed, 34 insertions(+), 71 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..55878cb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,34 @@ +[tool.poetry] +name = "celery-pubsub" +version = "2.0.0-beta3" +description = "A Publish and Subscribe library for Celery" +license = "MIT" +authors = ["Samuel GIFFARD "] +readme = "README.md" +homepage = "https://github.com/Mulugruntz/celery-pubsub" +repository = "https://github.com/Mulugruntz/celery-pubsub" +keywords = ["celery", "publish", "subscribe", "pubsub"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Software Development :: Libraries", + "Topic :: System :: Distributed Computing", + "Topic :: Utilities", + ] + +[tool.poetry.dependencies] +python = ">=3.7" +celery = ">=4.0.0" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 993a186..0000000 --- a/setup.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[metadata] -description-file = README.md - -[files] -extra_files = - LICENSE \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index bec910c..0000000 --- a/setup.py +++ /dev/null @@ -1,65 +0,0 @@ -import codecs -import os -import setuptools.command.test - - -def long_description(): - try: - return codecs.open("README.md", "r", "utf-8").read() - except IOError: - return "Long description error: Missing README.md file" - - -def _strip_comments(line): - return line.split("#", 1)[0].strip() - - -def parse_req_file(filename): - full_path = os.path.join(os.getcwd(), filename) - return [ - _strip_comments(req) - for req in codecs.open(full_path, "r", "utf-8").readlines() - if req - ] - - -def install_requires(): - return parse_req_file("requirements.txt") - - -def tests_require(): - return parse_req_file("requirements_test.txt") - - -setuptools.setup( - name="celery-pubsub", - packages=["celery_pubsub"], - version="2.0.0-beta3", - description="A Publish and Subscribe library for Celery", - long_description=long_description(), - long_description_content_type="text/markdown", - author="Samuel GIFFARD", - author_email="mulugruntz@gmail.com", - license="MIT", - url="https://github.com/Mulugruntz/celery-pubsub", - download_url="https://github.com/Mulugruntz/celery-pubsub/tarball/2.0.0-beta3", - keywords=["celery", "publish", "subscribe", "pubsub"], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Topic :: Software Development :: Libraries", - "Topic :: System :: Distributed Computing", - "Topic :: Utilities", - ], - include_package_data=True, - install_requires=install_requires(), - tests_require=tests_require(), -) From 86914eae3f817d5a949ee0b73f6edbab20a09895 Mon Sep 17 00:00:00 2001 From: Samuel Giffard Date: Mon, 11 Dec 2023 19:32:19 +0100 Subject: [PATCH 2/2] ci: Migrate to Poetry Signed-off-by: Samuel Giffard --- .github/workflows/build.yml | 49 ++++++++++++++++++++++--------------- pyproject.toml | 39 ++++++++++++++++++++++++++--- tests/conftest.py | 2 +- 3 files changed, 65 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8666c0..a540027 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,53 +96,62 @@ jobs: - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} architecture: x64 - - name: Show system - run: | - python --version - uname -a - lsb_release -a + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + # Use 1.5.1 for Python 3.7, otherwise use latest. + version: ${{ matrix.python-version == '3.7' && '1.5.1' || 'latest' }} + virtualenvs-create: true + virtualenvs-in-project: true + + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.celery }}-${{ hashFiles('**/poetry.lock') }} - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements_test.txt - pip install "celery${{ matrix.celery }}" - pip install pytest-github-actions-annotate-failures + poetry add "celery${{ matrix.celery }}" + poetry install --no-interaction --no-root --with=ci --with=dev + + - name: Install project + run: poetry install --no-interaction - name: Check with black - run: black --check . + run: poetry run black --check . - name: Check with mypy if: ${{ !startsWith(matrix.python-version, 'pypy') }} - run: mypy + run: poetry run mypy - name: Lint with flake8 run: | - pip install flake8 # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude .github + poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude .github --exclude .venv # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude .github + poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude .github --exclude .venv - name: Test with pytest run: | - coverage run -m pytest -v -s tests - coverage report + poetry run coverage run -m pytest -v -s tests + poetry run coverage report - name: Code Climate Coverage Action - uses: paambaati/codeclimate-action@v3.2.0 + uses: paambaati/codeclimate-action@v5.0.0 env: # According to CodeClimate documentation, this is not considered a sensitive value. # https://docs.codeclimate.com/docs/finding-your-test-coverage-token#regenerating-a-repos-test-reporter-id CC_TEST_REPORTER_ID: 4967416d540739937e0eebfb13a3cf2f8dfbddd762f2b1ec800e83d18fb5efbb with: - coverageCommand: coverage xml + coverageCommand: poetry run coverage xml debug: true - name: Prepare badges diff --git a/pyproject.toml b/pyproject.toml index 55878cb..a96c704 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,9 @@ [tool.poetry] name = "celery-pubsub" -version = "2.0.0-beta3" +version = "2.0.0-beta4" description = "A Publish and Subscribe library for Celery" +authors = ["Samuel Giffard "] license = "MIT" -authors = ["Samuel GIFFARD "] readme = "README.md" homepage = "https://github.com/Mulugruntz/celery-pubsub" repository = "https://github.com/Mulugruntz/celery-pubsub" @@ -17,17 +17,48 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries", "Topic :: System :: Distributed Computing", "Topic :: Utilities", ] +packages = [ + {include = "celery_pubsub"}, +] +include = [ + { path = "LICENSE", format = "sdist" }, +] + +[tool.poetry.urls] +"Download" = "https://github.com/Mulugruntz/celery-pubsub/tarball/2.0.0-beta4" [tool.poetry.dependencies] -python = ">=3.7" -celery = ">=4.0.0" +python = ">=3.7,<3.13" +celery = {version = ">=4.0,<6.0"} +# In python 3.12, we have to use kombu 5.3.5 or higher. +# This is not ideal, as it's celery's own dependency. +# https://github.com/celery/kombu/pull/1509 +kombu = [ + {version = ">=4.0,<6.0", python = ">=3.7,<3.12"}, + {version = "^5.3.0", python = ">=3.12"} +] + +[tool.poetry.group.dev.dependencies] +pytest = "^7.4.3" +coverage = "5.5" +black = "23.3.0" +flake8 = ">=5.0.0" +typing-extensions = "4.7.1" +# Only for CPython (exclude pypy). +celery-types = {version = "0.14.0", markers = "implementation_name != 'pypy'"} +mypy = {version = "1.0.0", markers = "implementation_name != 'pypy'"} +types-setuptools = {version = "67.6.0.6", markers = "implementation_name != 'pypy'"} + +[tool.poetry.group.ci.dependencies] +pytest-github-actions-annotate-failures = "^0.2.0" [build-system] requires = ["poetry-core"] diff --git a/tests/conftest.py b/tests/conftest.py index 1bdec6a..93f3b35 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,7 +19,7 @@ import pytest import celery -from celery import Task +from celery.app.task import Task from celery_pubsub import subscribe, subscribe_to from packaging.version import parse, Version