Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed May 24, 2019
0 parents commit 651e1c2
Show file tree
Hide file tree
Showing 18 changed files with 322 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .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
5 changes: 5 additions & 0 deletions .stickler.yml
@@ -0,0 +1,5 @@
---
linters:
flake8:
python: 3
max-line-length: 160
24 changes: 24 additions & 0 deletions .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
21 changes: 21 additions & 0 deletions 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.
62 changes: 62 additions & 0 deletions 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 "" --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/*
Expand Down
19 changes: 19 additions & 0 deletions 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`

5 changes: 5 additions & 0 deletions _bootstrap.sh
@@ -0,0 +1,5 @@
printf "\nOutstanding substitutions:\n"
grep -Irn --color "{{[A-Z:]*}}"

printf "\nOutstanding directory renames:\n"
find . -regex ".*{{[A-Z]*}}"
22 changes: 22 additions & 0 deletions 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"
4 changes: 4 additions & 0 deletions library/.coveragerc
@@ -0,0 +1,4 @@
[run]
source = {{LIBNAME}}
omit =
.tox/*
4 changes: 4 additions & 0 deletions library/CHANGELOG.txt
@@ -0,0 +1,4 @@
0.0.1
-----

* Initial Release
21 changes: 21 additions & 0 deletions 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.
5 changes: 5 additions & 0 deletions library/MANIFEST.in
@@ -0,0 +1,5 @@
include CHANGELOG.txt
include LICENSE.txt
include README.rst
include setup.py
recursive-include {{LIBNAME}} *.py
10 changes: 10 additions & 0 deletions library/setup.cfg
@@ -0,0 +1,10 @@
[flake8]
exclude =
.tox,
.eggs,
.git,
__pycache__,
build,
dist
ignore =
E501
53 changes: 53 additions & 0 deletions 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=[]
)
Empty file added library/tests/test_setup.py
Empty file.
21 changes: 21 additions & 0 deletions 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
2 changes: 2 additions & 0 deletions library/{{LIBNAME}}/__init__.py
@@ -0,0 +1,2 @@

__version__ = '0.0.1'
24 changes: 24 additions & 0 deletions 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"

0 comments on commit 651e1c2

Please sign in to comment.