From dbb16b5e62c20bad371c5e210667844086622e52 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Tue, 30 Aug 2022 13:01:38 +0100 Subject: [PATCH] switch to pyproject (#341) * switch to pyproject * fix compatibility between requirements files * add pointless setup.py, fix coverage --- .github/workflows/ci.yml | 20 ++++--- LICENSE | 2 +- MANIFEST.in | 3 - Makefile | 3 +- arq/__main__.py | 4 ++ arq/version.py | 7 +-- pyproject.toml | 58 ++++++++++++++++++ requirements/all.txt | 2 +- requirements/{setup.txt => pyproject.txt} | 12 ++-- requirements/testing.txt | 5 +- setup.py | 72 ++++++----------------- 11 files changed, 104 insertions(+), 84 deletions(-) delete mode 100644 MANIFEST.in create mode 100644 arq/__main__.py rename requirements/{setup.txt => pyproject.txt} (65%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef34da83..2ffeecbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: with: python-version: '3.10' - - run: pip install -r requirements/linting.txt -r requirements/setup.txt pre-commit + - run: pip install -r requirements/linting.txt -r requirements/pyproject.txt pre-commit - run: pre-commit run -a @@ -36,7 +36,7 @@ jobs: with: python-version: '3.10' - - run: pip install -r requirements/docs.txt -r requirements/setup.txt + - run: pip install -r requirements/docs.txt -r requirements/pyproject.txt - run: pip install . - run: make docs @@ -78,7 +78,7 @@ jobs: with: python-version: ${{ matrix.python }} - - run: pip install -r requirements/testing.txt -r requirements/setup.txt + - run: pip install -r requirements/testing.txt -r requirements/pyproject.txt - run: make test @@ -104,15 +104,16 @@ jobs: python-version: '3.10' - name: install - run: | - make install - pip install -U wheel twine + run: pip install -U twine build packaging - - name: set version - run: VERSION_PATH='arq/version.py' python <(curl -Ls https://git.io/JT3rm) + - name: check version + id: check-version + run: python <(curl -Ls https://gist.githubusercontent.com/samuelcolvin/4e1ad439c5489e8d6478cdee3eb952ef/raw/check_version.py) + env: + VERSION_PATH: 'arq/version.py' - name: build - run: python setup.py sdist bdist_wheel + run: python -m build - run: twine check dist/* @@ -123,6 +124,7 @@ jobs: TWINE_PASSWORD: ${{ secrets.pypi_token }} - name: publish docs + if: '!fromJSON(steps.check-version.outputs.IS_PRERELEASE)' run: make publish-docs env: NETLIFY: ${{ secrets.netlify_token }} diff --git a/LICENSE b/LICENSE index f4b8075b..f2229e02 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017, 2018, 2019, 2020 Samuel Colvin and other contributors +Copyright (c) 2017 - 2022 Samuel Colvin and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index ff7e67ab..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include LICENSE -include README.md -include HISTORY.rst diff --git a/Makefile b/Makefile index 319dcc0e..4aa4105d 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ black = black arq tests .PHONY: install install: - pip install -U pip setuptools pre-commit + pip install -U pip pre-commit pip install -r requirements/all.txt pip install -e .[watch] pre-commit install @@ -51,7 +51,6 @@ clean: rm -f .coverage.* rm -rf build make -C docs clean - python setup.py clean .PHONY: docs docs: diff --git a/arq/__main__.py b/arq/__main__.py new file mode 100644 index 00000000..d396c2a7 --- /dev/null +++ b/arq/__main__.py @@ -0,0 +1,4 @@ +from .cli import cli + +if __name__ == '__main__': + cli() diff --git a/arq/version.py b/arq/version.py index b47d1126..d2d370a8 100644 --- a/arq/version.py +++ b/arq/version.py @@ -1,5 +1,2 @@ -__all__ = ['VERSION'] - -# version is set automatically in CI before release, -# see https://gist.github.com/samuelcolvin/da2f521da5d2195fbfd65da3b8f58589 -VERSION = '0.0.dev0' +# Version here is used for the package version via the `[tool.hatch.version]` section of `pyproject.toml`. +VERSION = '0.24.0' diff --git a/pyproject.toml b/pyproject.toml index 45d3575d..f695d0de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,60 @@ +[build-system] +requires = ['hatchling'] +build-backend = 'hatchling.build' + +[tool.hatch.version] +path = 'arq/version.py' + +[project] +name = 'arq' +description = 'Job queues in python with asyncio and redis' +authors = [{name = 'Samuel Colvin', email = 's@muelcolvin.com'}] +license = {file = 'LICENSE'} +readme = 'README.md' +classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Framework :: AsyncIO', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: MIT License', + 'Operating System :: Unix', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3 :: Only', + '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', + 'Topic :: Internet', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: System :: Clustering', + 'Topic :: System :: Distributed Computing', + 'Topic :: System :: Monitoring', + 'Topic :: System :: Systems Administration', +] +requires-python = '>=3.7' +dependencies = [ + 'redis[hiredis]>=4.2.0', + 'click>=8.0', + 'typing-extensions>=4.1.0', +] +optional-dependencies = {watch = ['watchfiles>=0.16'] } +dynamic = ['version'] + +[project.scripts] +arq = 'arq.cli:cli' + +[project.urls] +Homepage = 'https://github.com/samuelcolvin/arq' +Documentation = 'https://arq-docs.helpmanual.io' +Funding = 'https://github.com/sponsors/samuelcolvin' +Source = 'https://github.com/samuelcolvin/arq' +Changelog = 'https://github.com/samuelcolvin/arq/releases' + [tool.pytest.ini_options] testpaths = 'tests' filterwarnings = ['error'] @@ -7,6 +64,7 @@ timeout = 10 [tool.coverage.run] source = ['arq'] branch = true +omit = ['arq/__main__.py'] [tool.coverage.report] precision = 2 diff --git a/requirements/all.txt b/requirements/all.txt index 975047ab..3e6af755 100644 --- a/requirements/all.txt +++ b/requirements/all.txt @@ -1,4 +1,4 @@ -r ./docs.txt -r ./linting.txt -r ./testing.txt --r ./setup.txt +-r ./pyproject.txt diff --git a/requirements/setup.txt b/requirements/pyproject.txt similarity index 65% rename from requirements/setup.txt rename to requirements/pyproject.txt index ff4928fb..5c605c88 100644 --- a/requirements/setup.txt +++ b/requirements/pyproject.txt @@ -2,14 +2,14 @@ # This file is autogenerated by pip-compile with python 3.9 # To update, run: # -# pip-compile --extra=watch --output-file=requirements/setup.txt setup.py +# pip-compile --extra=watch --output-file=requirements/pyproject.txt pyproject.toml # anyio==3.6.1 # via watchfiles async-timeout==4.0.2 # via redis click==8.1.3 - # via arq (setup.py) + # via arq (pyproject.toml) deprecated==1.2.13 # via redis hiredis==2.0.0 @@ -20,13 +20,13 @@ packaging==21.3 # via redis pyparsing==3.0.9 # via packaging -redis[hiredis]==4.2.2 - # via arq (setup.py) +redis[hiredis]==4.3.4 + # via arq (pyproject.toml) sniffio==1.2.0 # via anyio typing-extensions==4.3.0 - # via arq (setup.py) + # via arq (pyproject.toml) watchfiles==0.16.1 - # via arq (setup.py) + # via arq (pyproject.toml) wrapt==1.14.1 # via deprecated diff --git a/requirements/testing.txt b/requirements/testing.txt index 2dbbf647..243d054a 100644 --- a/requirements/testing.txt +++ b/requirements/testing.txt @@ -52,8 +52,9 @@ pytz==2022.2.1 # via # -r requirements/testing.in # dirty-equals -redis==4.2.2 - # via redislite +# manually removed to avoid conflict with redis version from pyproject.toml +# redis==4.2.2 +# # via redislite redislite==6.2.805324 # via -r requirements/testing.in termcolor==1.1.0 diff --git a/setup.py b/setup.py index 455974e7..94cd7b8d 100644 --- a/setup.py +++ b/setup.py @@ -1,66 +1,28 @@ -from pathlib import Path +import sys + +sys.stderr.write( + """ +=============================== +Unsupported installation method +=============================== +arq no longer supports installation with `python setup.py install`. +Please use `python -m pip install .` instead. +""" +) +sys.exit(1) -from importlib.machinery import SourceFileLoader -from setuptools import setup -description = 'Job queues in python with asyncio and redis' -readme = Path(__file__).parent / 'README.md' -if readme.exists(): - long_description = readme.read_text() -else: - long_description = description + '.\n\nSee https://arq-docs.helpmanual.io/ for documentation.' -# avoid loading the package before requirements are installed: -version = SourceFileLoader('version', 'arq/version.py').load_module() +# The below code will never execute, however GitHub is particularly +# picky about where it finds Python packaging metadata. +# See: https://github.com/github/feedback/discussions/6456 +# +# To be removed once GitHub catches up. setup( name='arq', - version=version.VERSION, - description=description, - long_description=long_description, - long_description_content_type='text/markdown', - classifiers=[ - 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Framework :: AsyncIO', - 'Intended Audience :: Developers', - 'Intended Audience :: Information Technology', - 'Intended Audience :: System Administrators', - 'License :: OSI Approved :: MIT License', - 'Operating System :: Unix', - 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3 :: Only', - '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', - 'Topic :: Internet', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: System :: Clustering', - 'Topic :: System :: Distributed Computing', - 'Topic :: System :: Monitoring', - 'Topic :: System :: Systems Administration', - ], - python_requires='>=3.7', - author='Samuel Colvin', - author_email='s@muelcolvin.com', - url='https://github.com/samuelcolvin/arq', - license='MIT', - packages=['arq'], - package_data={'arq': ['py.typed']}, - zip_safe=True, - entry_points=""" - [console_scripts] - arq=arq.cli:cli - """, install_requires=[ 'redis[hiredis]>=4.2.0', 'click>=8.0', 'typing-extensions>=4.1.0', ], - extras_require={ - 'watch': ['watchfiles>=0.16'], - } )