Setup: add universal wheel; update metadata; clean up setup.py

* Follow current setup.py recommendations from the pypa sample project
  (utf-8 encoding on file reads, ensure files are read relative to
  own location)
* Add/update some missing classifiers and other metadata
* Read _version.py constants into an isolated dict (rather than
  the global setup.py context)
* Add setup.cfg specifying universal bdist_wheel
This commit is contained in:
medmunds
2018-03-01 13:14:05 -08:00
parent 06c7077e37
commit deea8c5d5b
4 changed files with 37 additions and 12 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
*.pyc *.pyc
*.egg *.egg
*.egg-info *.egg-info
build/
dist/ dist/
docs/_build/ docs/_build/
local.py local.py

View File

@@ -1,3 +1,3 @@
VERSION = (1, 4) VERSION = (2, 0, 0, 'dev5')
__version__ = '.'.join([str(x) for x in VERSION]) # major.minor.patch or major.minor.devN __version__ = '.'.join([str(x) for x in VERSION]) # major.minor.patch or major.minor.devN
__minor_version__ = '.'.join([str(x) for x in VERSION[:2]]) # Sphinx's X.Y "version" __minor_version__ = '.'.join([str(x) for x in VERSION[:2]]) # Sphinx's X.Y "version"

5
setup.cfg Normal file
View File

@@ -0,0 +1,5 @@
[metadata]
license_file = LICENSE
[bdist_wheel]
universal=1

View File

@@ -1,37 +1,42 @@
from setuptools import setup
import re import re
from codecs import open # to use a consistent encoding
from collections import OrderedDict
from os import path
from setuptools import setup
# define __version__ and __minor_version__ from anymail/_version.py, here = path.abspath(path.dirname(__file__))
# get versions from anymail/_version.py,
# but without importing from anymail (which would break setup) # but without importing from anymail (which would break setup)
__version__ = "UNSET" with open(path.join(here, "anymail/_version.py"), encoding='utf-8') as f:
__minor_version__ = "UNSET"
with open("anymail/_version.py") as f:
code = compile(f.read(), "anymail/_version.py", 'exec') code = compile(f.read(), "anymail/_version.py", 'exec')
exec(code) _version = {}
exec(code, _version)
version = _version["__version__"] # X.Y or X.Y.Z or X.Y.Z.dev1 etc.
release_tag = "v%s" % version # vX.Y or vX.Y.Z
def long_description_from_readme(rst): def long_description_from_readme(rst):
# Freeze external links (on PyPI) to refer to this X.Y or X.Y.Z tag. # Freeze external links (on PyPI) to refer to this X.Y or X.Y.Z tag.
# (This relies on tagging releases with 'vX.Y' or 'vX.Y.Z' in GitHub.) # (This relies on tagging releases with 'vX.Y' or 'vX.Y.Z' in GitHub.)
release = 'v%s' % __version__ # vX.Y or vX.Y.Z
rst = re.sub(r'(?<=branch=)master' # Travis build status: branch=master --> branch=vX.Y.Z rst = re.sub(r'(?<=branch=)master' # Travis build status: branch=master --> branch=vX.Y.Z
r'|(?<=/)stable' # ReadTheDocs links: /stable --> /vX.Y.Z r'|(?<=/)stable' # ReadTheDocs links: /stable --> /vX.Y.Z
r'|(?<=version=)stable', # ReadTheDocs badge: version=stable --> version=vX.Y.Z r'|(?<=version=)stable', # ReadTheDocs badge: version=stable --> version=vX.Y.Z
release, rst) # (?<=...) is "positive lookbehind": must be there, but won't get replaced release_tag, rst) # (?<=...) is "positive lookbehind": must be there, but won't get replaced
return rst return rst
with open('README.rst') as f: with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = long_description_from_readme(f.read()) long_description = long_description_from_readme(f.read())
setup( setup(
name="django-anymail", name="django-anymail",
version=__version__, version=version,
description='Django email backends for Mailgun, Mailjet, Postmark, SendGrid, SparkPost ' description='Django email backends for Mailgun, Mailjet, Postmark, SendGrid, SparkPost '
'and other transactional ESPs', 'and other transactional ESPs',
keywords="django, email, email backend, ESP, transactional mail, mailgun, mailjet, mandrill, postmark, sendgrid", keywords="django, email, email backend, ESP, transactional mail, mailgun, mailjet, mandrill, postmark, sendgrid",
author="Mike Edmunds <medmunds@gmail.com>", author="Mike Edmunds and Anymail contributors",
author_email="medmunds@gmail.com", author_email="medmunds@gmail.com",
url="https://github.com/anymail/django-anymail", url="https://github.com/anymail/django-anymail",
license="BSD License", license="BSD License",
@@ -57,15 +62,29 @@ setup(
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7", "Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.6",
"License :: OSI Approved :: BSD License", "License :: OSI Approved :: BSD License",
"Topic :: Communications :: Email",
"Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries :: Python Modules",
"Intended Audience :: Developers",
"Framework :: Django", "Framework :: Django",
"Framework :: Django :: 1.8",
"Framework :: Django :: 1.9",
"Framework :: Django :: 1.10",
"Framework :: Django :: 1.11",
"Framework :: Django :: 2.0",
"Environment :: Web Environment", "Environment :: Web Environment",
], ],
long_description=long_description, long_description=long_description,
project_urls=OrderedDict([
("Documentation", "https://anymail.readthedocs.io/en/%s/" % release_tag),
("Source", "https://github.com/anymail/django-anymail"),
("Changelog", "https://github.com/anymail/django-anymail/releases"),
("Tracker", "https://github.com/anymail/django-anymail/issues"),
]),
) )