From 2bfd9498d9e442239358c9d82ff35f9d3bc1169e Mon Sep 17 00:00:00 2001 From: Mathieu Dupuy Date: Thu, 28 Sep 2023 16:26:49 +0200 Subject: [PATCH 1/3] migrate setup.py to setup.cfg --- setup.cfg | 44 ++++++++++++++++++++++++++++++++++++ setup.py | 67 ++----------------------------------------------------- 2 files changed, 46 insertions(+), 65 deletions(-) diff --git a/setup.cfg b/setup.cfg index c86d8633..f371b0af 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,47 @@ +[metadata] +name = django-prometheus +version = attr: django_prometheus.__version__ +author = Uriel Corfa +author_email = uriel@corfa.fr +license = Apache +description = Django middlewares to monitor your application with Prometheus.io. +keywords = django, monitoring, prometheus +url = http://github.com/korfuri/django-prometheus +long_description = file: README.md +long_description_content_type = text/markdown +classifiers = + Development Status :: 5 - Production/Stable + Intended Audience :: Developers + Intended Audience :: Information Technology + Intended Audience :: System Administrators + Programming Language :: Python :: 3 + 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 + Framework :: Django :: 3.2 + Framework :: Django :: 4.0 + Framework :: Django :: 4.1 + Framework :: Django :: 4.2 + Topic :: System :: Monitoring + License :: OSI Approved :: Apache Software License +project_urls = + Changelog = https://github.com/korfuri/django-prometheus/blob/master/CHANGELOG.md + Documentation = https://github.com/korfuri/django-prometheus/blob/master/README.md + Source = https://github.com/korfuri/django-prometheus + Tracker = https://github.com/korfuri/django-prometheus/issues + +[options] +packages = find: +setup_requires = pytest-runner +install_requires = prometheus-client>=0.7 +test_suite = django_prometheus.tests +tests_require = pytest; pytest-django + +[options.packages.find] +exclude = tests + [aliases] test=pytest diff --git a/setup.py b/setup.py index 471439d9..60684932 100644 --- a/setup.py +++ b/setup.py @@ -1,66 +1,3 @@ -import re +from setuptools import setup -from setuptools import find_packages, setup - -with open("README.md") as fl: - LONG_DESCRIPTION = fl.read() - - -def get_version(): - version_file = open("django_prometheus/__init__.py", "r").read() - version_match = re.search( - r'^__version__ = [\'"]([^\'"]*)[\'"]', version_file, re.MULTILINE - ) - if version_match: - return version_match.group(1) - raise RuntimeError("Unable to find version string.") - - -setup( - name="django-prometheus", - version=get_version(), - author="Uriel Corfa", - author_email="uriel@corfa.fr", - description=("Django middlewares to monitor your application with Prometheus.io."), - license="Apache", - keywords="django monitoring prometheus", - url="http://github.com/korfuri/django-prometheus", - project_urls={ - "Changelog": "https://github.com/korfuri/django-prometheus/blob/master/CHANGELOG.md", - "Documentation": "https://github.com/korfuri/django-prometheus/blob/master/README.md", - "Source": "https://github.com/korfuri/django-prometheus", - "Tracker": "https://github.com/korfuri/django-prometheus/issues", - }, - packages=find_packages( - exclude=[ - "tests", - ] - ), - test_suite="django_prometheus.tests", - long_description=LONG_DESCRIPTION, - long_description_content_type="text/markdown", - tests_require=["pytest", "pytest-django"], - setup_requires=["pytest-runner"], - options={"bdist_wheel": {"universal": "1"}}, - install_requires=[ - "prometheus-client>=0.7", - ], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Intended Audience :: Information Technology", - "Intended Audience :: System Administrators", - "Programming Language :: Python :: 3", - "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", - "Framework :: Django :: 3.2", - "Framework :: Django :: 4.0", - "Framework :: Django :: 4.1", - "Framework :: Django :: 4.2", - "Topic :: System :: Monitoring", - "License :: OSI Approved :: Apache Software License", - ], -) +setup() From 1ef5791ab8af990ef43e65f57d0011a8a75dffe3 Mon Sep 17 00:00:00 2001 From: Mathieu Dupuy Date: Thu, 28 Sep 2023 17:24:23 +0200 Subject: [PATCH 2/3] migrate setup.cfg to pyproject.toml --- CONTRIBUTING.md | 7 +++---- README.md | 2 +- pyproject.toml | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 47 ------------------------------------------ setup.py | 3 --- 5 files changed, 59 insertions(+), 55 deletions(-) delete mode 100644 setup.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 484f8ee1..0fbe3d3f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,15 +28,14 @@ Please write unit tests for your change. There are two kinds of tests: ### Running all tests ```shell -python setup.py test -cd tests/end2end/ && PYTHONPATH=../.. ./manage.py test +tox ``` The former runs the regular unit tests, the latter runs the Django unit test. -To avoid setting PYTHONPATH every time, you can also run `python -setup.py install`. +To avoid setting PYTHONPATH every time, you can also run `pip install +-e .` ### Running the test Django app diff --git a/README.md b/README.md index 0f2cf659..fc26c6bb 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ pip install django-prometheus Or, if you're using a development version cloned from this repository: ```shell -python path-to-where-you-cloned-django-prometheus/setup.py install +pip install -e path-to-where-you-cloned-django-prometheus/setup.py ``` This will install [prometheus_client](https://github.com/prometheus/client_python) as a dependency. diff --git a/pyproject.toml b/pyproject.toml index d59b21fc..c56ee26d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,58 @@ +[project] +name = "django-prometheus" +authors = [{name = "Uriel Corfa", email = "uriel@corfa.fr"}] +license = {text = "Apache"} +description = "Django middlewares to monitor your application with Prometheus.io." +keywords = ["django", "monitoring", "prometheus"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "Intended Audience :: System Administrators", + "Programming Language :: Python :: 3", + "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", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.0", + "Framework :: Django :: 4.1", + "Framework :: Django :: 4.2", + "Topic :: System :: Monitoring", + "License :: OSI Approved :: Apache Software License", +] +dependencies = ["prometheus-client>=0.7"] +dynamic = ["version"] + +[project.readme] +file = "README.md" +content-type = "text/markdown" + +[project.urls] +Homepage = "https://github.com/korfuri/django-prometheus" +Changelog = "https://github.com/korfuri/django-prometheus/blob/master/CHANGELOG.md" +Documentation = "https://github.com/korfuri/django-prometheus/blob/master/README.md" +Source = "https://github.com/korfuri/django-prometheus" +Tracker = "https://github.com/korfuri/django-prometheus/issues" + +[project.optional-dependencies] +testing = ["pytest", "pytest-django"] + +[tool.setuptools] +test-suite = "django_prometheus.tests" +include-package-data = false + +[tool.setuptools.packages.find] +exclude = ["tests"] +namespaces = false + +[tool.setuptools.dynamic] +version = {attr = "django_prometheus.__version__"} + +[tool.aliases] +test = "pytest" + [build-system] requires = [ "setuptools >= 67.7.2", "wheel >= 0.40.0"] build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index f371b0af..95016d0c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,50 +1,3 @@ -[metadata] -name = django-prometheus -version = attr: django_prometheus.__version__ -author = Uriel Corfa -author_email = uriel@corfa.fr -license = Apache -description = Django middlewares to monitor your application with Prometheus.io. -keywords = django, monitoring, prometheus -url = http://github.com/korfuri/django-prometheus -long_description = file: README.md -long_description_content_type = text/markdown -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Intended Audience :: Information Technology - Intended Audience :: System Administrators - Programming Language :: Python :: 3 - 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 - Framework :: Django :: 3.2 - Framework :: Django :: 4.0 - Framework :: Django :: 4.1 - Framework :: Django :: 4.2 - Topic :: System :: Monitoring - License :: OSI Approved :: Apache Software License -project_urls = - Changelog = https://github.com/korfuri/django-prometheus/blob/master/CHANGELOG.md - Documentation = https://github.com/korfuri/django-prometheus/blob/master/README.md - Source = https://github.com/korfuri/django-prometheus - Tracker = https://github.com/korfuri/django-prometheus/issues - -[options] -packages = find: -setup_requires = pytest-runner -install_requires = prometheus-client>=0.7 -test_suite = django_prometheus.tests -tests_require = pytest; pytest-django - -[options.packages.find] -exclude = tests - -[aliases] -test=pytest - [pycodestyle] max-line-length = 110 diff --git a/setup.py b/setup.py deleted file mode 100644 index 60684932..00000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() From fbc8ae2e400fa29d7ea4df920229cb64def1275d Mon Sep 17 00:00:00 2001 From: Mathieu Dupuy Date: Thu, 28 Sep 2023 17:27:44 +0200 Subject: [PATCH 3/3] remove deprecated setuptools keys --- pyproject.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c56ee26d..d81c7d8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,6 @@ Tracker = "https://github.com/korfuri/django-prometheus/issues" testing = ["pytest", "pytest-django"] [tool.setuptools] -test-suite = "django_prometheus.tests" include-package-data = false [tool.setuptools.packages.find] @@ -50,9 +49,6 @@ namespaces = false [tool.setuptools.dynamic] version = {attr = "django_prometheus.__version__"} -[tool.aliases] -test = "pytest" - [build-system] requires = [ "setuptools >= 67.7.2", "wheel >= 0.40.0"] build-backend = "setuptools.build_meta"