Skip to content
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
14 changes: 14 additions & 0 deletions .github/workflows/test_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,17 @@ jobs:
pure_python_wheel: true
test_extras: recommended
test_command: python -c 'import test_package'

custom_source_directory:
name: Test action (custom source-directory)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- id: build
uses: ./
with:
source-directory: packages/subpackage
pure_python_wheel: true
test_extras: test
test_command: pytest --pyargs subpackage
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@ jobs:
test_command: pytest --pyargs test_package
```

## Custom source directory

By default, the action builds from the repository root. If your package is in a
subdirectory (e.g., in a monorepo or non-standard project layout), use the
`source-directory` input:

```yaml
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:
source-directory: packages/my-package
test_command: pytest --pyargs my_package
```

## Custom Python version

By default, the [`actions/setup-python`](https://github.com/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,
Expand Down
9 changes: 7 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ inputs:
required: false
default: '3.x'
type: string
source-directory:
description: The directory containing the package to build, relative to the repository root
required: false
default: '.'
type: string
runs:
using: "composite"
steps:
Expand All @@ -47,7 +52,7 @@ runs:

- name: Build source distribution
shell: bash
run: python -m build --sdist .
run: python -m build --sdist --outdir dist ${{ inputs.source-directory }}

- name: Create and activate a virtual environment
shell: bash
Expand Down Expand Up @@ -80,7 +85,7 @@ runs:

- name: Build pure Python wheel distribution
shell: bash
run: python -m build --wheel .
run: python -m build --wheel --outdir dist ${{ inputs.source-directory }}
if: ${{ inputs.pure_python_wheel == 'true' }}

- name: Verify that one pure Python wheel was built
Expand Down
19 changes: 19 additions & 0 deletions packages/subpackage/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[project]
name = "subpackage"
version = "0.1.0"

[project.optional-dependencies]
test = ["pytest"]

[dependency-groups]
test = ["pytest>=8.0.0"]

[tool.setuptools]
include-package-data = false

[tool.setuptools.packages]
find = {namespaces = false}
1 change: 1 addition & 0 deletions packages/subpackage/subpackage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
Empty file.
3 changes: 3 additions & 0 deletions packages/subpackage/subpackage/tests/test_subpackage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_import():
import subpackage
assert subpackage.__version__ == "0.1.0"