cmarqu / build-and-inspect-python-package

Build and Inspect Python Packages in Your CI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build-and-inspect-python-package

This action provides the following functionality for GitHub Actions users that are maintaining Python packages:

Builds your package using PyPA's build (this works with any PEP 517-compatible build backend, including Hatch, Flit, Setuptools, PDM, or Poetry). SOURCE_DATE_EPOCH is set to the timestamp of the last commit, giving you reproducible builds with meaningful file timestamps.

Uploads the built wheel and the source distribution (SDist) as GitHub Actions artifacts, so you can download and inspect them from the Summary view of a run, or upload them to PyPI automatically once the verification succeeds.

Lints the wheel contents using check-wheel-contents.

Lints the PyPI README using Twine and uploads it as an GitHub Actions artifact for further inspection. To level up your PyPI README game, check out hatch-fancy-pypi-readme!

Prints the tree of both SDist and wheel in the CI output, so you don't have to download the packages, if you just want to check the content list.

Prints and uploads the packaging metadata as a GitHub Actions artifact.


If you package an application as a Python package, this action is useful to double-check you're shipping everything you need, including all templates, translation files, et cetera.

Usage

jobs:
  check-package:
    name: Build & inspect our package.
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - uses: hynek/build-and-inspect-python-package@v1

Inputs

  • path: the location of the Python package to build (optional, default: .).

Outputs

  • dist: the location with the built packages.

    See for example how argon2-cffi-bindings uses this feature to check the built wheels don't break a dependency.

Artifacts

After a successful run, you'll find multiple artifacts in the run's Summary view:

  • Packages: The built packages. Perfect for automated PyPI upload workflows!
  • Package Metadata: the extracted packaging metadata (hint: it's formatted as an email).
  • PyPI README: the extracted PyPI README, exactly how it would be used by PyPI as your project's landing page. PEP 621 calls it readme, in classic setuptools it's long_description.

Our CI uses all inputs and outputs, if you want to see them in action.

License

The scripts and documentation in this project are released under the MIT License.

About

Build and Inspect Python Packages in Your CI

License:MIT License