Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use constraints file for sdist/wheel build + get version using build.util #3167

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 11 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,19 @@ jobs:
with:
persist-credentials: false

- name: Install build
run: python -Im pip install build -c test-requirements.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would leak into the underlying PEP 517 ephemeral build envs.

Suggested change
run: python -Im pip install build -c test-requirements.txt
env:
PIP_CONSTRAINT: test-requirements.txt
run: python -Im pip install build


- name: Get the dist version
id: dist-version
run: >-
echo "version=$(
grep ^__version__ src/trio/_version.py
| sed 's#__version__ = "\([^"]\+\)"#\1#'
)"
>> "${GITHUB_OUTPUT}"
shell: python
run: |
import os
import build.util
version = build.util.project_wheel_metadata(".")["version"]

with open(os.environ["GITHUB_OUTPUT"], mode="a", encoding="utf8") as f:
f.write(f"version={version}")

- name: Set the expected dist artifact names
id: artifact-name
Expand All @@ -58,9 +63,6 @@ jobs:
DIST_NAME: ${{ env.dist-name }}
VERSION: ${{ steps.dist-version.outputs.version }}

- name: Install build
run: python -Im pip install build

- name: Build dists
run: python -Im build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming, you'll do something like pip-compile --only-build-deps --output-file=build-requirements.txt pyproject.toml:

Suggested change
run: python -Im build
env:
PIP_CONSTRAINT: build-requirements.txt
run: python -Im build

- name: Verify that the artifacts with expected names got created
Expand Down
2 changes: 1 addition & 1 deletion ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ python -m pip install -U pip uv -c test-requirements.txt
python -m pip --version
python -m uv --version

python -m uv pip install build
python -m uv pip install build -c test-requirements.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also use an env var:

Suggested change
python -m uv pip install build -c test-requirements.txt
PIP_CONSTRAINT=test-requirements.txt python -m uv pip install build


python -m build
wheel_package=$(ls dist/*.whl)
Expand Down
1 change: 1 addition & 0 deletions test-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jedi; implementation_name == "cpython" # for jedi code completi
cryptography>=41.0.0 # cryptography<41 segfaults on pypy3.10

# Tools
build
black; implementation_name == "cpython"
mypy # Would use mypy[faster-cache], but orjson has build issues on pypy
orjson; implementation_name == "cpython"
Expand Down
17 changes: 13 additions & 4 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ babel==2.16.0
# via sphinx
black==24.10.0 ; implementation_name == 'cpython'
# via -r test-requirements.in
build==1.2.2.post1
# via -r test-requirements.in
certifi==2024.8.30
# via requests
cffi==1.17.1 ; platform_python_implementation != 'PyPy' or os_name == 'nt'
Expand All @@ -28,8 +30,9 @@ click==8.1.7 ; implementation_name == 'cpython'
# via black
codespell==2.3.0
# via -r test-requirements.in
colorama==0.4.6 ; (implementation_name != 'cpython' and sys_platform == 'win32') or (platform_system != 'Windows' and sys_platform == 'win32') or (implementation_name == 'cpython' and platform_system == 'Windows')
colorama==0.4.6 ; (implementation_name != 'cpython' and sys_platform == 'win32') or (platform_system != 'Windows' and sys_platform == 'win32') or (implementation_name == 'cpython' and platform_system == 'Windows') or os_name == 'nt'
# via
# build
# click
# pylint
# pytest
Expand Down Expand Up @@ -57,8 +60,10 @@ idna==3.10
# trustme
imagesize==1.4.1
# via sphinx
importlib-metadata==8.5.0 ; python_full_version < '3.10'
# via sphinx
importlib-metadata==8.5.0 ; python_full_version < '3.10.2'
# via
# build
# sphinx
iniconfig==2.0.0
# via pytest
isort==5.13.2
Expand Down Expand Up @@ -87,6 +92,7 @@ outcome==1.3.0.post0
packaging==24.2
# via
# black
# build
# pytest
# sphinx
parso==0.8.4 ; implementation_name == 'cpython'
Expand All @@ -107,6 +113,8 @@ pylint==3.3.1
# via -r test-requirements.in
pyopenssl==24.2.1
# via -r test-requirements.in
pyproject-hooks==1.2.0
# via build
pyright==1.1.389
# via -r test-requirements.in
pytest==8.3.3
Expand Down Expand Up @@ -138,6 +146,7 @@ sphinxcontrib-serializinghtml==2.0.0
tomli==2.2.1 ; python_full_version < '3.11'
# via
# black
# build
# mypy
# pylint
# pytest
Expand Down Expand Up @@ -168,5 +177,5 @@ urllib3==2.2.3
# via requests
uv==0.5.5
# via -r test-requirements.in
zipp==3.21.0 ; python_full_version < '3.10'
zipp==3.21.0 ; python_full_version < '3.10.2'
# via importlib-metadata
Loading