Initial Commit
authorPhil Howard <phil@gadgetoid.com>
Fri, 24 May 2019 11:46:04 +0000 (12:46 +0100)
committerPhil Howard <phil@gadgetoid.com>
Fri, 24 May 2019 11:46:04 +0000 (12:46 +0100)
18 files changed:
.gitignore [new file with mode: 0644]
.stickler.yml [new file with mode: 0644]
.travis.yml [new file with mode: 0644]
LICENSE [new file with mode: 0644]
Makefile [new file with mode: 0644]
README.md [new file with mode: 0644]
_bootstrap.sh [new file with mode: 0755]
install.sh [new file with mode: 0755]
library/.coveragerc [new file with mode: 0644]
library/CHANGELOG.txt [new file with mode: 0644]
library/LICENSE.txt [new file with mode: 0644]
library/MANIFEST.in [new file with mode: 0644]
library/setup.cfg [new file with mode: 0644]
library/setup.py [new file with mode: 0755]
library/tests/test_setup.py [new file with mode: 0644]
library/tox.ini [new file with mode: 0644]
library/{{LIBNAME}}/__init__.py [new file with mode: 0644]
uninstall.sh [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..fa45562
--- /dev/null
@@ -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 (file)
index 0000000..2466815
--- /dev/null
@@ -0,0 +1,5 @@
+---
+linters:
+    flake8:
+        python: 3
+        max-line-length: 160
diff --git a/.travis.yml b/.travis.yml
new file mode 100644 (file)
index 0000000..42479fe
--- /dev/null
@@ -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 (file)
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 (file)
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 <target>, 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 "\r" --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 (file)
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 (executable)
index 0000000..8b88e7d
--- /dev/null
@@ -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 (executable)
index 0000000..13ce97a
--- /dev/null
@@ -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 (file)
index 0000000..dfa463a
--- /dev/null
@@ -0,0 +1,4 @@
+[run]
+source = {{LIBNAME}}
+omit =
+    .tox/*
diff --git a/library/CHANGELOG.txt b/library/CHANGELOG.txt
new file mode 100644 (file)
index 0000000..0f98d12
--- /dev/null
@@ -0,0 +1,4 @@
+0.0.1
+-----
+
+* Initial Release
diff --git a/library/LICENSE.txt b/library/LICENSE.txt
new file mode 100644 (file)
index 0000000..aed751a
--- /dev/null
@@ -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 (file)
index 0000000..4f72d67
--- /dev/null
@@ -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 (file)
index 0000000..241587e
--- /dev/null
@@ -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 (executable)
index 0000000..4f00793
--- /dev/null
@@ -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 (file)
index 0000000..e69de29
diff --git a/library/tox.ini b/library/tox.ini
new file mode 100644 (file)
index 0000000..c3a18ec
--- /dev/null
@@ -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 (file)
index 0000000..2192205
--- /dev/null
@@ -0,0 +1,2 @@
+
+__version__ = '0.0.1'
diff --git a/uninstall.sh b/uninstall.sh
new file mode 100755 (executable)
index 0000000..ba44d0a
--- /dev/null
@@ -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"