Skip to content

Commit 0b7a787

Browse files
authored
Convert setup.py metadata to setup.cfg (#580)
Use [setup-py-upgrade](https://pypi.org/project/setup-py-upgrade/) plus some manual editing to move to the declarative metadata format.
1 parent 0ed1d30 commit 0b7a787

File tree

4 files changed

+58
-70
lines changed

4 files changed

+58
-70
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Pending
88

99
.. Insert new release notes below this line
1010
11+
* Converted setuptools metadata to configuration file. This meant removing the
12+
``__version__`` attribute from the package. If you want to inspect the
13+
installed version, use
14+
``pkg_resources.get_distribution("django-mysql").version``
15+
(`docs <https://setuptools.readthedocs.io/en/latest/pkg_resources.html#getting-or-creating-distributions>`__).
16+
1117
3.2.0 (2019-06-14)
1218
------------------
1319

django_mysql/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
__author__ = "Adam Johnson"
2-
__email__ = "[email protected]"
3-
__version__ = "3.2.0"
4-
5-
61
default_app_config = "django_mysql.apps.MySQLConfig"

setup.cfg

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
[metadata]
2+
name = django-mysql
3+
version = 3.2.0
4+
description = Extensions to Django for use with MySQL/MariaDB
5+
long_description = file: README.rst, HISTORY.rst
6+
long_description_content_type = text/x-rst
7+
author = Adam Johnson
8+
author_email = [email protected]
9+
url = https://github.com/adamchainz/django-mysql
10+
project_urls =
11+
Changelog = https://github.com/adamchainz/django-mysql/blob/master/HISTORY.rst
12+
license = BSD
13+
keywords =
14+
Django
15+
MySQL
16+
MariaDB
17+
classifiers =
18+
Development Status :: 5 - Production/Stable
19+
Framework :: Django
20+
Framework :: Django :: 1.11
21+
Framework :: Django :: 2.0
22+
Framework :: Django :: 2.1
23+
Framework :: Django :: 2.2
24+
Intended Audience :: Developers
25+
License :: OSI Approved :: BSD License
26+
Natural Language :: English
27+
Operating System :: OS Independent
28+
Programming Language :: Python :: 3 :: Only
29+
Programming Language :: Python :: 3
30+
Programming Language :: Python :: 3.5
31+
Programming Language :: Python :: 3.6
32+
Programming Language :: Python :: 3.7
33+
Topic :: Database
34+
license_file = LICENSE
35+
36+
[options]
37+
packages = find:
38+
include_package_data = True
39+
install_requires = Django>=1.11
40+
python_requires = >=3.5
41+
zip_safe = False
42+
43+
[options.packages.find]
44+
exclude =
45+
tests
46+
tests.*
47+
148
[flake8]
249
max-line-length = 80
350
select = C,E,F,W,B,B950
@@ -12,11 +59,8 @@ line_length = 88
1259
multi_line_output = 3
1360
use_parentheses = True
1461

15-
[metadata]
16-
license_file = LICENSE
17-
1862
[tool:multilint]
1963
paths = django_mysql
20-
runtests.py
21-
setup.py
22-
tests
64+
runtests.py
65+
setup.py
66+
tests

setup.py

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,3 @@
1-
import os
2-
import re
1+
from setuptools import setup
32

4-
from setuptools import find_packages, setup
5-
6-
7-
def get_version(filename):
8-
with open(filename, "r") as fp:
9-
contents = fp.read()
10-
return re.search(r"__version__ = ['\"]([^'\"]+)['\"]", contents).group(1)
11-
12-
13-
version = get_version(os.path.join("django_mysql", "__init__.py"))
14-
15-
16-
with open("README.rst", "r") as readme_file:
17-
readme = readme_file.read()
18-
19-
with open("HISTORY.rst", "r") as history_file:
20-
history = history_file.read().replace(".. :changelog:", "")
21-
22-
setup(
23-
name="django-mysql",
24-
version=version,
25-
description="Extensions to Django for use with MySQL/MariaDB",
26-
long_description=readme + "\n\n" + history,
27-
author="Adam Johnson",
28-
author_email="[email protected]",
29-
url="https://github.com/adamchainz/django-mysql",
30-
project_urls={
31-
"Changelog": (
32-
"https://github.com/adamchainz/django-mysql/blob/master/HISTORY.rst"
33-
)
34-
},
35-
packages=find_packages(exclude=["tests", "tests.*"]),
36-
include_package_data=True,
37-
install_requires=["Django>=1.11"],
38-
python_requires=">=3.5",
39-
license="BSD",
40-
zip_safe=False,
41-
keywords=["Django", "MySQL", "MariaDB"],
42-
classifiers=[
43-
"Development Status :: 5 - Production/Stable",
44-
"Framework :: Django",
45-
"Framework :: Django :: 1.11",
46-
"Framework :: Django :: 2.0",
47-
"Framework :: Django :: 2.1",
48-
"Framework :: Django :: 2.2",
49-
"Intended Audience :: Developers",
50-
"License :: OSI Approved :: BSD License",
51-
"Natural Language :: English",
52-
"Operating System :: OS Independent",
53-
"Programming Language :: Python :: 3 :: Only",
54-
"Programming Language :: Python :: 3",
55-
"Programming Language :: Python :: 3.5",
56-
"Programming Language :: Python :: 3.6",
57-
"Programming Language :: Python :: 3.7",
58-
"Topic :: Database",
59-
],
60-
)
3+
setup()

0 commit comments

Comments
 (0)