From 889b9534cb7046f85b6fc2ddbd846df14d2c9fc9 Mon Sep 17 00:00:00 2001 From: David Leong <116610336+leongdl@users.noreply.github.com> Date: Wed, 16 Sep 2026 13:24:02 -0700 Subject: [PATCH] fix: Exclude broken hatchling 1.32.1 from isolated build envs hatchling 1.32.1 imports `hatch`, which is absent from the isolated build environment `hatch build` creates, so every build fails with ModuleNotFoundError (pypa/hatch#2427). The release has been yanked, so unpinned resolution already skips it; this makes the exclusion explicit in the four reusable workflows that run `hatch build`. Same intent as aws-deadline/deadline-cloud#1359, which excluded 1.32.1 in pyproject.toml build-system.requires. Reusable workflows cannot edit the calling repo's pyproject.toml, so the exclusion is applied as a constraint file instead. Measured with hatch 1.16.4: the build env is installed by uv and honours UV_CONSTRAINT (a `hatchling==1.31.0` constraint changed the installed version; the same file via PIP_CONSTRAINT did not), so both variables are set to cover either installer. A `hatchling!=1.32.1` pin on the `pip install hatch` line alone would only reach the CLI environment. The Install Hatch step in reusable_python_build.yml is forced to bash because that job also runs on windows-latest, where the default pwsh shell would not evaluate the POSIX redirection. Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com> --- .github/workflows/reusable_prerelease.yml | 5 +++++ .github/workflows/reusable_publish.yml | 12 ++++++++++++ .github/workflows/reusable_python_build.yml | 15 +++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/.github/workflows/reusable_prerelease.yml b/.github/workflows/reusable_prerelease.yml index 9c3d701..21a053c 100644 --- a/.github/workflows/reusable_prerelease.yml +++ b/.github/workflows/reusable_prerelease.yml @@ -26,6 +26,11 @@ jobs: - name: Build run: | pip install --upgrade hatch "click<8.3" "virtualenv<21" + # Keep hatchling 1.32.1 out of the isolated build env (pypa/hatch#2427). + # See reusable_python_build.yml for why the pin must be a constraint. + echo 'hatchling!=1.32.1' > "$RUNNER_TEMP/build-constraints.txt" + export UV_CONSTRAINT="$RUNNER_TEMP/build-constraints.txt" + export PIP_CONSTRAINT="$RUNNER_TEMP/build-constraints.txt" hatch -v build - name: UploadArtifacts diff --git a/.github/workflows/reusable_publish.yml b/.github/workflows/reusable_publish.yml index cb5244f..3a1cb34 100644 --- a/.github/workflows/reusable_publish.yml +++ b/.github/workflows/reusable_publish.yml @@ -79,6 +79,11 @@ jobs: - name: Build run: | pip install --upgrade hatch "click<8.3" "virtualenv<21" + # Keep hatchling 1.32.1 out of the isolated build env (pypa/hatch#2427). + # See reusable_python_build.yml for why the pin must be a constraint. + echo 'hatchling!=1.32.1' > "$RUNNER_TEMP/build-constraints.txt" + export UV_CONSTRAINT="$RUNNER_TEMP/build-constraints.txt" + export PIP_CONSTRAINT="$RUNNER_TEMP/build-constraints.txt" hatch -v build - name: Configure AWS credentials @@ -168,6 +173,13 @@ jobs: run: | pip install --upgrade hatch "click<8.3" "virtualenv<21" pip install --upgrade twine + # Keep hatchling 1.32.1 out of the isolated build env (pypa/hatch#2427). + # See reusable_python_build.yml for why the pin must be a constraint. + echo 'hatchling!=1.32.1' > "$RUNNER_TEMP/build-constraints.txt" + { + echo "UV_CONSTRAINT=$RUNNER_TEMP/build-constraints.txt" + echo "PIP_CONSTRAINT=$RUNNER_TEMP/build-constraints.txt" + } >> "$GITHUB_ENV" - name: Build run: hatch -v build diff --git a/.github/workflows/reusable_python_build.yml b/.github/workflows/reusable_python_build.yml index c8cfa79..6902a2d 100644 --- a/.github/workflows/reusable_python_build.yml +++ b/.github/workflows/reusable_python_build.yml @@ -53,6 +53,9 @@ jobs: python-version: ${{ inputs.python-version }} - name: Install Hatch + # bash on every OS: the constraint snippet below uses POSIX redirection, + # and this job also runs on windows-latest where the default is pwsh. + shell: bash run: | # pyproject-hooks 1.3.0 renamed the env var carrying an in-tree # backend's backend-path to _PYPROJECT_HOOKS_BACKEND_PATH_JSON @@ -62,6 +65,18 @@ jobs: # once hatch sets the new name. pip install --upgrade hatch "click<8.3" "virtualenv<21" "pyproject-hooks<1.3" + # hatchling 1.32.1 imports `hatch`, which is absent from the isolated + # build env that `hatch build` creates, so every build fails with + # ModuleNotFoundError (pypa/hatch#2427; the release is yanked). A pin + # on the line above only reaches the CLI env. The build env is + # installed by uv and honours UV_CONSTRAINT; PIP_CONSTRAINT covers a + # pip-installed one. + echo 'hatchling!=1.32.1' > "$RUNNER_TEMP/build-constraints.txt" + { + echo "UV_CONSTRAINT=$RUNNER_TEMP/build-constraints.txt" + echo "PIP_CONSTRAINT=$RUNNER_TEMP/build-constraints.txt" + } >> "$GITHUB_ENV" + - name: Run Linting run: hatch -v run lint