MicroPython Package Validationο
Validate and create MicroPython package JSON file
Generalο
MicroPython Package Validation for mip package.json files
π The latest documentation is available at MicroPython Package Validation ReadTheDocs π
Installationο
Install required toolsο
Python3 must be installed on your system. Check the current Python version with the following command
python --version
python3 --version
Depending on which command Python 3.x.y
(with x.y as some numbers) is
returned, use that command to proceed.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Installationο
pip install setup2upypackage
Usageο
Validateο
Validate package JSON fileο
The following command will exit with a non-zero code in case of a difference
between the generated (based on setup.py
) and existing package
(package.json
) content.
upy-package \
--setup_file tests/data/setup.py \
--package_changelog_file tests/data/sample_changelog.md \
--package_file tests/data/package.json \
--validate
Validate package JSON file from changelogο
In case the package version is defined by a changelog and the version
entry
of the setup.py
file is filled on demand by e.g.
changelog2version, the semantic version changelog can
be specified explicitly to use its latest entry for the version value.
upy-package \
--setup_file tests/data/setup.py \
--package_changelog_file tests/data/sample_changelog.md \
--package_file tests/data/package.json \
--validate
Optionsο
To not take the version or the dependencies specified in the package.json
file during a validation run, use the --ignore-version
or --ignore-deps
argument. Additionally added boot.py
and main.py
files in package.json
can be ignored using --ignore-boot-main
during a validation run.
Createο
Create package JSON fileο
The following command creates a package.json
file in the same directory as
the specified setup.py
file. The content of the package.json
file is
additionally printed to stdout (--print
) with an indentation of 4 (due to
the --pretty
option)
upy-package \
--setup_file tests/data/setup.py \
--createΒ \
--print \
--pretty
Create specific package JSON fileο
A specific package JSON file can be specified with the --package_file
parameter. The file has to exist before running the command.
upy-package \
--setup_file tests/data/setup.py \
--package_file tests/data/custom-package.json \
--createΒ \
--print \
--pretty
Create package JSON file from changelogο
In case the package version is defined by a changelog and the version
entry
of the setup.py
file is filled on demand by e.g.
changelog2version, the semantic version changelog can
be specified explicitly to use its latest entry for the version value.
upy-package \
--setup_file tests/data/setup.py \
--package_changelog_file tests/data/sample_changelog.md \
--createΒ \
--print \
--pretty
Contributingο
Unittestsο
Run the unittests locally with the following command after installing this package in a virtual environment
# run all tests
nose2 --config tests/unittest.cfg
# run only one specific tests
nose2 tests.test_setup2upypackage.TestSetup2uPyPackage.test_package_version
Generate the coverage files with
python create_report_dirs.py
coverage html
The coverage report is placed at reports/coverage/html/index.html
Precommit hooksο
This repo is equipped with a .pre-commit-hooks.yaml
file to be usable in
other repos.
In order to run this repoβs pre commit hooks, perform the following steps
pip install pre-commit
# for older systems without colored output support, last supported version is
# 1.18.3 (7c3404ef1f7593094c854f99bcd3b3eec75fbb2f, 1.19.0 broke it)
# test it with:
# from os import openpty
# r,w = openpty()
pre-commit run --all-files
Creditsο
Based on the PyPa sample project.