Giter VIP home page Giter VIP logo

micropython-package-validation's Introduction

MicroPython Package Validation

Downloads Release Python License: MIT codecov CI

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.

micropython-package-validation's People

Contributors

brainelectronics avatar

Watchers

 avatar

micropython-package-validation's Issues

Add option to skip deps check

As not only packages of the MicroPython package index can be added as dependencies to the package.json file, the comparision with the setup.py file might fail.

In some cases it is necessary to set a custom (GitHub) package in the package.json file, as the official PyPI can't be used as of now, see micropython/micropython-lib#632

Add option to ignore package versions during check

Running the package validation on packages with automated version updates/tagging based on the changelog, the check could fail if the version of package.json is not updated as well.
While updating package.json and the changelog brings the benefit of a synced version, finally the only single source of truth should be one file, the changelog. Furthermore mip does currently not take the version parameter of package.json into account.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.