From f3e5e7ffa364b8fb74f4f4da47629f27eb57a9fb Mon Sep 17 00:00:00 2001 From: Alexandr Artemyev Date: Mon, 1 Jul 2024 19:10:45 +0500 Subject: [PATCH] migate from setup.py to pyproject.toml --- .github/workflows/test.yml | 2 +- constance/__init__.py | 2 -- docs/conf.py | 23 ++++++++----- pyproject.toml | 55 ++++++++++++++++++++++++++++++ setup.py | 68 -------------------------------------- tox.ini | 8 ++--- 6 files changed, 74 insertions(+), 84 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4d219290..2c1a3858 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install --upgrade 'tox<4' tox-gh-actions + python -m pip install --upgrade tox tox-gh-actions - name: Tox tests run: | diff --git a/constance/__init__.py b/constance/__init__.py index 16bbb750..1db3d096 100644 --- a/constance/__init__.py +++ b/constance/__init__.py @@ -1,7 +1,5 @@ from django.utils.functional import LazyObject -__version__ = '3.1.0' - class LazyConfig(LazyObject): def _setup(self): diff --git a/docs/conf.py b/docs/conf.py index 4ada1bca..ebdfb3d1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,10 +3,20 @@ # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html +import re import sys import os from datetime import datetime + +def get_version(): + with open('../pyproject.toml') as f: + for line in f: + match = re.match(r'version = "(.*)"', line) + if match: + return match.group(1) + return '0.0.0' + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings') # If extensions (or modules to document with autodoc) are in another directory, @@ -22,15 +32,10 @@ project_copyright = datetime.now().year.__str__() + ', Jazzband' # author = '' -# Use current version. -try: - from constance import __version__ - # The short X.Y version. - version = '.'.join(__version__.split('.')[:2]) - # The full version, including alpha/beta/rc tags. - release = __version__ -except ImportError: - version = release = 'dev' +# The full version, including alpha/beta/rc tags +release = get_version() +# The short X.Y version +version = ".".join(release.split(".")[:3]) # -- General configuration ------------------------------------------------ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..5db21bc8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "django-constance" +version = "3.1.0" +description = "Django live settings with pluggable backends, including Redis." +readme = "README.rst" +license = { text = "BSD" } +requires-python = ">=3.8" +authors = [ + { name = "Jannis Leidel", email = "jannis@leidel.info" }, +] +keywords = ["django", "libraries", "redis", "settings"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Framework :: Django", + "Framework :: Django :: 4.2", + "Framework :: Django :: 5.0", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "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", + "Topic :: Utilities", +] +dependencies = [ + "django-picklefield", +] + +[project.optional-dependencies] +redis = [ + "redis", +] + +[project.entry-points.pytest11] +pytest-django-constance = "constance.test.pytest" + +[project.urls] +homepage = "https://github.com/jazzband/django-constance/" +documentation = "https://django-constance.readthedocs.io/en/latest/" +repository = "https://github.com/jazzband/django-constance/" +changelog = "https://github.com/jazzband/django-constance/releases/" + +[tool.setuptools.packages.find] +include = ["constance*"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 3640f0b5..00000000 --- a/setup.py +++ /dev/null @@ -1,68 +0,0 @@ -import os -import re -import codecs -from setuptools import setup, find_packages - - -def read(*parts): - filename = os.path.join(os.path.dirname(__file__), *parts) - with codecs.open(filename, encoding='utf-8') as fp: - return fp.read() - - -def find_version(*file_paths): - version_file = read(*file_paths) - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", - version_file, re.M) - if version_match: - return version_match.group(1) - raise RuntimeError('Unable to find version string.') - - -setup( - name='django-constance', - version=find_version('constance', '__init__.py'), - url='https://github.com/jazzband/django-constance', - description='Django live settings with pluggable backends, including Redis.', - long_description=read('README.rst'), - author='Jannis Leidel', - author_email='jannis@leidel.info', - license='BSD', - keywords='django libraries settings redis'.split(), - platforms=['any'], - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Web Environment', - 'Framework :: Django', - 'Framework :: Django :: 4.2', - 'Framework :: Django :: 5.0', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: Implementation :: CPython', - 'Topic :: Utilities', - ], - packages=find_packages(exclude=['tests', 'tests.*']), - include_package_data=True, - zip_safe=False, - python_requires='>=3.8', - install_requires=[ - 'django-picklefield', - ], - extras_require={ - 'redis': ['redis'], - }, - entry_points={ - 'pytest11': [ - 'pytest-django-constance = constance.test.pytest', - ], - }, -) diff --git a/tox.ini b/tox.ini index 838e5a72..fa2319a2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,10 @@ [tox] -requires = - tox<4 +isolated_build = true envlist = py{38,39,310,311,312}-dj{42}-{unittest,pytest} py{310,311,312}-dj{50}-{unittest,pytest} py{310,311,312}-dj{main}-{unittest,pytest} +skip_missing_interpreters = True [testenv] deps = @@ -27,8 +27,8 @@ commands = unittest: coverage xml pytest: pytest --cov=. --ignore=.tox --disable-pytest-warnings --cov-report=xml --cov-append {toxinidir} setenv = - PYTHONDONTWRITEBYTECODE=1 - DJANGO_SETTINGS_MODULE=tests.settings + PYTHONPATH = {toxinidir} + DJANGO_SETTINGS_MODULE = tests.settings [gh-actions] python =