Skip to content

Commit

Permalink
Replace setup.py in favor of pyproject.toml (#173)
Browse files Browse the repository at this point in the history
* Replace setup.py by pyproject.toml

* adapt tests
  • Loading branch information
andruten committed Oct 16, 2023
1 parent d0099ea commit e76a7b4
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 89 deletions.
74 changes: 74 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
build-backend = "setuptools.build_meta"

[project]
name = "django-revproxy"
authors = [
{ name = "Sergio Oliveira", email = "sergio@tracy.com.br" },
]

description = "Yet another Django reverse proxy application"
readme = "README.rst"

requires-python = ">=3.7"
keywords = ["django", "reverse proxy", "revproxy"]
license = { text = "MPL v2.0" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"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",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Internet :: Proxy Servers",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries",
]
dependencies = [
"Django>=3.0",
"urllib3>=1.12",
]
optional-dependencies.diazo = [
"diazo>=1.0.5",
"lxml>=3.4",
]
optional-dependencies.tests = [
"diazo",
"lxml>=3.4",
"coverage",
"flake8",
]

dynamic = ["version"]

[tool.setuptools.dynamic]
version = { attr = "revproxy.__version__" }

[project.urls]
homepage = "https://github.com/jazzband/django-revproxy"
download = "https://pypi.org/project/django-revproxy/"
documentation = "https://django-revproxy.readthedocs.io/en/stable/"
changelog = "https://django-revproxy.readthedocs.io/en/latest/changelog.html"
issues = "https://github.com/jazzband/django-revproxy/issues"

[tool.setuptools]
packages = ["revproxy"]

[tool.setuptools_scm]
version_scheme = "post-release"
66 changes: 1 addition & 65 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,67 +1,3 @@
import codecs
import os
import re

from setuptools import setup


def read(*parts):
return codecs.open(os.path.join(os.path.dirname(__file__), *parts),
encoding='utf8').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-revproxy',
description='Yet another Django reverse proxy application.',
version=find_version('revproxy/__init__.py'),
long_description=read('README.rst'),
packages=['revproxy'],
install_requires=[
'django>=3.0',
'urllib3>=1.12',
],
extras_require={
'diazo': ['diazo>=1.0.5', 'lxml>=3.4'],
},
tests_require=['diazo', 'lxml>=3.4'],
test_suite="tests.run.runtests",
author='Sergio Oliveira',
author_email='sergio@tracy.com.br',
url='https://github.com/jazzband/django-revproxy',
license='MPL v2.0',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
'Operating System :: OS Independent',
'Programming Language :: Python',
'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',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Internet :: Proxy Servers',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries',
],
)
setup()
7 changes: 3 additions & 4 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os
from pathlib import Path

SECRET_KEY = 'asdf'

BASE_DIR = Path(__file__).resolve().parent

DATABASES = {
'default': {
Expand Down Expand Up @@ -28,10 +31,6 @@

ROOT_URLCONF = 'tests.urls'

import os

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
Expand Down
7 changes: 3 additions & 4 deletions tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

from unittest.mock import patch

import os
from unittest.mock import patch

from django.conf import settings
from django.test import TestCase, RequestFactory
try:
from django.utils.six.moves.urllib.parse import ParseResult
Expand Down Expand Up @@ -137,7 +136,7 @@ class CustomProxyView(DiazoProxyView):

proxy_view = CustomProxyView()

correct_path = os.path.join(os.path.dirname(__file__), 'diazo.xml')
correct_path = os.path.join(settings.BASE_DIR, 'diazo.xml')
self.assertEqual(proxy_view.diazo_rules, correct_path)

def test_diazo_rules_overriden(self):
Expand Down
29 changes: 13 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[gh-actions]
python =
2.7: py27
3.6: py36
3.7: py37
3.8: py38
3.9: py39
Expand All @@ -10,7 +8,6 @@ python =

[gh-actions:env]
DJANGO =
2.2: dj22
3.0: dj30
3.1: dj31
3.2: dj32
Expand All @@ -19,13 +16,12 @@ DJANGO =
4.2: dj42

[tox]
skipsdist = True
usedevelop = True

envlist =
py{37,38,39}-dj{30}
py{36,37,38,39}-dj{31}
py{36,37,38,39,310}-dj{32}
py{37,38,39}-dj{31}
py{37,38,39,310}-dj{32}
py{38,39,310,311}-dj{40}
py{38,39,310,311}-dj{41}
py{38,39,310,311}-dj{42}
Expand All @@ -39,16 +35,17 @@ basepython =
py311: python3.11

deps =
coverage
flake8
dj30: Django>=3.0,<3.0.99
dj31: Django>=3.1,<3.1.99
dj32: Django>=3.2,<3.2.99
dj40: Django>=4.0,<4.0.99
dj41: Django>=4.1,<4.1.99
dj42: Django>=4.2,<4.2.99
dj30: Django>=3.0,<3.1
dj31: Django>=3.1,<3.2
dj32: Django>=3.2,<4.0
dj40: Django>=4.0,<4.1
dj41: Django>=4.1,<4.2
dj42: Django>=4.2,<5.0

extras =
tests

commands =
flake8 revproxy -v
coverage run --branch --source=revproxy setup.py test
flake8 revproxy
coverage run --branch --source=revproxy {envbindir}/django-admin test --pythonpath=./ --settings=tests.settings
coverage report --fail-under=90 --show-missing

0 comments on commit e76a7b4

Please sign in to comment.