From 31fd0927ed183241ffe72f9f1dc65efa1006032a Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Sat, 16 Nov 2019 00:02:47 +0000 Subject: [PATCH] Update project to match cookiecutter-mopidy-ext The first version of requests officially supporting Python 3.7 is v2.20.0. The CircleCI build will fail because there isn't a 3.7 wheel for python-spotify on PyPI. --- .circleci/config.yml | 51 +++++++++++++++++++ .gitignore | 17 +++---- .travis.yml | 42 ---------------- CHANGES.rst => CHANGELOG.rst | 0 MANIFEST.in | 14 ++++-- README.rst | 19 ++++---- dev-requirements.txt | 4 -- pyproject.toml | 17 +++++++ setup.cfg | 94 ++++++++++++++++++++++++++++++++++-- setup.py | 47 +----------------- tox.ini | 25 +++++----- 11 files changed, 200 insertions(+), 130 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 .travis.yml rename CHANGES.rst => CHANGELOG.rst (100%) delete mode 100644 dev-requirements.txt create mode 100644 pyproject.toml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..bfd4689a --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,51 @@ +version: 2.1 + +orbs: + codecov: codecov/codecov@1.0.5 + +workflows: + version: 2 + test: + jobs: + - py38 + - py37 + - black + - check-manifest + - flake8 + +jobs: + py38: &test-template + docker: + - image: mopidy/ci-python:3.8 + steps: + - checkout + - restore_cache: + name: Restoring tox cache + key: tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.cfg" }} + - run: + name: Run tests + command: | + tox -e $CIRCLE_JOB -- \ + --junit-xml=test-results/pytest/results.xml \ + --cov-report=xml + - save_cache: + name: Saving tox cache + key: tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.cfg" }} + paths: + - ./.tox + - ~/.cache/pip + - codecov/upload: + file: coverage.xml + - store_test_results: + path: test-results + + py37: + <<: *test-template + docker: + - image: mopidy/ci-python:3.7 + + black: *test-template + + check-manifest: *test-template + + flake8: *test-template diff --git a/.gitignore b/.gitignore index 3bc63c38..03640c9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,9 @@ -*.egg-info *.pyc -*.swp -.cache/ -.coverage -.tox/ -MANIFEST -build/ -dist/ -xunit-*.xml +/.coverage +/.mypy_cache/ +/.pytest_cache/ +/.tox/ +/*.egg-info +/build/ +/dist/ +/MANIFEST diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5a23a986..00000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -language: python - -python: - - "2.7" - -virtualenv: - system_site_packages: true - -addons: - apt: - sources: - - mopidy-stable - packages: - - mopidy - - python-spotify - -env: - - TOX_ENV=py27 - - TOX_ENV=flake8 - - TOX_ENV=check-manifest - -install: - - "pip install tox" - -script: - - "tox -e $TOX_ENV" - -after_success: - - "if [ $TOX_ENV == 'py27' ]; then pip install coveralls; coveralls; fi" - -branches: - except: - - debian - -notifications: - irc: - channels: - - "irc.freenode.org#mopidy" - on_success: change - on_failure: change - use_notice: true - skip_join: true diff --git a/CHANGES.rst b/CHANGELOG.rst similarity index 100% rename from CHANGES.rst rename to CHANGELOG.rst diff --git a/MANIFEST.in b/MANIFEST.in index 7f7f76d3..e8a90ecb 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,10 +1,16 @@ +include *.py include *.rst -include *.txt -include .travis.yml +include .mailmap include LICENSE include MANIFEST.in -include mopidy_spotify/ext.conf -include mopidy_spotify/spotify_appkey.key +include pyproject.toml include tox.ini +recursive-include .circleci * +recursive-include .github * + +include mopidy_*/ext.conf +include mopidy_spotify/spotify_appkey.key + recursive-include tests *.py +recursive-include tests/data * diff --git a/README.rst b/README.rst index 69809926..dd1353a1 100644 --- a/README.rst +++ b/README.rst @@ -2,17 +2,17 @@ Mopidy-Spotify ************** -.. image:: https://img.shields.io/pypi/v/Mopidy-Spotify.svg?style=flat - :target: https://pypi.python.org/pypi/Mopidy-Spotify/ +.. image:: https://img.shields.io/pypi/v/Mopidy-Spotify.svg + :target: https://pypi.org/project/Mopidy-Spotify/ :alt: Latest PyPI version -.. image:: https://img.shields.io/travis/mopidy/mopidy-spotify/develop.svg?style=flat - :target: https://travis-ci.org/mopidy/mopidy-spotify - :alt: Travis CI build status +.. image:: https://img.shields.io/circleci/project/mopidy/mopidy-spotify/develop.svg + :target: https://circleci.com/gh/mopidy/mopidy-spotify + :alt: CircleCI build status -.. image:: https://img.shields.io/coveralls/mopidy/mopidy-spotify/develop.svg?style=flat - :target: https://coveralls.io/r/mopidy/mopidy-spotify - :alt: Test coverage +.. image:: https://img.shields.io/codecov/c/github/mopidy/mopidy-spotify/develop.svg + :target: https://codecov.io/gh/mopidy/mopidy-spotify + :alt: Test coverage `Mopidy `_ extension for playing music from `Spotify `_. @@ -115,7 +115,7 @@ OS X: Install the ``mopidy-spotify`` package from the Else: Install the dependencies listed above yourself, and then install the package from PyPI:: - pip install Mopidy-Spotify + python3 -m pip Mopidy-Spotify Configuration @@ -188,6 +188,7 @@ Project resources - `Source code `_ - `Issue tracker `_ +- `Changelog `_ Credits diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index 12152e3d..00000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -pytest -pytest-cov -mock -responses diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..bff16e03 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,17 @@ +[build-system] +requires = ["setuptools >= 30.3.0", "wheel"] + + +[tool.black] +target-version = ["py37", "py38"] +line-length = 80 + + +[tool.isort] +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +line_length = 88 +known_tests = "tests" +sections = "FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,TESTS,LOCALFOLDER" diff --git a/setup.cfg b/setup.cfg index 1afcbd19..07a56550 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,92 @@ -[flake8] -application-import-names = mopidy_spotify,tests -exclude = .git,.tox +[metadata] +name = Mopidy-Spotify +version = 3.1.0 +url = https://github.com/mopidy/mopidy-spotify +author = Stein Magnus Jodal +author_email = stein.magnus@jodal.no +license = Apache License, Version 2.0 +license_file = LICENSE +description = Mopidy extension for playing music from Spotify +long_description = file: README.rst +classifiers = + Environment :: No Input/Output (Daemon) + Intended Audience :: End Users/Desktop + License :: OSI Approved :: Apache Software License + Operating System :: OS Independent + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Topic :: Multimedia :: Sound/Audio :: Players + + +[options] +zip_safe = False +include_package_data = True +packages = find: +python_requires = >= 3.7 +install_requires = + Mopidy >= 3.0.0a4 # Change to >= 3.0 once final is released + Pykka >= 2.0.1 + pyspotify >= 2.0.5 + requests >= 2.20.0 + setuptools + + +[options.extras_require] +lint = + black + check-manifest + flake8 + flake8-bugbear + flake8-import-order + isort[pyproject] +release = + twine + wheel +test = + pytest + pytest-cov + responses +dev = + %(lint)s + %(release)s + %(test)s + + +[options.packages.find] +exclude = + tests + tests.* -[wheel] + +[options.entry_points] +mopidy.ext = + spotify = mopidy_spotify:Extension + + +[bdist_wheel] universal = 1 + + +[flake8] +application-import-names = mopidy_spotify, tests +max-line-length = 80 +exclude = .git, .tox, build +select = + # Regular flake8 rules + C, E, F, W + # flake8-bugbear rules + B + # B950: line too long (soft speed limit) + B950 + # pep8-naming rules + N +ignore = + # E203: whitespace before ':' (not PEP8 compliant) + E203 + # E501: line too long (replaced by B950) + E501 + # W503: line break before binary operator (not PEP8 compliant) + W503 + # B305: .next() is not a thing on Python 3 (used by playback controller) + B305 diff --git a/setup.py b/setup.py index 590723f5..60684932 100644 --- a/setup.py +++ b/setup.py @@ -1,46 +1,3 @@ -from __future__ import unicode_literals +from setuptools import setup -import re - -from setuptools import find_packages, setup - - -def get_version(filename): - content = open(filename).read() - metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", content)) - return metadata['version'] - - -setup( - name='Mopidy-Spotify', - version=get_version('mopidy_spotify/__init__.py'), - url='https://github.com/mopidy/mopidy-spotify', - license='Apache License, Version 2.0', - author='Stein Magnus Jodal', - author_email='stein.magnus@jodal.no', - description='Mopidy extension for playing music from Spotify', - long_description=open('README.rst').read(), - packages=find_packages(exclude=['tests', 'tests.*']), - zip_safe=False, - include_package_data=True, - install_requires=[ - 'Mopidy >= 2.0', - 'Pykka >= 1.1', - 'pyspotify >= 2.0.5', - 'requests >= 2.0', - 'setuptools', - ], - entry_points={ - 'mopidy.ext': [ - 'spotify = mopidy_spotify:Extension', - ], - }, - classifiers=[ - 'Environment :: No Input/Output (Daemon)', - 'Intended Audience :: End Users/Desktop', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2', - 'Topic :: Multimedia :: Sound/Audio :: Players', - ], -) +setup() diff --git a/tox.ini b/tox.ini index 17cf1b7c..c99a3999 100644 --- a/tox.ini +++ b/tox.ini @@ -1,24 +1,23 @@ [tox] -envlist = py27, flake8, check-manifest +envlist = py37, py38, black, check-manifest, flake8 [testenv] sitepackages = true -deps = - https://github.com/mopidy/mopidy/archive/develop.zip - -rdev-requirements.txt +deps = .[test] commands = - py.test \ + python -m pytest \ --basetemp={envtmpdir} \ --cov=mopidy_spotify --cov-report=term-missing \ {posargs} -[testenv:flake8] -deps = - flake8 - flake8-import-order -skip_install = true -commands = flake8 mopidy_spotify/ setup.py tests/ +[testenv:black] +deps = .[lint] +commands = python -m black --check . [testenv:check-manifest] -deps = check-manifest -commands = check-manifest +deps = .[lint] +commands = python -m check_manifest + +[testenv:flake8] +deps = .[lint] +commands = python -m flake8 --show-source --statistics