Get lib name automatically for install endpoints
[EVA-2020-02-2.git] / _bootstrap.md
CommitLineData
b3d40390
PH
1* Python Library - library/name/__init__.py
2* At least *one* test - library/tests/test_setup.py
3* Examples
4
5# In Detail
6
7To get started, copy the contents of this repository (excluding the .git directory) and run `_bootstrap.sh` to highlight substitutions you need to make.
8
9Be careful to copy *all* files, including those starting with a . such as `.travis.yml`.
10
11A Makefile is provided to automate some tests, checks and package building. You should use it!
12
13## Library
14
15### Structure
16
17Libraries should be singleton if they pertain to a HAT or pHAT and class-based if they are for breakouts with selectable addresses.
18
19A singleton library would work like this:
20
21```
22import library
23
24library.do_something()
25```
26
27Whereas a class-based library requires an instance of its class:
28
29```
30import library
31
32device = library.Library()
33
34device.do_something()
35```
36
37### Linting
38
39You should ensure you either run `flake8` while writing the library, or use an IDE/Editor with linting.
40
41All libraries (and example code) should stick to PEP8 style guides, although you can ignore long line warnings (E501) if you feel they're unwarranted.
42
43### Testing
44
45At least one test script should be used to prevent obvious errors and omissions from creeping into the library.
46
47You should use `tox` to run the test scripts:
48
49```
50sudo pip install tox
51cd library/
52tox
53```
54
55## Examples
56
57Examples should use hyphens and short, descriptive names, ie: `rainbow-larson.py`
58
59Examples should include a `print()` front-matter introducing them, ie:
60
61```
62print("""rainbow-larson.py - Display a larson scanning rainbow
63
64Press Ctrl+C to exit.
65
66""")
67```
68
69# Deployment
70
71Before deploying you should `make python-testdeploy` and verify that the package looks good and is installable from test PyPi.
72
73You should also `make check` to catch common errors, including mismatched version numbers, trailing whitespace and DOS line-endings.
74
75Subsequent 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.