diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 6eb69c5..8c60245 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -19,7 +19,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools - python -m pip install -r requires/lint.txt + python -m pip install '.[ci]' - name: Flake8 run: | flake8 sprockets tests.py @@ -37,7 +37,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip setuptools - python -m pip install -r requires/testing.txt + python -m pip install '.[ci]' python -m pip install -e '.[msgpack]' - name: Dump packages run: python -m pip freeze @@ -48,7 +48,7 @@ jobs: coverage xml -o ./coverage.xml - name: Send coverage data to codecov.io uses: codecov/codecov-action@v1.3.2 - if: github.event_name == 'push' + if: github.event_name == 'push' && github.repository == 'sprockets/sprockets.mixins.media_type' with: file: ./coverage.xml flags: unittests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c332c4a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: python -dist: xenial -python: - - "3.7" - - "3.8" -install: - - pip install codecov -r requires/development.txt -script: - - python setup.py build_sphinx - - python setup.py check - - flake8 sprockets - - coverage run -m unittest discover tests - - coverage report -after_success: - - codecov -deploy: - distributions: sdist bdist_wheel - provider: pypi - on: - python: 3.8 - tags: true - all_branches: true - user: sprockets - password: - secure: BdTGYPioHV/pxNTKnS1pxBFu4cqJHHNu7VtYebWDVKBtaavYSpyFh3Vbfpx5RpTjJbMHjmJBtGbsbndU8N8BwxAcDrWfvxYtV7IjaPonZCzBzAtieSAwR7qrgb8lPc3Z1qUSjK80zl3PgNTph+0Y2c2wJX84odq689y9nNsV3t9sM+91SqGN5zonuFlM7JlyR0ihJzQVuGq5Wnq66qPd8yErPQjeI3nTPHnRRSLrwCBhengncRKRng/HmJPQ0Ywu84Mcvu3qlOq+Km2mFWAdzjn9dXRhFsHYupzKhg45WFL2jlBpPxeH2J9WTzFTGcTdOSQ3wnfw1TvxNLHcsCAK+QH1WJjuNR4KybwRP142EZ7L1ys4ANQCSe5wcw4FRBqwhMjYd96MiSW5Mp7AnN0s/FBReJJcXccUyVkgENTuyqyM63o7YX9jySp8jRmRtnOkz3K0pydM1HHSY0wn8IC8ElFbVu4OhevOr/w0ZqLwot/lLwTgQgT4qhGDB9PGRd1eHTx2T2GDhXN6pCIXm7Whk5piIsOZoSk1xtzAEoq05bPB5hPfBjoW41uC2W/q2RlKLI/yp9LgNayrUSmNcXCrZ9L37b2aO5UN16yzM4AUilkLteiOMJOze+KMerlwsqoMAPJvoed1ioTd8IPQDFUy/2TQvYKAHGPMkJjenXW540E= diff --git a/CONTRIBUTING b/CONTRIBUTING index 4ad338a..c937ef9 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -18,7 +18,7 @@ you you don't have a choice. That is why we run our tests using tox. The next step is to install the development tools that this project uses. These are listed in *requires/development.txt*:: - $ env/bin/pip install -qr requires/development.txt + $ env/bin/pip install '.[dev]' At this point, you will have everything that you need to develop at your disposal. Use the unittest runner to run the test suite or the coverage @@ -45,7 +45,7 @@ tool chest. It provides the following commands: **./setup.py build_sphinx** Generate the documentation using sphinx. -**./setup.py flake8** +**flake8 sprockets tests.py** Run flake8 over the code and report style violations. If any of the preceding commands give you problems, then you will have to diff --git a/docs/conf.py b/docs/conf.py index d33ee0d..f75a38b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,37 +1,35 @@ +import os + import pkg_resources -needs_sphinx = '1.0' +needs_sphinx = '4.0' extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.intersphinx', 'sphinx.ext.extlinks', - 'sphinxcontrib.autohttp.tornado'] + 'sphinxcontrib.httpdomain'] master_doc = 'index' project = 'sprockets.mixins.mediatype' -copyright = '2015-2018, AWeber Communications' +copyright = '2015-2021, AWeber Communications' release = pkg_resources.get_distribution('sprockets.mixins.mediatype').version version = '.'.join(release.split('.')[0:1]) -html_style = 'custom.css' -html_static_path = ['static'] +# Only install the ReadTheDocs theme when we are not running +# in the RTD build system. +if not os.environ.get('READTHEDOCS', None): + import sphinx_rtd_theme + html_theme = 'sphinx_rtd_theme' + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + html_sidebars = { '**': ['about.html', 'navigation.html'], } -html_theme_options = { - 'github_user': 'sprockets', - 'github_repo': 'sprockets.mixins.mediatype', - 'description': 'Content-Type negotation mix-in', - 'github_banner': True, - 'travis_button': True, - 'sidebar_width': '230px', - 'codecov_button': True, -} intersphinx_mapping = { 'python': ('https://docs.python.org/3', None), 'requests': ('https://requests.readthedocs.org/en/latest/', None), 'sprockets': ('https://sprockets.readthedocs.org/en/latest/', None), - 'tornado': ('http://tornadoweb.org/en/latest/', None), + 'tornado': ('https://www.tornadoweb.org/en/stable/', None), } # https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html diff --git a/docs/static/custom.css b/docs/static/custom.css deleted file mode 100644 index 59fb5ed..0000000 --- a/docs/static/custom.css +++ /dev/null @@ -1,32 +0,0 @@ -@import url("alabaster.css"); -h1.logo { - font-size: 12pt; - overflow-wrap: normal; - word-wrap: normal; - overflow: hidden; - margin-right: -25px; /* works together with div.body padding-left */ -} -div.body {padding-left: 30px;} -th.field-name {hyphens: none; -webkit-hyphens: none; -ms-hyphens: none;} -div.document {width: 90%;} -/* support small screens too! */ -@media screen and (max-width: 1000px) { - div.sphinxsidebar {display: none;} - div.document {width: 100%!important;} - div.bodywrapper {margin-left: 0;} - div.highlight pre {margin-right: -30px;} -} -@media screen and (min-width: 1000px) { - div.bodywrapper {margin-left: default;} -} -/* hanging indent for class names - * would use "text-indent: 2em hanging" if it were supported everywhere - */ -dl.class > dt, dl.function > dt { - text-indent: -4em; - padding-left: 4em; -} -/* add some space to wrap nicely */ -span.sig-paren::after { - content: " "; -} diff --git a/requires/development.txt b/requires/development.txt deleted file mode 100644 index f6ea5a6..0000000 --- a/requires/development.txt +++ /dev/null @@ -1,4 +0,0 @@ --e .[msgpack] --r docs.txt --r lint.txt --r testing.txt diff --git a/requires/docs.txt b/requires/docs.txt deleted file mode 100644 index 3c555e5..0000000 --- a/requires/docs.txt +++ /dev/null @@ -1,2 +0,0 @@ -sphinx==4.2.0 -sphinxcontrib-httpdomain==1.7.0 diff --git a/requires/installation.txt b/requires/installation.txt deleted file mode 100644 index 0fbae78..0000000 --- a/requires/installation.txt +++ /dev/null @@ -1,2 +0,0 @@ -ietfparse>=1.5.1,<2 -tornado>=5,<7 diff --git a/requires/lint.txt b/requires/lint.txt deleted file mode 100644 index 694f7a4..0000000 --- a/requires/lint.txt +++ /dev/null @@ -1 +0,0 @@ -flake8==3.9.2 diff --git a/requires/testing.txt b/requires/testing.txt deleted file mode 100644 index 1500af8..0000000 --- a/requires/testing.txt +++ /dev/null @@ -1,2 +0,0 @@ -coverage==5.5 -tox==3.24.3 diff --git a/setup.cfg b/setup.cfg index 3eac929..8ba4f09 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,55 @@ -[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 +ci = + coverage==5.5 + flake8==3.9.2 +dev = + coverage==5.5 + flake8==3.9.2 + sphinx==4.2.0 + sphinx-rtd-theme==1.0.0 + sphinxcontrib-httpdomain==1.7.0 + tox==3.24.3 +docs = + sphinx==4.2.0 + sphinx-rtd-theme==1.0.0 + sphinxcontrib-httpdomain==1.7.0 [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/__init__.py b/sprockets/__init__.py index de40ea7..656dc0f 100644 --- a/sprockets/__init__.py +++ b/sprockets/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) +__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover diff --git a/sprockets/mixins/__init__.py b/sprockets/mixins/__init__.py index de40ea7..656dc0f 100644 --- a/sprockets/mixins/__init__.py +++ b/sprockets/mixins/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) +__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover diff --git a/sprockets/mixins/mediatype/__init__.py b/sprockets/mixins/mediatype/__init__.py index c53fec5..2d54e3a 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, + from .content import (ContentMixin, ContentSettings, # noqa: F401 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 +except ImportError: # pragma: no cover + 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