From e9e5f25925c800c76abe43efa62250bcc8fd7c79 Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Mon, 13 Sep 2021 07:42:26 -0400 Subject: [PATCH] Move metadata from setup.py into setup.cfg. --- setup.cfg | 48 ++++++++++++++++++++- setup.py | 58 +++----------------------- sprockets/mixins/mediatype/__init__.py | 28 ++++--------- 3 files changed, 59 insertions(+), 75 deletions(-) diff --git a/setup.cfg b/setup.cfg index 3eac929..6638b6a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,49 @@ -[bdist_wheel] -universal = 1 +[metadata] +name = sprockets.mixins.mediatype +version = attr: sprockets.mixins.mediatype.__version__ +description = A mixin for reporting handling content-type/accept headers. +long_description = file: README.rst +long_description_content_type = text/x-rst; charset=UTF-8 +license = BSD 3-Clause License +license_file = LICENSE +home_page = https://github.com/sprockets/sprockets.mixins.mediatype +author = AWeber Communications +author_email = api@aweber.com +project_urls = + Changelog = https://sprocketsmixinsmedia-type.readthedocs.io/en/latest/history.html + Documentation = https://sprocketsmixinsmedia-type.readthedocs.io + Download = https://pypi.org/project/sprockets.mixins.mediatype/ + Source = https://github.com/sprockets/sprockets.mixins.mediatype +classifiers = + Development Status :: 5 - Production/Stable + Intended Audience :: Developers + License :: OSI Approved :: BSD License + Natural Language :: English + Operating System :: OS Independent + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: Implementation :: CPython + Topic :: Software Development :: Libraries + Topic :: Software Development :: Libraries :: Python Modules + +[options] +install_requires = + ietfparse>=1.5.1,<2 + tornado>=5,<7 + +[options.extras_require] +msgpack = + u-msgpack-python>=2.5.0,<3 +testing = + coverage==5.5 + flake8==3.9.2 +dev = + coverage==5.5 + flake8==3.9.2 + tox==3.24.3 + [build_sphinx] fresh-env = 1 diff --git a/setup.py b/setup.py index f6b5b87..02ea4f0 100755 --- a/setup.py +++ b/setup.py @@ -1,56 +1,10 @@ #!/usr/bin/env python -import pathlib +import pkg_resources import setuptools -from sprockets.mixins import mediatype +dist = pkg_resources.get_distribution('setuptools') +setup_version = tuple(int(c) for c in dist.version.split('.')[:3]) +if setup_version < (42, 0): + raise ImportError('Please upgrade setuptools') -REPO_DIR = pathlib.Path(__name__).parent - - -def read_requirements(name): - requirements = [] - for req_line in REPO_DIR.joinpath(name).read_text().split('\n'): - req_line = req_line.strip() - if '#' in req_line: - req_line = req_line[0:req_line.find('#')].strip() - if req_line.startswith('-r'): - req_line = req_line[2:].strip() - requirements.extend(read_requirements(req_line)) - else: - requirements.append(req_line) - return requirements - - -setuptools.setup( - name='sprockets.mixins.mediatype', - version=mediatype.__version__, - description='A mixin for reporting handling content-type/accept headers', - long_description=REPO_DIR.joinpath('README.rst').read_text(), - url='https://github.com/sprockets/sprockets.mixins.mediatype', - author='AWeber Communications', - author_email='api@aweber.com', - license='BSD', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: Implementation :: CPython', - 'Topic :: Software Development :: Libraries', - 'Topic :: Software Development :: Libraries :: Python Modules' - ], - packages=setuptools.find_packages(), - install_requires=read_requirements('requires/installation.txt'), - tests_require=read_requirements('requires/testing.txt'), - extras_require={ - 'msgpack': ['u-msgpack-python>=2.5.0,<3'] - }, - namespace_packages=['sprockets', 'sprockets.mixins'], - test_suite='nose.collector', - python_requires='>=3.7', - zip_safe=False) +setuptools.setup() diff --git a/sprockets/mixins/mediatype/__init__.py b/sprockets/mixins/mediatype/__init__.py index c53fec5..0cdf763 100644 --- a/sprockets/mixins/mediatype/__init__.py +++ b/sprockets/mixins/mediatype/__init__.py @@ -1,29 +1,15 @@ -""" -sprockets.mixins.mediatype - -""" +"""sprockets.mixins.mediatype""" try: from .content import (ContentMixin, ContentSettings, add_binary_content_type, add_text_content_type, set_default_content_type) except ImportError as error: # noqa: F841 # pragma no cover - def _error_closure(*args, **kwargs): - raise error # noqa: F821 - - class ErrorClosureClass(object): - def __init__(self, *args, **kwargs): - raise error # noqa: F821 - - ContentMixin = ErrorClosureClass - ContentSettings = ErrorClosureClass - add_binary_content_type = _error_closure - add_text_content_type = _error_closure - set_default_content_type = _error_closure + import warnings + warnings.warn( + 'Missing runtime requirements for sprockets.mixins.mediatype', + UserWarning) version_info = (3, 0, 4) -__version__ = '.'.join(str(x) for x in version_info) - -__all__ = ['ContentMixin', 'ContentSettings', 'add_binary_content_type', - 'add_text_content_type', 'set_default_content_type', - 'version_info', '__version__'] +version = '.'.join(str(x) for x in version_info) +__version__ = version # compatibility