# MicroPython Package Validation
[![Downloads](https://pepy.tech/badge/micropython-package-validation)](https://pepy.tech/project/micropython-package-validation)
![Release](https://img.shields.io/github/v/release/brainelectronics/micropython-package-validation?include_prereleases&color=success)
![Python](https://img.shields.io/badge/python3-Ok-green.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![codecov](https://codecov.io/github/brainelectronics/micropython-package-validation/branch/main/graph/badge.svg)](https://app.codecov.io/github/brainelectronics/micropython-package-validation)
[![CI](https://github.com/brainelectronics/micropython-package-validation/actions/workflows/release.yml/badge.svg)](https://github.com/brainelectronics/micropython-package-validation/actions/workflows/release.yml)
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][ref-rtd-micropython-package-validation] 📚
<!-- MarkdownTOC -->
- [Installation](#installation)
- [Install required tools](#install-required-tools)
- [Installation](#installation-1)
- [Usage](#usage)
- [Validate](#validate)
- [Validate package JSON file](#validate-package-json-file)
- [Validate package JSON file from changelog](#validate-package-json-file-from-changelog)
- [Options](#options)
- [Create](#create)
- [Create package JSON file](#create-package-json-file)
- [Create specific package JSON file](#create-specific-package-json-file)
- [Create package JSON file from changelog](#create-package-json-file-from-changelog)
- [Contributing](#contributing)
- [Unittests](#unittests)
- [Precommit hooks](#precommit-hooks)
- [Credits](#credits)
<!-- /MarkdownTOC -->
## Installation
### Install required tools
Python3 must be installed on your system. Check the current Python version
with the following command
```bash
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.
```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```
## Installation
```bash
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.
```bash
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][ref-changelog2version], the semantic version changelog can
be specified explicitly to use its latest entry for the version value.
```bash
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)
```bash
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.
```bash
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][ref-changelog2version], the semantic version changelog can
be specified explicitly to use its latest entry for the version value.
```bash
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
```bash
# 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
```bash
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
```bash
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][ref-pypa-sample].
<!-- Links -->
[ref-rtd-micropython-package-validation]: https://micropython-package-validation.readthedocs.io/en/latest/
[ref-pypa-sample]: https://github.com/pypa/sampleproject
[ref-changelog2version]: https://github.com/brainelectronics/changelog2version
Raw data
{
"_id": null,
"home_page": "https://github.com/brainelectronics/micropython-package-validation",
"name": "setup2upypackage",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7, <4",
"maintainer_email": "",
"keywords": "micropython,package,mip-helper,validation",
"author": "brainelectronics",
"author_email": "info@brainelectronics.de",
"download_url": "https://files.pythonhosted.org/packages/fc/8e/33bd31d0f4d3f03e3b9d7008f8c202c8be935c28ba852f725ee44132342c/setup2upypackage-0.5.0.tar.gz",
"platform": null,
"description": "# MicroPython Package Validation\n\n[![Downloads](https://pepy.tech/badge/micropython-package-validation)](https://pepy.tech/project/micropython-package-validation)\n![Release](https://img.shields.io/github/v/release/brainelectronics/micropython-package-validation?include_prereleases&color=success)\n![Python](https://img.shields.io/badge/python3-Ok-green.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/github/brainelectronics/micropython-package-validation/branch/main/graph/badge.svg)](https://app.codecov.io/github/brainelectronics/micropython-package-validation)\n[![CI](https://github.com/brainelectronics/micropython-package-validation/actions/workflows/release.yml/badge.svg)](https://github.com/brainelectronics/micropython-package-validation/actions/workflows/release.yml)\n\nValidate and create MicroPython package JSON file\n\n---------------\n\n## General\n\nMicroPython Package Validation for mip package.json files\n\n\ud83d\udcda The latest documentation is available at\n[MicroPython Package Validation ReadTheDocs][ref-rtd-micropython-package-validation] \ud83d\udcda\n\n<!-- MarkdownTOC -->\n\n- [Installation](#installation)\n - [Install required tools](#install-required-tools)\n- [Installation](#installation-1)\n- [Usage](#usage)\n - [Validate](#validate)\n - [Validate package JSON file](#validate-package-json-file)\n - [Validate package JSON file from changelog](#validate-package-json-file-from-changelog)\n - [Options](#options)\n - [Create](#create)\n - [Create package JSON file](#create-package-json-file)\n - [Create specific package JSON file](#create-specific-package-json-file)\n - [Create package JSON file from changelog](#create-package-json-file-from-changelog)\n- [Contributing](#contributing)\n - [Unittests](#unittests)\n - [Precommit hooks](#precommit-hooks)\n- [Credits](#credits)\n\n<!-- /MarkdownTOC -->\n\n## Installation\n\n### Install required tools\n\nPython3 must be installed on your system. Check the current Python version\nwith the following command\n\n```bash\npython --version\npython3 --version\n```\n\nDepending on which command `Python 3.x.y` (with x.y as some numbers) is\nreturned, use that command to proceed.\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate\n\npip install -r requirements.txt\n```\n\n## Installation\n\n```bash\npip install setup2upypackage\n```\n\n## Usage\n\n### Validate\n#### Validate package JSON file\n\nThe following command will exit with a non-zero code in case of a difference\nbetween the generated (based on `setup.py`) and existing package\n(`package.json`) content.\n\n```bash\nupy-package \\\n --setup_file tests/data/setup.py \\\n --package_changelog_file tests/data/sample_changelog.md \\\n --package_file tests/data/package.json \\\n --validate\n```\n\n#### Validate package JSON file from changelog\n\nIn case the package version is defined by a changelog and the `version` entry\nof the `setup.py` file is filled on demand by e.g.\n[changelog2version][ref-changelog2version], the semantic version changelog can\nbe specified explicitly to use its latest entry for the version value.\n\n```bash\nupy-package \\\n --setup_file tests/data/setup.py \\\n --package_changelog_file tests/data/sample_changelog.md \\\n --package_file tests/data/package.json \\\n --validate\n```\n\n#### Options\n\nTo not take the version or the dependencies specified in the `package.json`\nfile during a validation run, use the `--ignore-version` or `--ignore-deps`\nargument. Additionally added `boot.py` and `main.py` files in `package.json`\ncan be ignored using `--ignore-boot-main` during a validation run.\n\n### Create\n#### Create package JSON file\n\nThe following command creates a `package.json` file in the same directory as\nthe specified `setup.py` file. The content of the `package.json` file is\nadditionally printed to stdout (`--print`) with an indentation of 4 (due to\nthe `--pretty` option)\n\n```bash\nupy-package \\\n --setup_file tests/data/setup.py \\\n --create\u00a0\\\n --print \\\n --pretty\n```\n\n##### Create specific package JSON file\n\nA specific package JSON file can be specified with the `--package_file`\nparameter. The file has to exist before running the command.\n\n```bash\nupy-package \\\n --setup_file tests/data/setup.py \\\n --package_file tests/data/custom-package.json \\\n --create\u00a0\\\n --print \\\n --pretty\n```\n\n#### Create package JSON file from changelog\n\nIn case the package version is defined by a changelog and the `version` entry\nof the `setup.py` file is filled on demand by e.g.\n[changelog2version][ref-changelog2version], the semantic version changelog can\nbe specified explicitly to use its latest entry for the version value.\n\n```bash\nupy-package \\\n --setup_file tests/data/setup.py \\\n --package_changelog_file tests/data/sample_changelog.md \\\n --create\u00a0\\\n --print \\\n --pretty\n```\n\n## Contributing\n\n### Unittests\n\nRun the unittests locally with the following command after installing this\npackage in a virtual environment\n\n```bash\n# run all tests\nnose2 --config tests/unittest.cfg\n\n# run only one specific tests\nnose2 tests.test_setup2upypackage.TestSetup2uPyPackage.test_package_version\n```\n\nGenerate the coverage files with\n\n```bash\npython create_report_dirs.py\ncoverage html\n```\n\nThe coverage report is placed at `reports/coverage/html/index.html`\n\n### Precommit hooks\n\nThis repo is equipped with a `.pre-commit-hooks.yaml` file to be usable in\nother repos.\n\nIn order to run this repo's pre commit hooks, perform the following steps\n\n```bash\npip install pre-commit\n# for older systems without colored output support, last supported version is\n# 1.18.3 (7c3404ef1f7593094c854f99bcd3b3eec75fbb2f, 1.19.0 broke it)\n# test it with:\n# from os import openpty\n# r,w = openpty()\n\npre-commit run --all-files\n```\n\n## Credits\n\nBased on the [PyPa sample project][ref-pypa-sample].\n\n<!-- Links -->\n[ref-rtd-micropython-package-validation]: https://micropython-package-validation.readthedocs.io/en/latest/\n[ref-pypa-sample]: https://github.com/pypa/sampleproject\n[ref-changelog2version]: https://github.com/brainelectronics/changelog2version\n",
"bugtrack_url": null,
"license": "",
"summary": "Validate and create MicroPython package JSON file",
"version": "0.5.0",
"project_urls": {
"Bug Reports": "https://github.com/brainelectronics/micropython-package-validation/issues",
"Homepage": "https://github.com/brainelectronics/micropython-package-validation",
"Source": "https://github.com/brainelectronics/micropython-package-validation/"
},
"split_keywords": [
"micropython",
"package",
"mip-helper",
"validation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fe5b93ba9e5bcbb1bb7c18f280612acb7664557e2ed782539df7f7ee274a2101",
"md5": "800c52245d02f443bd5c86dfbaf4c602",
"sha256": "28730b89c311fd5d6ee62b811ff563e30bcf139dc5876d53cf112a2a7e431b0a"
},
"downloads": -1,
"filename": "setup2upypackage-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "800c52245d02f443bd5c86dfbaf4c602",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7, <4",
"size": 10348,
"upload_time": "2023-07-05T21:02:49",
"upload_time_iso_8601": "2023-07-05T21:02:49.007314Z",
"url": "https://files.pythonhosted.org/packages/fe/5b/93ba9e5bcbb1bb7c18f280612acb7664557e2ed782539df7f7ee274a2101/setup2upypackage-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fc8e33bd31d0f4d3f03e3b9d7008f8c202c8be935c28ba852f725ee44132342c",
"md5": "9c05d4676ee07afee1d28be6b692c9ce",
"sha256": "c89e758107926eab54e8cfbcbc38963059cda4a18083b9373ef2f223943b6c57"
},
"downloads": -1,
"filename": "setup2upypackage-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "9c05d4676ee07afee1d28be6b692c9ce",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7, <4",
"size": 17314,
"upload_time": "2023-07-05T21:02:50",
"upload_time_iso_8601": "2023-07-05T21:02:50.401884Z",
"url": "https://files.pythonhosted.org/packages/fc/8e/33bd31d0f4d3f03e3b9d7008f8c202c8be935c28ba852f725ee44132342c/setup2upypackage-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-05 21:02:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "brainelectronics",
"github_project": "micropython-package-validation",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "setup2upypackage"
}