Skip to content

mpremote: Use hatch to build mpremote package. #10645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/mpremote.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Package mpremote

on:
push:
pull_request:
paths:
- '.github/workflows/*.yml'
- 'tools/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# Version is determined from git,
# should be deep enough to get to latest tag
fetch-depth: '1000'
- run: |
git fetch --prune --unshallow --tags
- uses: actions/setup-python@v1
- name: Install build tools
run: pip install build
- name: Build mpremote wheel
run: cd tools/mpremote && python -m build --wheel
- name: Archive mpremote wheel
uses: actions/upload-artifact@v2
with:
name: mpremote
path: |
tools/mpremote/dist/mpremote*.whl
1 change: 1 addition & 0 deletions tools/mpremote/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
13 changes: 12 additions & 1 deletion tools/mpremote/mpremote/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
__version__ = "0.4.0"
try:
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version("mpremote")
except PackageNotFoundError:
# Error loading package version (e.g. running from source).
__version__ = "0.0.0-local"
except ImportError:
# importlib.metadata not available (e.g. CPython <3.8 without
# importlib_metadata compatibility package installed).
__version__ = "0.0.0-unknown"
54 changes: 51 additions & 3 deletions tools/mpremote/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
"hatchling",
"hatch-requirements-txt",
"hatch-vcs",
]
build-backend = "setuptools.build_meta"
build-backend = "hatchling.build"

[project]
name = "mpremote"
description = "Tool for interacting remotely with MicroPython devices"
readme = "README.md"
authors = [
{name = "Damien George", email = "damien@micropython.org"},
]
urls = {Homepage = "https://github.com/micropython/micropython"}
keywords = [
"hardware",
"micropython",
]
license = {text = "MIT"}
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Embedded Systems",
"Topic :: System :: Hardware",
]
requires-python = ">=3.4"
dynamic = ["dependencies", "version"]

[project.scripts]
mpremote = "mpremote.main:main"

[tool.hatch.metadata.hooks.requirements_txt]
files = ["requirements.txt"]

[tool.hatch.version]
source = "vcs"
tag-pattern = "(?P<version>v(\\d+).(\\d+).(\\d+))"
raw-options = { root = "../..", version_scheme = "post-release" }

[tool.hatch.build]
packages = ["mpremote"]

# Also grab pyboard.py from /tools and add it to the package for both wheel and sdist.
[tool.hatch.build.force-include]
"../pyboard.py" = "mpremote/pyboard.py"

# Workaround to allow `python -m build` to work.
[tool.hatch.build.targets.sdist.force-include]
"../pyboard.py" = "mpremote/pyboard.py"
"requirements.txt" = "requirements.txt"
2 changes: 2 additions & 0 deletions tools/mpremote/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pyserial >= 3.3
importlib_metadata >= 1.4
25 changes: 0 additions & 25 deletions tools/mpremote/setup.cfg

This file was deleted.