Skip to content

Commit 8c82c2f

Browse files
Merge pull request #21 from neutrinoceros/enh/pep735-support
2 parents 88c00a7 + 1f2891e commit 8c82c2f

File tree

5 files changed

+67
-26
lines changed

5 files changed

+67
-26
lines changed

.github/workflows/test_action.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,27 @@ on:
77
jobs:
88
build_pure:
99
name: Test action (pure wheel)
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-latest
1111

1212
steps:
1313
- uses: actions/checkout@v4
1414
- id: build
1515
uses: ./
1616
with:
1717
pure_python_wheel: true
18-
test_extras: test
18+
test_groups: test, concurrency
19+
test_extras: recommended
1920
test_command: pytest --pyargs test_package
2021
build_non_pure:
2122
name: Test action (not pure wheel)
22-
runs-on: ubuntu-20.04
23+
runs-on: ubuntu-latest
2324

2425
steps:
2526
- uses: actions/checkout@v4
2627
- id: build_not_pure
2728
uses: ./
2829
with:
2930
pure_python_wheel: "false"
30-
test_extras: test
31+
test_groups: test
32+
test_extras: recommended
3133
test_command: pytest --pyargs test_package

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,19 @@ jobs:
3636
- id: build
3737
uses: OpenAstronomy/build-python-dist@v1
3838
with:
39-
test_extras: test
39+
test_groups: test
40+
test_extras: recommended
4041
test_command: pytest --pyargs test_package
4142
```
4243
43-
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).
44+
The ``test_groups`` option, if specified, should contain a comma-separated list
45+
of [PEP 735 Dependency Groups](https://peps.python.org/pep-0735/) that should be
46+
installed when testing (e.g. ``test``, or ``test, concurrency`` ...).
47+
Similarily, the ``test_extras`` option specifies optional dependencies
48+
(e.g. ``recommended`` or ``recommended, plotting``) that will be used to determine
49+
which 'extras' should be installed when testing. The ``test_command`` option
50+
should contain the full command to use for testing the installed package (this
51+
is run from an empty temporary directory).
4452
4553
### Build a source distribution and wheel for a pure-Python package
4654
@@ -55,7 +63,8 @@ jobs:
5563
uses: OpenAstronomy/build-python-dist@v1
5664
with:
5765
pure_python_wheel: true
58-
test_extras: test
66+
test_groups: test
67+
test_extras: recommended
5968
test_command: pytest --pyargs test_package
6069
```
6170
@@ -73,7 +82,8 @@ jobs:
7382
- id: build
7483
uses: OpenAstronomy/build-python-dist@v1
7584
with:
76-
test_extras: test
85+
test_groups: test
86+
test_extras: recommended
7787
test_command: pytest --pyargs test_package
7888
python-version: '3.9'
7989
```

action.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ branding:
44
icon: package
55
color: blue
66
inputs:
7+
test_groups:
8+
description: Comma-separated PEP 735 dependency groups that should be installed for testing
9+
required: false
10+
default: ''
11+
type: string
712
test_extras:
813
description: Any extras_requires modifier that should be used to install the package for testing
914
required: false
@@ -44,24 +49,30 @@ runs:
4449
shell: bash
4550
run: python -m build --sdist .
4651

47-
- name: Test source distribution
52+
- name: Create and activate a virtual environment
4853
shell: bash
4954
run: |
5055
python -m venv test-sdist
5156
source test-sdist/bin/activate
5257
which python
53-
python -m pip install --force-reinstall `find dist -name "*.tar.gz"`[${{ inputs.test_extras }}]
58+
59+
- name: Parse dependency groups
60+
shell: bash
61+
run: |
62+
echo "group_flags=$( python -c "print(' '.join(f'--group {g.strip()}' for g in '${{ inputs.test_groups }}'.split(',')))" ) " >> "$GITHUB_ENV"
63+
64+
- name: Test source distribution
65+
shell: bash
66+
run: |
67+
python -m pip install --force-reinstall `find dist -name "*.tar.gz"`[${{ inputs.test_extras }}] $group_flags
5468
cd ${{ runner.temp }}
5569
${{ inputs.test_command }}
5670
if: ${{ inputs.test_command != '' && inputs.test_extras != '' }}
5771

5872
- name: Test source distribution
5973
shell: bash
6074
run: |
61-
python -m venv test-sdist
62-
source test-sdist/bin/activate
63-
which python
64-
python -m pip install --force-reinstall `find dist -name "*.tar.gz"`
75+
python -m pip install --force-reinstall `find dist -name "*.tar.gz"` $group_flags
6576
cd ${{ runner.temp }}
6677
${{ inputs.test_command }}
6778
if: ${{ inputs.test_command != '' && inputs.test_extras == '' }}

pyproject.toml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
[build-system]
2-
requires = ["setuptools>=43.0.0",
3-
"wheel"]
4-
build-backend = 'setuptools.build_meta'
2+
requires = ["setuptools>=61.2"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "test-package"
7+
dynamic = ["version"]
8+
9+
[project.optional-dependencies]
10+
recommended = [
11+
# use small, pure-Python, extremely popular packages
12+
"boto3",
13+
"urllib3",
14+
]
15+
16+
[dependency-groups]
17+
concurrency = [
18+
{include-group = "test"},
19+
"pytest-repeat",
20+
"pytest-run-parallel",
21+
]
22+
test = [
23+
"hypothesis>=6.135.14",
24+
"pytest>=8.4.1",
25+
]
26+
27+
[tool.setuptools]
28+
include-package-data = false
29+
30+
[tool.setuptools.packages]
31+
find = {namespaces = false}

setup.cfg

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)