GitHub Action
Build Python Source and Wheel Distributions
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.
jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: build
uses: OpenAstronomy/build-python-dist@v1
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).
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
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'
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
.