Skip to content

Commit 3bffdb0

Browse files
jdufresnejpadilla
authored andcommitted
Move setup information to declarative setup.cfg (#495)
Use a declarative syntax to avoid mixing code and configuration. Simplifies handling of long description and version by reducing some boilerplate. For details on this setuptools feature, see: https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files
1 parent cf430bc commit 3bffdb0

File tree

3 files changed

+53
-73
lines changed

3 files changed

+53
-73
lines changed

setup.cfg

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[metadata]
2+
name = PyJWT
3+
version = attr: jwt.__version__
4+
author = Jose Padilla
5+
author_email = [email protected]
6+
description = JSON Web Token implementation in Python
7+
license = MIT
8+
keywords =
9+
json
10+
jwt
11+
security
12+
signing
13+
token
14+
web
15+
url = https://github.com/jpadilla/pyjwt
16+
long_description = file: README.rst
17+
classifiers =
18+
Development Status :: 5 - Production/Stable
19+
Intended Audience :: Developers
20+
Natural Language :: English
21+
License :: OSI Approved :: MIT License
22+
Programming Language :: Python
23+
Programming Language :: Python :: 3
24+
Programming Language :: Python :: 3 :: Only
25+
Programming Language :: Python :: 3.5
26+
Programming Language :: Python :: 3.6
27+
Programming Language :: Python :: 3.7
28+
Programming Language :: Python :: 3.8
29+
Topic :: Utilities
30+
31+
[options]
32+
python_requires = >=3.5
33+
packages = find:
34+
35+
[options.entry_points]
36+
console_scripts =
37+
pyjwt = jwt.__main__:main
38+
39+
[options.extras_require]
40+
crypto =
41+
cryptography >= 1.4
42+
tests =
43+
pytest>=4.0.1,<5.0.0
44+
pytest-cov>=2.6.0,<3.0.0
45+
46+
[options.packages.find]
47+
exclude =
48+
tests
49+
tests.*

setup.py

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,5 @@
11
#!/usr/bin/env python3
22

3-
import os
4-
import re
5-
import sys
3+
from setuptools import setup
64

7-
from setuptools import find_packages, setup
8-
9-
10-
def get_version(package):
11-
"""
12-
Return package version as listed in `__version__` in `init.py`.
13-
"""
14-
with open(os.path.join(package, "__init__.py"), "rb") as init_py:
15-
src = init_py.read().decode("utf-8")
16-
return re.search("__version__ = ['\"]([^'\"]+)['\"]", src).group(1)
17-
18-
19-
version = get_version("jwt")
20-
21-
with open(os.path.join(os.path.dirname(__file__), "README.rst")) as readme:
22-
long_description = readme.read()
23-
24-
if sys.argv[-1] == "publish":
25-
if os.system("pip freeze | grep twine"):
26-
print("twine not installed.\nUse `pip install twine`.\nExiting.")
27-
sys.exit()
28-
os.system("python setup.py sdist bdist_wheel")
29-
os.system("twine upload dist/*")
30-
print("You probably want to also tag the version now:")
31-
print(" git tag -a {0} -m 'version {0}'".format(version))
32-
print(" git push --tags")
33-
sys.exit()
34-
35-
EXTRAS_REQUIRE = {
36-
"tests": ["pytest>=4.0.1,<5.0.0", "pytest-cov>=2.6.0,<3.0.0"],
37-
"crypto": ["cryptography >= 1.4"],
38-
}
39-
40-
EXTRAS_REQUIRE["dev"] = (
41-
EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["crypto"] + ["mypy", "pre-commit"]
42-
)
43-
44-
setup(
45-
name="PyJWT",
46-
version=version,
47-
author="Jose Padilla",
48-
author_email="[email protected]",
49-
description="JSON Web Token implementation in Python",
50-
license="MIT",
51-
keywords="jwt json web token security signing",
52-
url="https://github.com/jpadilla/pyjwt",
53-
packages=find_packages(
54-
exclude=["*.tests", "*.tests.*", "tests.*", "tests"]
55-
),
56-
long_description=long_description,
57-
classifiers=[
58-
"Development Status :: 5 - Production/Stable",
59-
"Intended Audience :: Developers",
60-
"Natural Language :: English",
61-
"License :: OSI Approved :: MIT License",
62-
"Programming Language :: Python",
63-
"Programming Language :: Python :: 3",
64-
"Programming Language :: Python :: 3 :: Only",
65-
"Programming Language :: Python :: 3.5",
66-
"Programming Language :: Python :: 3.6",
67-
"Programming Language :: Python :: 3.7",
68-
"Programming Language :: Python :: 3.8",
69-
"Topic :: Utilities",
70-
],
71-
python_requires=">=3.5",
72-
extras_require=EXTRAS_REQUIRE,
73-
entry_points={"console_scripts": ["pyjwt = jwt.__main__:main"]},
74-
)
5+
setup()

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ deps =
1717

1818

1919
[testenv:typing]
20-
extras = dev
20+
deps = mypy
2121
commands = mypy --ignore-missing-imports jwt
2222

2323

2424
[testenv:lint]
25-
extras = dev
25+
deps = pre-commit
2626
passenv = HOMEPATH # needed on Windows
2727
commands = pre-commit run --all-files

0 commit comments

Comments
 (0)