diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..a5486e6 --- /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 + {% raw %}key: tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.cfg" }}{% endraw %} + - 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 + {% raw %}key: tox-v1-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.cfg" }}{% endraw %} + 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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3b29847..5f0c41c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ -*.egg-info *.pyc -.coverage -.pytest_cache/ -.tox/ -MANIFEST -build/ -dist/ -.vscode/ +/.coverage +/.mypy_cache/ +/.pytest_cache/ +/.tox/ +/*.egg-info +/build/ +/dist/ +/MANIFEST \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 32df99f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: python - -python: - - "2.7" - -virtualenv: - system_site_packages: true - -addons: - apt: - sources: - - mopidy-stable - packages: - - mopidy - -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 diff --git a/MANIFEST.in b/MANIFEST.in index 31fe726..1ac4cab 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,9 +1,15 @@ -include .travis.yml -include CHANGELOG.rst +include *.py +include *.rst +include .mailmap include LICENSE include MANIFEST.in -include README.rst -include mopidy_raspberry_gpio/ext.conf +include pyproject.toml include tox.ini +recursive-include .circleci * +recursive-include .github * + +include mopidy_*/ext.conf + recursive-include tests *.py +recursive-include tests/data * \ No newline at end of file diff --git a/README.rst b/README.rst index 4e98f17..a8bb1ab 100644 --- a/README.rst +++ b/README.rst @@ -2,17 +2,17 @@ Mopidy-Raspberry-GPIO **************************** -.. image:: https://img.shields.io/pypi/v/Mopidy-Raspberry-GPIO.svg?style=flat +.. image:: https://img.shields.io/pypi/v/Mopidy-Raspberry-GPIO.svg :target: https://pypi.org/project/Mopidy-Raspberry-GPIO/ :alt: Latest PyPI version -.. image:: https://img.shields.io/travis/pimoroni/mopidy-raspberry-gpio/master.svg?style=flat - :target: https://travis-ci.org/pimoroni/mopidy-raspberry-gpio - :alt: Travis CI build status +.. image:: https://img.shields.io/circleci/build/gh/pimoroni/mopidy-raspberry-gpio + :target: https://circleci.com/gh/pimoroni/mopidy-raspberry-gpio + :alt: CircleCI build status -.. image:: https://img.shields.io/coveralls/pimoroni/mopidy-raspberry-gpio/master.svg?style=flat - :target: https://coveralls.io/r/pimoroni/mopidy-raspberry-gpio - :alt: Test coverage +.. image:: https://img.shields.io/codecov/c/gh/pimoroni/mopidy-raspberry-gpio + :target: https://codecov.io/gh/pimoroni/mopidy-raspberry-gpio + :alt: Test coverage Mopidy extension for GPIO input on a Raspberry Pi @@ -22,7 +22,7 @@ Installation Install by running:: - pip install Mopidy-Raspberry-GPIO + python3 -m pip install Mopidy-Raspberry-GPIO Or, if available, install the Debian/Ubuntu package from `apt.mopidy.com `_. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6a8423f --- /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" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 614c20c..b2ad4f8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,85 @@ -[flake8] -application-import-names = mopidy_raspberry_gpio,tests -exclude = .git,.tox +[metadata] +name = mopidy-raspberry-gpio +version = 0.0.2 +url = https://github.com/pimoroni/mopidy-raspberry-gpio +author = Phil Howard +author_email = phil@pimoroni.com +license = Apache License, Version 2.0 +license_file = LICENSE +description = Mopidy extension for GPIO input on a Raspberry Pi +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 -[wheel] -universal = 1 + +[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 + setuptools + + +[options.extras_require] +lint = + black + check-manifest + flake8 + flake8-bugbear + flake8-import-order + isort[pyproject] +release = + twine + wheel +test = + pytest + pytest-cov +dev = + %(lint)s + %(release)s + %(test)s + + +[options.packages.find] +exclude = + tests + tests.* + + +[options.entry_points] +mopidy.ext = + raspberry-gpio = mopidy_raspberry_gpio:Extension + + +[flake8] +application-import-names = mopidy_raspberry_gpio, 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 \ No newline at end of file diff --git a/setup.py b/setup.py index cbbc9b2..fc1f76c 100644 --- a/setup.py +++ b/setup.py @@ -1,45 +1,3 @@ -from __future__ import unicode_literals +from setuptools import setup -import re - -from setuptools import find_packages, setup - - -def get_version(filename): - with open(filename) as fh: - metadata = dict(re.findall('__([a-z]+)__ = "([^"]+)"', fh.read())) - return metadata["version"] - - -setup( - name="Mopidy-Raspberry-GPIO", - version=get_version("mopidy_raspberry_gpio/__init__.py"), - url="https://github.com/pimoroni/mopidy-raspberry-gpio", - license="Apache License, Version 2.0", - author="Phil Howard", - author_email="phil@pimoroni.com", - description="Mopidy extension for GPIO input on a Raspberry Pi", - long_description=open("README.rst").read(), - packages=find_packages(exclude=["tests", "tests.*"]), - zip_safe=False, - include_package_data=True, - python_requires="> 2.7, < 3", - install_requires=[ - "setuptools", - "Mopidy >= 2.2", - "Pykka >= 2.0", - ], - entry_points={ - "mopidy.ext": [ - "raspberry-gpio = mopidy_raspberry_gpio: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.7", - "Topic :: Multimedia :: Sound/Audio :: Players", - ], -) +setup() \ No newline at end of file diff --git a/tox.ini b/tox.ini index 1e07a84..d57a105 100644 --- a/tox.ini +++ b/tox.ini @@ -1,27 +1,23 @@ [tox] -envlist = py27, py27-flake8, py27-check-manifest +envlist = py37, py38, black, check-manifest, flake8 [testenv] sitepackages = true -deps = - mock - pytest - pytest-cov - pytest-xdist +deps = .[test] commands = - pytest \ - -v -r wsx \ + python -m pytest \ --basetemp={envtmpdir} \ --cov=mopidy_raspberry_gpio --cov-report=term-missing \ {posargs} -[testenv:py27-flake8] -deps = - flake8 - flake8-import-order -skip_install = true -commands = python -m flake8 +[testenv:black] +deps = .[lint] +commands = python -m black --check . -[testenv:py27-check-manifest] -deps = check-manifest -commands = check-manifest +[testenv:check-manifest] +deps = .[lint] +commands = python -m check_manifest + +[testenv:flake8] +deps = .[lint] +commands = python -m flake8 --show-source --statistics \ No newline at end of file