build(py): add target that publishes to PyPI (#2172)

Add a Bazel target `//python/tflite_micro:whl.publish` that publishes the
Python distribution package to PyPI. Require an authorization token in
the environment. See code comments for usage.

BUG=part of #1484
This commit is contained in:
Ryan Kuester 2023-08-16 19:22:13 -05:00 committed by GitHub
parent 704d3070be
commit 3bd11ea33b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 198 additions and 10 deletions

View file

@ -169,6 +169,13 @@ expand_stamp_vars(
py_wheel(
name = "whl",
# This macro yields additional targets:
#
# - whl.publish: publish the package to PyPI via a command like:
#
# TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-*** \
# bazel run //python/tflite_micro:whl.publish -- --repository testpypi
#
description_file = ":description_file",
distribution = "tflite_micro",
requires = [
@ -179,6 +186,7 @@ py_wheel(
stamp = 1, # 1 == always stamp
strip_path_prefixes = [package_name()],
summary = "TensorFlow Lite for Microcontrollers",
twine = "@tflm_pip_deps_twine//:pkg",
version = "{BUILD_EMBED_LABEL}.dev{STABLE_GIT_COMMIT_TIME}",
deps = [
":namespace",