@@ -27,6 +27,10 @@ MicroPython PyPi package template with GitHub Action based testing and deploy
2727 - [Manually](#manually)
2828 - [Upload files to board](#upload-files-to-board)
2929- [ Usage] ( #usage )
30+ - [ Create a PyPi \( micropython\) package] ( #create-a-pypi-micropython-package )
31+ - [Setup](#setup-1)
32+ - [Create a distribution](#create-a-distribution)
33+ - [Upload to PyPi](#upload-to-pypi)
3034- [ Contributing] ( #contributing )
3135 - [Unittests](#unittests)
3236- [ Credits] ( #credits )
@@ -142,6 +146,51 @@ flash_led(pin=led_pin, amount=3)
142146# flash_led(pin=led_pin, amount=3, on_time=1, off_time=3)
143147```
144148
149+ ## Create a PyPi (micropython) package
150+
151+ ### Setup
152+
153+ Install the required python package with the following command in a virtual
154+ environment to avoid any conflicts with other packages installed on your local
155+ system.
156+
157+ ``` bash
158+ python3 -m venv .venv
159+ source .venv/bin/activate
160+
161+ pip install twine
162+ ```
163+
164+ ### Create a distribution
165+
166+ This module overrides distutils (also compatible with setuptools) ` sdist `
167+ command to perform pre- and post-processing as required for MicroPython's
168+ upip package manager. This script is taken from
169+ [ pfalcon's picoweb] [ ref-pfalcon-picoweb-sdist-upip ] and updated to be PEP8
170+ conform.
171+
172+ ``` bash
173+ python setup.py sdist
174+ ```
175+
176+ A new folder ` dist ` will be created. The [ ` sdist_upip ` ] ( sdist_upip.py ) will be
177+ used to create everything necessary.
178+
179+ ### Upload to PyPi
180+
181+ ** Be aware: [ pypi.org] [ ref-pypi ] and [ test.pypi.org] [ ref-test-pypi ] are different**
182+
183+ You can ** NOT** login to [ test.pypi.org] [ ref-test-pypi ] with the
184+ [ pypi.org] [ ref-pypi ] account unless you created the same on the other. See
185+ [ invalid auth help page of ** test** pypi] [ ref-invalid-auth-test-pypi ]
186+
187+ For testing purposes add ` --repository testpypi ` to
188+ upload it to [ test.pypi.org] [ ref-test-pypi ]
189+
190+ ``` bash
191+ twine upload dist/micropython-package-template-* .tar.gz -u PYPI_USERNAME -p PYPI_PASSWORD
192+ ```
193+
145194## Contributing
146195
147196### Unittests
@@ -174,3 +223,7 @@ Based on the [PyPa sample project][ref-pypa-sample].
174223[ ref-remote-upy-shell ] : https://github.com/dhylands/rshell
175224[ ref-brainelectronics-test-pypiserver ] : https://github.com/brainelectronics/test-pypiserver
176225[ ref-pypa-sample ] : https://github.com/pypa/sampleproject
226+ [ ref-pfalcon-picoweb-sdist-upip ] : https://github.com/pfalcon/picoweb/blob/b74428ebdde97ed1795338c13a3bdf05d71366a0/sdist_upip.py
227+ [ ref-test-pypi ] : https://test.pypi.org/
228+ [ ref-pypi ] : https://pypi.org/
229+ [ ref-invalid-auth-test-pypi ] : https://test.pypi.org/help/#invalid-auth
0 commit comments