generated from pimoroni/boilerplate-python
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c25a989
Showing
21 changed files
with
627 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
linters: | ||
flake8: | ||
python: 3 | ||
max-line-length: 160 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
language: python | ||
sudo: false | ||
cache: pip | ||
|
||
git: | ||
submodules: true | ||
|
||
matrix: | ||
include: | ||
- python: "2.7" | ||
env: TOXENV=py27 | ||
- python: "3.5" | ||
env: TOXENV=py35 | ||
|
||
install: | ||
- pip install --ignore-installed --upgrade setuptools pip tox coveralls | ||
|
||
script: | ||
- cd library | ||
- tox -vv | ||
|
||
after_success: if [ "$TOXENV" == "py35" ]; then coveralls; fi | ||
|
||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# {{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 Versions](https://img.shields.io/pypi/pyversions/{{LIBNAME}}.svg)](https://pypi.python.org/pypi/{{LIBNAME}}) | ||
|
||
# Pre-requisites | ||
|
||
You must enable (delete where appropriate): | ||
|
||
* i2c: `sudo raspi-config nonint do_i2c 0` | ||
* spi: `sudo raspi-config nonint do_spi 0` | ||
|
||
You can optionally run `sudo raspi-config` or the graphical Raspberry Pi Configuration UI to enable interfaces. | ||
|
||
# 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` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
* Python Library - library/name/__init__.py | ||
* At least *one* test - library/tests/test_setup.py | ||
* Examples | ||
|
||
# In Detail | ||
|
||
To get started, copy the contents of this repository (excluding the .git directory) and run `_bootstrap.sh` to highlight substitutions you need to make. | ||
|
||
Be careful to copy *all* files, including those starting with a . such as `.travis.yml`. | ||
|
||
A Makefile is provided to automate some tests, checks and package building. You should use it! | ||
|
||
## Library | ||
|
||
### Structure | ||
|
||
Libraries should be singleton if they pertain to a HAT or pHAT and class-based if they are for breakouts with selectable addresses. | ||
|
||
A singleton library would work like this: | ||
|
||
``` | ||
import library | ||
library.do_something() | ||
``` | ||
|
||
Whereas a class-based library requires an instance of its class: | ||
|
||
``` | ||
import library | ||
device = library.Library() | ||
device.do_something() | ||
``` | ||
|
||
### Linting | ||
|
||
You should ensure you either run `flake8` while writing the library, or use an IDE/Editor with linting. | ||
|
||
All libraries (and example code) should stick to PEP8 style guides, although you can ignore long line warnings (E501) if you feel they're unwarranted. | ||
|
||
### Testing | ||
|
||
At least one test script should be used to prevent obvious errors and omissions from creeping into the library. | ||
|
||
You should use `tox` to run the test scripts: | ||
|
||
``` | ||
sudo pip install tox | ||
cd library/ | ||
tox | ||
``` | ||
|
||
## Examples | ||
|
||
Examples should use hyphens and short, descriptive names, ie: `rainbow-larson.py` | ||
|
||
Examples should include a `print()` front-matter introducing them, ie: | ||
|
||
``` | ||
print("""rainbow-larson.py - Display a larson scanning rainbow | ||
Press Ctrl+C to exit. | ||
""") | ||
``` | ||
|
||
# Deployment | ||
|
||
Before deploying you should `make python-testdeploy` and verify that the package looks good and is installable from test PyPi. | ||
|
||
You should also `make check` to catch common errors, including mismatched version numbers, trailing whitespace and DOS line-endings. | ||
|
||
Subsequent to deployment you should `git tag -a "vX.X.X" -m "Version X.X.X"` and `git push origin master --follow-tags` to tag a release on GitHub that matches the deployed code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
printf "\nOutstanding substitutions:\n" | ||
grep -Irn --color "{{[A-Z:]*}}" | ||
|
||
printf "\nOutstanding directory renames:\n" | ||
find . -regex ".*{{[A-Z]*}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
git remote rename origin boilerplate | ||
git remote set-url --push boilerplate no_push | ||
git remote add origin $1 |
Oops, something went wrong.