diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fa45562 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +build/ +_build/ +*.o +*.so +*.a +*.py[cod] +*.egg-info +dist/ +__pycache__ +.DS_Store +*.deb +*.dsc +*.build +*.changes +*.orig.* +packaging/*tar.xz +library/debian/ +.coverage +.pytest_cache +.tox diff --git a/.stickler.yml b/.stickler.yml new file mode 100644 index 0000000..2466815 --- /dev/null +++ b/.stickler.yml @@ -0,0 +1,5 @@ +--- +linters: + flake8: + python: 3 + max-line-length: 160 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..42479fe --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: python +sudo: false +cache: pip + +git: + submodules: true + +matrix: + include: + - python: "2.7" + env: TOXENV=py27 + - python: "3.5" + env: TOXENV=py35 + - python: "2.7" + env: TOXENV=py27 + +install: + - pip install --ignore-installed --upgrade setuptools pip tox coveralls + +script: + - cd library + - tox -vv + +after_success: if [ "$TOXENV" == "py35" ]; then coveralls; fi diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..aed751a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Pimoroni Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b59f0c3 --- /dev/null +++ b/Makefile @@ -0,0 +1,62 @@ +LIBRARY_VERSION=`cat library/setup.py | grep version | awk -F"'" '{print $$2}'` +LIBRARY_NAME=`cat library/setup.py | grep name | awk -F"'" '{print $$2}'` + +.PHONY: usage install uninstall +usage: + @echo "Usage: make , where target is one of:\n" + @echo "install: install the library locally from source" + @echo "uninstall: uninstall the local library" + @echo "check: peform basic integrity checks on the codebase" + @echo "python-readme: generate library/README.rst from README.md" + @echo "python-wheels: build python .whl files for distribution" + @echo "python-sdist: build python source distribution" + @echo "python-clean: clean python build and dist directories" + @echo "python-dist: build all python distribution files" + @echo "python-testdeploy: build all and deploy to test PyPi" + +install: + ./install.sh + +uninstall: + ./uninstall.sh + +check: + @echo "Checking for trailing whitespace" + @! grep -IUrn --color "[[:blank:]]$$" --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO + @echo "Checking for DOS line-endings" + @! grep -IUrn --color " " --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile + @echo "Checking library/CHANGELOG.txt" + @cat library/CHANGELOG.txt | grep ^${LIBRARY_VERSION} + @echo "Checking library/${LIBRARY_NAME}/__init__.py" + @cat library/${LIBRARY_NAME}/__init__.py | grep "^__version__ = '${LIBRARY_VERSION}'" + +python-readme: library/README.rst + +python-license: library/LICENSE.txt + +library/README.rst: README.md + pandoc --from=markdown --to=rst -o library/README.rst README.md + +library/LICENSE.txt: LICENSE + cp LICENSE library/LICENSE.txt + +python-wheels: python-readme python-license + cd library; python3 setup.py bdist_wheel + cd library; python setup.py bdist_wheel + +python-sdist: python-readme python-license + cd library; python setup.py sdist + +python-clean: + -rm -r library/dist + -rm -r library/build + -rm -r library/*.egg-info + +python-dist: python-clean python-wheels python-sdist + ls library/dist + +python-testdeploy: python-dist + twine upload --repository-url https://test.pypi.org/legacy/ library/dist/* + +python-deploy: check python-dist + twine upload library/dist/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..0a961c5 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# {{TITLE}} + +[![Build Status](https://travis-ci.com/pimoroni/{{LIBNAME}}-python.svg?branch=master)](https://travis-ci.com/pimoroni/{{LIBNAME}}-python) +[![Coverage Status](https://coveralls.io/repos/github/pimoroni/{{LIBNAME}}-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/{{LIBNAME}}-python?branch=master) +[![PyPi Package](https://img.shields.io/pypi/v/{{LIBNAME}}.svg)](https://pypi.python.org/pypi/{{LIBNAME}}-python) +[![Python Versions](https://img.shields.io/pypi/pyversions/{{LIBNAME}}.svg)](https://pypi.python.org/pypi/{{LIBNAME}}-python) + +# Installing + +Stable library from PyPi: + +* Just run `sudo pip install {{LIBNAME}}` + +Latest/development library from GitHub: + +* `git clone https://github.com/pimoroni/{{LIBNAME}}-python` +* `cd {{LIBNAME}}-python` +* `sudo ./install.sh` + diff --git a/_bootstrap.sh b/_bootstrap.sh new file mode 100755 index 0000000..8b88e7d --- /dev/null +++ b/_bootstrap.sh @@ -0,0 +1,5 @@ +printf "\nOutstanding substitutions:\n" +grep -Irn --color "{{[A-Z:]*}}" + +printf "\nOutstanding directory renames:\n" +find . -regex ".*{{[A-Z]*}}" diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..13ce97a --- /dev/null +++ b/install.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +printf "{{LIBNAME:UC}} Python Library: Installer\n\n" + +if [ $(id -u) -ne 0 ]; then + printf "Script must be run as root. Try 'sudo ./install.sh'\n" + exit 1 +fi + +cd library + +printf "Installing for Python 2..\n" +python setup.py install + +if [ -f "/usr/bin/python3" ]; then + printf "Installing for Python 3..\n" + python3 setup.py install +fi + +cd .. + +printf "Done!\n" diff --git a/library/.coveragerc b/library/.coveragerc new file mode 100644 index 0000000..dfa463a --- /dev/null +++ b/library/.coveragerc @@ -0,0 +1,4 @@ +[run] +source = {{LIBNAME}} +omit = + .tox/* diff --git a/library/CHANGELOG.txt b/library/CHANGELOG.txt new file mode 100644 index 0000000..0f98d12 --- /dev/null +++ b/library/CHANGELOG.txt @@ -0,0 +1,4 @@ +0.0.1 +----- + +* Initial Release diff --git a/library/LICENSE.txt b/library/LICENSE.txt new file mode 100644 index 0000000..aed751a --- /dev/null +++ b/library/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Pimoroni Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/library/MANIFEST.in b/library/MANIFEST.in new file mode 100644 index 0000000..4f72d67 --- /dev/null +++ b/library/MANIFEST.in @@ -0,0 +1,5 @@ +include CHANGELOG.txt +include LICENSE.txt +include README.rst +include setup.py +recursive-include {{LIBNAME}} *.py diff --git a/library/setup.cfg b/library/setup.cfg new file mode 100644 index 0000000..241587e --- /dev/null +++ b/library/setup.cfg @@ -0,0 +1,10 @@ +[flake8] +exclude = + .tox, + .eggs, + .git, + __pycache__, + build, + dist +ignore = + E501 diff --git a/library/setup.py b/library/setup.py new file mode 100755 index 0000000..4f00793 --- /dev/null +++ b/library/setup.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +""" +Copyright (c) 2016 Pimoroni + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +try: + from setuptools import setup +except ImportError: + from distutils.core import setup + +classifiers = ['Development Status :: 4 - Beta', + 'Operating System :: POSIX :: Linux', + 'License :: OSI Approved :: MIT License', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Topic :: Software Development', + 'Topic :: System :: Hardware'] + +setup( + name='{{LIBNAME}}', + version='0.0.1', + author='Philip Howard', + author_email='phil@pimoroni.com', + description="""{{DESCRIPTION}}""", + long_description=open('README.rst').read() + '\n' + open('CHANGELOG.txt').read(), + license='MIT', + keywords='Raspberry Pi', + url='http://www.pimoroni.com', + classifiers=classifiers, + packages=['{{LIBNAME}}'], + install_requires=[] +) diff --git a/library/tests/test_setup.py b/library/tests/test_setup.py new file mode 100644 index 0000000..e69de29 diff --git a/library/tox.ini b/library/tox.ini new file mode 100644 index 0000000..c3a18ec --- /dev/null +++ b/library/tox.ini @@ -0,0 +1,21 @@ +[tox] +envlist = py{27,35},qa +skip_missing_interpreters = True + +[testenv] +commands = + python setup.py install + coverage run -m py.test -v -r wsx + coverage report +deps = + mock + pytest>=3.1 + pytest-cov + +[testenv:qa] +commands = + flake8 --ignore E501 + rstcheck README.rst +deps = + flake8 + rstcheck diff --git a/library/{{LIBNAME}}/__init__.py b/library/{{LIBNAME}}/__init__.py new file mode 100644 index 0000000..2192205 --- /dev/null +++ b/library/{{LIBNAME}}/__init__.py @@ -0,0 +1,2 @@ + +__version__ = '0.0.1' diff --git a/uninstall.sh b/uninstall.sh new file mode 100755 index 0000000..ba44d0a --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +PACKAGE="{{LIBNAME}}" + +printf "{{LIBNAME:UC}} Python Library: Uninstaller\n\n" + +if [ $(id -u) -ne 0 ]; then + printf "Script must be run as root. Try 'sudo ./uninstall.sh'\n" + exit 1 +fi + +cd library + +printf "Unnstalling for Python 2..\n" +pip uninstall $PACKAGE + +if [ -f "/usr/bin/pip3" ]; then + printf "Uninstalling for Python 3..\n" + pip3 uninstall $PACKAGE +fi + +cd .. + +printf "Done!\n"