From 42788c0613c4137055c3a83b44db41ecde1c8106 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Wed, 9 Nov 2022 00:34:59 +0100 Subject: [PATCH] Revert to patching `pyproject.toml` for nightlies https://github.com/pypa/setuptools_scm/issues/455#issuecomment-1304931476 turned out to be a bad idea and didn't work as expected. --- .github/workflows/build-test-n-publish.yml | 84 ++++++++++++++++------ 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-test-n-publish.yml b/.github/workflows/build-test-n-publish.yml index edc2161e3..3d8374387 100644 --- a/.github/workflows/build-test-n-publish.yml +++ b/.github/workflows/build-test-n-publish.yml @@ -500,18 +500,32 @@ jobs: && github.event.inputs.release-commitish || '' }} - - name: Write the current version metadata to `.git_archival.txt` + - name: Install tomlkit Python distribution package if: >- fromJSON(needs.pre-setup.outputs.is-untagged-devel) run: >- - git show --format='node: %H%nnode-date: %cI%ndescribe-name: - %(describe:tags=true,match=*[0-9]*)%nref-names: %D%n' --no-patch - | - tee -a .git_archival.txt - - name: Delete the Git repository + python -m pip install --user tomlkit + - name: Instruct setuptools-scm not to add a local version part + if: >- + fromJSON(needs.pre-setup.outputs.is-untagged-devel) + run: | + from pathlib import Path + + import tomlkit + + pyproject_toml_path = Path.cwd() / 'pyproject.toml' + with pyproject_toml_path.open() as pyproject_toml_fp: + pyproject_toml = tomlkit.load(pyproject_toml_fp) + setuptools_scm_section = pyproject_toml['tool']['setuptools_scm'] + setuptools_scm_section['local_scheme'] = 'no-local-version' + tomlkit.dump(pyproject_toml, pyproject_toml_fp) + shell: python + - name: Pretend that pyproject.toml is unchanged if: >- fromJSON(needs.pre-setup.outputs.is-untagged-devel) - run: rm -rf .git + run: | + git diff --color=always + git update-index --assume-unchanged pyproject.toml - name: Build dist run: >- @@ -783,18 +797,32 @@ jobs: && github.event.inputs.release-commitish || '' }} - - name: Write the current version metadata to `.git_archival.txt` + - name: Install tomlkit Python distribution package if: >- fromJSON(needs.pre-setup.outputs.is-untagged-devel) run: >- - git show --format='node: %H%nnode-date: %cI%ndescribe-name: - %(describe:tags=true,match=*[0-9]*)%nref-names: %D%n' --no-patch - | - tee -a .git_archival.txt - - name: Delete the Git repository + python -m pip install --user tomlkit + - name: Instruct setuptools-scm not to add a local version part if: >- fromJSON(needs.pre-setup.outputs.is-untagged-devel) - run: rm -rf .git + run: | + from pathlib import Path + + import tomlkit + + pyproject_toml_path = Path.cwd() / 'pyproject.toml' + with pyproject_toml_path.open() as pyproject_toml_fp: + pyproject_toml = tomlkit.load(pyproject_toml_fp) + setuptools_scm_section = pyproject_toml['tool']['setuptools_scm'] + setuptools_scm_section['local_scheme'] = 'no-local-version' + tomlkit.dump(pyproject_toml, pyproject_toml_fp) + shell: python + - name: Pretend that pyproject.toml is unchanged + if: >- + fromJSON(needs.pre-setup.outputs.is-untagged-devel) + run: | + git diff --color=always + git update-index --assume-unchanged pyproject.toml - name: >- Set up QEMU ${{ env.QEMU_ARCH }} arch emulation @@ -966,18 +994,32 @@ jobs: && github.event.inputs.release-commitish || '' }} - - name: Write the current version metadata to `.git_archival.txt` + - name: Install tomlkit Python distribution package if: >- fromJSON(needs.pre-setup.outputs.is-untagged-devel) run: >- - git show --format='node: %H%nnode-date: %cI%ndescribe-name: - %(describe:tags=true,match=*[0-9]*)%nref-names: %D%n' --no-patch - | - tee -a .git_archival.txt - - name: Delete the Git repository + python -m pip install --user tomlkit + - name: Instruct setuptools-scm not to add a local version part if: >- fromJSON(needs.pre-setup.outputs.is-untagged-devel) - run: rm -rf .git + run: | + from pathlib import Path + + import tomlkit + + pyproject_toml_path = Path.cwd() / 'pyproject.toml' + with pyproject_toml_path.open() as pyproject_toml_fp: + pyproject_toml = tomlkit.load(pyproject_toml_fp) + setuptools_scm_section = pyproject_toml['tool']['setuptools_scm'] + setuptools_scm_section['local_scheme'] = 'no-local-version' + tomlkit.dump(pyproject_toml, pyproject_toml_fp) + shell: python + - name: Pretend that pyproject.toml is unchanged + if: >- + fromJSON(needs.pre-setup.outputs.is-untagged-devel) + run: | + git diff --color=always + git update-index --assume-unchanged pyproject.toml - name: Build sdist and verify metadata run: >-