Skip to content

Commit b824bc4

Browse files
authored
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: pypa/setuptools-scm#455 (comment).
1 parent 6cc349e commit b824bc4

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

.github/workflows/build.yaml

+11-9
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,24 @@ jobs:
2828
python-version: 3.13
2929

3030
- uses: astral-sh/setup-uv@v5
31-
- run: uv pip install --upgrade setuptools_scm twine --system
3231

33-
- name: Force version for Test PyPI upload
34-
if: ${{ !startsWith(github.ref, 'refs/tags') }}
35-
run: echo version=$(python -m setuptools_scm | awk -F+ '{print $1}' | tail -1) >> $GITHUB_ENV
32+
- name: Omit local version for Test PyPI upload
33+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
34+
run: echo SETUPTOOLS_SCM_OVERRIDES_FOR_DVC='{local_scheme="no-local-version"}' >> $GITHUB_ENV
3635

37-
- run: echo 'PKG = "pip"'>dvc/_build.py
38-
- run: uv build
39-
env:
40-
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DVC: ${{ env.version }}
41-
- run: twine check --strict dist/*
36+
- name: Build Python Package
37+
run: |
38+
echo 'PKG = "pip"'>dvc/_build.py
39+
uv build
40+
41+
- name: Check dist
42+
run: uv tool run twine check --strict dist/*
4243

4344
- uses: actions/upload-artifact@v4
4445
with:
4546
name: Packages
4647
path: dist/
48+
if-no-files-found: error
4749

4850
test-pypi-publish:
4951
name: Publish dev package to test.pypi.org

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
22
build-backend = "setuptools.build_meta"
3-
requires = ["setuptools>=77", "setuptools_scm[toml]>=7"]
3+
requires = ["setuptools>=77", "setuptools_scm[toml]>=8"]
44

55
[project]
66
name = "dvc"

0 commit comments

Comments
 (0)