From deea8c5d5b1b65a47d49e7ef31755eeb69a9057c Mon Sep 17 00:00:00 2001 From: medmunds Date: Thu, 1 Mar 2018 13:14:05 -0800 Subject: [PATCH] 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 --- .gitignore | 1 + anymail/_version.py | 2 +- setup.cfg | 5 +++++ setup.py | 41 ++++++++++++++++++++++++++++++----------- 4 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 setup.cfg diff --git a/.gitignore b/.gitignore index 24567f9..868f63c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.pyc *.egg *.egg-info +build/ dist/ docs/_build/ local.py diff --git a/anymail/_version.py b/anymail/_version.py index 13934ee..3edff39 100644 --- a/anymail/_version.py +++ b/anymail/_version.py @@ -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 __minor_version__ = '.'.join([str(x) for x in VERSION[:2]]) # Sphinx's X.Y "version" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..a3e84ca --- /dev/null +++ b/setup.cfg @@ -0,0 +1,5 @@ +[metadata] +license_file = LICENSE + +[bdist_wheel] +universal=1 diff --git a/setup.py b/setup.py index b4cff12..2ec0100 100644 --- a/setup.py +++ b/setup.py @@ -1,37 +1,42 @@ -from setuptools import setup 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) -__version__ = "UNSET" -__minor_version__ = "UNSET" -with open("anymail/_version.py") as f: +with open(path.join(here, "anymail/_version.py"), encoding='utf-8') as f: 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): # 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.) - 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 r'|(?<=/)stable' # ReadTheDocs links: /stable --> /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 -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()) setup( name="django-anymail", - version=__version__, + version=version, description='Django email backends for Mailgun, Mailjet, Postmark, SendGrid, SparkPost ' 'and other transactional ESPs', keywords="django, email, email backend, ESP, transactional mail, mailgun, mailjet, mandrill, postmark, sendgrid", - author="Mike Edmunds ", + author="Mike Edmunds and Anymail contributors", author_email="medmunds@gmail.com", url="https://github.com/anymail/django-anymail", license="BSD License", @@ -57,15 +62,29 @@ setup( "Programming Language :: Python", "Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "License :: OSI Approved :: BSD License", + "Topic :: Communications :: Email", "Topic :: Software Development :: Libraries :: Python Modules", + "Intended Audience :: Developers", "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", ], 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"), + ]), )