Skip to content

Build Python Source and Wheel Distributions

Actions
Build source distribution for any Python package and wheels for Python packages without extensions
v1.0.1
Latest
Star (2)

build-python-dist

.github/workflows/main.yml

A GitHub action to build and test a source distribution for a Python package, and optionally a wheel for pure Python packages.

To build wheels for packages with extensions, you should instead use cibuildwheel which also includes a GitHub action for convenience.

Examples

Build a source distribution with no testing:

jobs:
  build_sdist:
    name: Build source distribution
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - id: build
        uses: OpenAstronomy/build-python-dist@v1

Build a source distribution with testing

jobs:
  build_sdist:
    name: Build source distribution
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - id: build
        uses: OpenAstronomy/build-python-dist@v1
        with:
          test_extras: test
          test_command: pytest --pyargs test_package

The test_extras option, if specified, should contain a string (e.g. test or test,all) that will be used to determine which 'extras' should be installed when testing. The test_command option should contain the full command to use for testing the installed package (this is run from an empty temporary directory).

Build a source distribution and wheel for a pure-Python package

jobs:
  build_sdist_and_wheel:
    name: Build source distribution and pure-Python wheel
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - id: build
        uses: OpenAstronomy/build-python-dist@v1
        with:
          pure_python_wheel: true
          test_extras: test
          test_command: pytest --pyargs test_package

Custom Python version

By default, the actions/setup-python action will install the latest Python 3 version for building and testing, however, the OpenAstronomy/build-python-dist action accepts a python-version string input to select a specific version,

jobs:
  build_sdist:
    name: Build source distribution
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - id: build
        uses: OpenAstronomy/build-python-dist@v1
        with:
          test_extras: test
          test_command: pytest --pyargs test_package
          python-version: '3.9'

Notes

If you want to use the latest available version of this action instead of hard-coding a specific version, you can replace OpenAstronomy/build-python-dist@v1 by OpenAstronomy/build-python-dist@main.

Build Python Source and Wheel Distributions is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Build source distribution for any Python package and wheels for Python packages without extensions
v1.0.1
Latest

Build Python Source and Wheel Distributions is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.