ci(build): use envvar override to omit local version for Test PyPI upload (#10720)

Uses `SETUPTOOLS_SCM_OVERRIDES_FOR_DVC` to omit the local version
when uploading to Test PyPI. This is needed because (Test) PyPI
does not support local version.

This requires bumping minimum version of `setuptools_scm` to `8.0.0`.

The envvar is documented here: https://setuptools-scm.readthedocs.io/en/latest/overrides/.

Also see:
https://github.com/pypa/setuptools-scm/issues/455#issuecomment-2791301186.
This commit is contained in:
skshetry
2025-04-10 12:59:32 +05:45
committed by GitHub
parent 6cc349edb4
commit b824bc4db7
2 changed files with 12 additions and 10 deletions
+11 -9
View File
@@ -28,22 +28,24 @@ jobs:
python-version: 3.13 python-version: 3.13
- uses: astral-sh/setup-uv@v5 - uses: astral-sh/setup-uv@v5
- run: uv pip install --upgrade setuptools_scm twine --system
- name: Force version for Test PyPI upload - name: Omit local version for Test PyPI upload
if: ${{ !startsWith(github.ref, 'refs/tags') }} if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: echo version=$(python -m setuptools_scm | awk -F+ '{print $1}' | tail -1) >> $GITHUB_ENV run: echo SETUPTOOLS_SCM_OVERRIDES_FOR_DVC='{local_scheme="no-local-version"}' >> $GITHUB_ENV
- run: echo 'PKG = "pip"'>dvc/_build.py - name: Build Python Package
- run: uv build run: |
env: echo 'PKG = "pip"'>dvc/_build.py
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DVC: ${{ env.version }} uv build
- run: twine check --strict dist/*
- name: Check dist
run: uv tool run twine check --strict dist/*
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: Packages name: Packages
path: dist/ path: dist/
if-no-files-found: error
test-pypi-publish: test-pypi-publish:
name: Publish dev package to test.pypi.org name: Publish dev package to test.pypi.org
+1 -1
View File
@@ -1,6 +1,6 @@
[build-system] [build-system]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
requires = ["setuptools>=77", "setuptools_scm[toml]>=7"] requires = ["setuptools>=77", "setuptools_scm[toml]>=8"]
[project] [project]
name = "dvc" name = "dvc"