Skip to content

Commit e6a3b8f

Browse files
Merge pull request #15 from brainelectronics/feature/improvements-and-findings-after-first-usage
Improvements and findings after first usage
2 parents 7799cdd + 1714e47 commit e6a3b8f

File tree

13 files changed

+158
-11
lines changed

13 files changed

+158
-11
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ omit =
1010
.tox/*,
1111
build/*,
1212
dist/*,
13-
version.py
13+
be_upy_blink/version.py
1414

1515
[report]
1616
# include = src/*

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ trim_trailing_whitespace = true
1515
[*.py]
1616
indent_size = 4
1717

18+
[*.json]
19+
indent_size = 4
20+
21+
# 2 space indentation
1822
[*.yml]
1923
indent_size = 2
2024

.flake8

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ exclude =
4545
libs_external
4646
sdist_upip.py
4747
setup.py
48-
update_version.py
4948

5049
# Provide a comma-separated list of glob patterns to add to the list of excluded ones.
5150
# extend-exclude =

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ on:
1313
branches-ignore:
1414
- 'main'
1515
- 'develop'
16+
pull_request:
17+
branches:
18+
- 'main'
19+
- 'develop'
1620

1721
permissions:
1822
contents: read

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 brainelectronics and contributors
3+
Copyright (c) 2023 brainelectronics and contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ MicroPython PyPi package template project with auto deploy
1515

1616
MicroPython PyPi package template with GitHub Action based testing and deploy
1717

18+
📚 The latest documentation is available at
19+
[MicroPython Package Template ReadTheDocs][ref-rtd-micropython-package-template] 📚
20+
1821
<!-- MarkdownTOC -->
1922

2023
- [Installation](#installation)
@@ -33,6 +36,7 @@ MicroPython PyPi package template with GitHub Action based testing and deploy
3336
- [Upload to PyPi](#upload-to-pypi)
3437
- [Contributing](#contributing)
3538
- [Unittests](#unittests)
39+
- [Steps after using this template](#steps-after-using-this-template)
3640
- [Credits](#credits)
3741

3842
<!-- /MarkdownTOC -->
@@ -76,6 +80,13 @@ station.isconnected()
7680

7781
Install the latest package version of this lib on the MicroPython device
7882

83+
```python
84+
import mip
85+
mip.install("github:brainelectronics/micropython-package-template")
86+
```
87+
88+
For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`
89+
7990
```python
8091
import upip
8192
upip.install('micropython-package-template')
@@ -85,6 +96,16 @@ upip.install('micropython-package-template')
8596

8697
Install a specific, fixed package version of this lib on the MicroPython device
8798

99+
```python
100+
import mip
101+
# install a verions of a specific branch
102+
mip.install("github:brainelectronics/micropython-package-template", version="feature/initial-implementation")
103+
# install a tag version
104+
mip.install("github:brainelectronics/micropython-package-template", version="0.6.0")
105+
```
106+
107+
For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`
108+
88109
```python
89110
import upip
90111
upip.install('micropython-package-template==0.1.1')
@@ -97,6 +118,13 @@ Install a specific release candidate version uploaded to
97118
MicroPython device. If no specific version is set, the latest stable version
98119
will be used.
99120

121+
```python
122+
import mip
123+
mip.install("github:brainelectronics/micropython-package-template", version="0.6.0-rc9.dev13")
124+
```
125+
126+
For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`
127+
100128
```python
101129
import upip
102130
# overwrite index_urls to only take artifacts from test.pypi.org
@@ -215,11 +243,33 @@ coverage html
215243

216244
The coverage report is placed at `reports/coverage/html/index.html`
217245

246+
## Steps after using this template
247+
248+
In order to use this template for a new MicroPython package to following steps
249+
should be done and changes to these file being made
250+
251+
| File | Changes | More details |
252+
| ---- | ------- | -------------|
253+
| `.coveragerc` | Path to `version.py` file | Omit version file from coverage |
254+
| `.coveragerc` | Path to `include` folder | Include the package folder for coverage |
255+
| `.github/workflows/release.yml` | Path to `version.py` file | Use package version file to set changelog based version |
256+
| `.github/workflows/test-release.yml` | Path to `version.py` file | Use package version file to set changelog based version |
257+
| `.github/workflows/test.yml` | Path to `version.py` file | Use package version file to set changelog based version |
258+
| `README.md` | Links in header section and installation instructions | |
259+
| `changelog.md` | Cleanup changelog from informations of template | Keep usage of SemVer |
260+
| `docs/DOCUMENTATION.md` | Kink to ReadTheDocs | |
261+
| `docs/conf.py` | List to modules to be mocked, package import, path to `version.py` file, update `author`, `project` and `linkcheck_ignore` | |
262+
| `docs/index.rst` | Header name and included modules | Replace `be_upy_blink` with new `.rst` file of new package |
263+
| `docs/NEW_MODULE_NAME.rst` | Create a new `.rst` file named as the package | Use `docs/be_upy_blink.rst` as template |
264+
| `package.json` | Files and paths to new package and repo | Used by `mip` |
265+
| `setup.py` | Path to `version.py` file, `name`, `description`, `url`, `author`, `author_email`, `keywords`, `project_urls`, `packages`, `install_requires` | Used to create the package and its informations published at e.g. PyPI |
266+
218267
## Credits
219268

220269
Based on the [PyPa sample project][ref-pypa-sample].
221270

222271
<!-- Links -->
272+
[ref-rtd-micropython-package-template]: https://micropython-package-template.readthedocs.io/en/latest/
223273
[ref-remote-upy-shell]: https://github.com/dhylands/rshell
224274
[ref-brainelectronics-test-pypiserver]: https://github.com/brainelectronics/test-pypiserver
225275
[ref-pypa-sample]: https://github.com/pypa/sampleproject

changelog.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
1717
-->
1818

1919
## Released
20+
## [0.7.0] - 2023-03-17
21+
### Added
22+
- Set settings for JSON files to use an indentation of 4 in `.editorconfig`
23+
- `package.json` for `mip` installation with MicroPython v1.19.1 or newer
24+
- Instructions for installation with `mip` on MicroPython v1.19.1 or newer in `README`
25+
- Instructions to be performed after using this template package in `README`
26+
- Example files for `boot` and `main`
27+
28+
### Changed
29+
- Omit package version file from coverage calculation in `.coveragerc`
30+
- Run test workflow also on pull requests
31+
- Update date of license to 2023
32+
33+
### Removed
34+
- No longer used `update_version.py` file removed from flake8 exclude list
35+
36+
### Fixed
37+
- Path to documentation build output folder is only highlighted to avoid broken links errors
38+
- Mock commonly used MicroPython specific modules in docs config file
39+
2040
## [0.6.0] - 2023-02-22
2141
### Added
2242
- `.editorconfig` for common editor settings, see #12
@@ -90,8 +110,9 @@ r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
90110
- [`setup.py`](setup.py) and [`sdist_upip.py`](sdist_upip.py) file
91111

92112
<!-- Links -->
93-
[Unreleased]: https://github.com/brainelectronics/micropython-package-template/compare/0.6.0...main
113+
[Unreleased]: https://github.com/brainelectronics/micropython-package-template/compare/0.7.0...main
94114

115+
[0.7.0]: https://github.com/brainelectronics/micropython-package-template/tree/0.7.0
95116
[0.6.0]: https://github.com/brainelectronics/micropython-package-template/tree/0.6.0
96117
[0.5.0]: https://github.com/brainelectronics/micropython-package-template/tree/0.5.0
97118
[0.4.0]: https://github.com/brainelectronics/micropython-package-template/tree/0.4.0

docs/DOCUMENTATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sphinx-build docs/ docs/build/linkcheck -d docs/build/docs_doctree/ --color -bli
3434
sphinx-build docs/ docs/build/html/ -d docs/build/docs_doctree/ --color -bhtml -j auto -W
3535
```
3636

37-
The created documentation can be found at [`docs/build/html`](docs/build/html).
37+
The created documentation can be found at `docs/build/html`.
3838

3939
<!-- Links -->
4040
[ref-rtd-micropython-package-template]: https://micropython-package-template.readthedocs.io/en/latest/

docs/conf.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@
1414
here = Path(__file__).parent.resolve()
1515

1616
try:
17-
import be_upy_blink
18-
except ImportError:
19-
raise SystemExit("be_upy_blink has to be importable")
20-
else:
2117
# Inject mock modules so that we can build the
2218
# documentation without having the real stuff available
2319
from mock import Mock
2420

25-
sys.modules['micropython'] = Mock()
26-
print("Mocked 'micropython' module")
21+
to_be_mocked = [
22+
'micropython',
23+
'machine',
24+
'time.sleep_ms', 'time.sleep_us',
25+
]
26+
for module in to_be_mocked:
27+
sys.modules[module] = Mock()
28+
print("Mocked '{}' module".format(module))
29+
30+
import be_upy_blink
31+
except ImportError:
32+
raise SystemExit("be_upy_blink has to be importable")
2733

2834
# load elements of version.py
2935
exec(open(here / '..' / 'be_upy_blink' / 'version.py').read())

examples/boot.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: UTF-8 -*-
3+
4+
"""
5+
Boot script
6+
Do initial stuff here, similar to the setup() function on Arduino
7+
"""
8+
9+
# This file is executed on every boot (including wake-boot from deepsleep)
10+
# import esp
11+
# esp.osdebug(None)
12+
# import webrepl
13+
# webrepl.start()
14+
15+
print('System booted successfully!')

0 commit comments

Comments
 (0)