From c60dbfdef07ee2b31e25a314dbf53209498e2387 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 23 Dec 2024 08:09:17 +0000 Subject: [PATCH 1/3] get version using project metadata --- .github/workflows/ci.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6f31c1064..69c939cac9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,14 +40,19 @@ jobs: with: persist-credentials: false + - name: Install build + 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 @@ -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 - name: Verify that the artifacts with expected names got created From b63587a8356c2088a38de2b95da8d8b6f092ea3e Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 23 Dec 2024 08:12:35 +0000 Subject: [PATCH 2/3] use contraints file for build --- .github/workflows/ci.yml | 2 +- ci.sh | 2 +- test-requirements.in | 1 + test-requirements.txt | 17 +++++++++++++---- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69c939cac9..0e2d32f51e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: persist-credentials: false - name: Install build - run: python -Im pip install build + run: python -Im pip install build -c test-requirements.txt - name: Get the dist version id: dist-version diff --git a/ci.sh b/ci.sh index 83ec65748b..5138c2da48 100755 --- a/ci.sh +++ b/ci.sh @@ -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 python -m build wheel_package=$(ls dist/*.whl) diff --git a/test-requirements.in b/test-requirements.in index 809e171e3b..b578ca825a 100644 --- a/test-requirements.in +++ b/test-requirements.in @@ -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" diff --git a/test-requirements.txt b/test-requirements.txt index 87b3c581eb..b5afa84923 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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' @@ -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 @@ -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 @@ -87,6 +92,7 @@ outcome==1.3.0.post0 packaging==24.2 # via # black + # build # pytest # sphinx parso==0.8.4 ; implementation_name == 'cpython' @@ -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 @@ -138,6 +146,7 @@ sphinxcontrib-serializinghtml==2.0.0 tomli==2.2.1 ; python_full_version < '3.11' # via # black + # build # mypy # pylint # pytest @@ -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 From 90f2b75ccf2fe009328ab18e15517b36d0a27f05 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 23 Dec 2024 08:37:19 +0000 Subject: [PATCH 3/3] fix version parsing --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e2d32f51e..8252a9fc6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: run: | import os import build.util - version = build.util.project_wheel_metadata(".").version + version = build.util.project_wheel_metadata(".")["version"] with open(os.environ["GITHUB_OUTPUT"], mode="a", encoding="utf8") as f: f.write(f"version={version}")