Skip to content

Commit 3ff7ac6

Browse files
FindHaofacebook-github-bot
authored andcommitted
Enable setuptools-scm and nightly PyPI publishing (#95)
Summary: fix #94 - Adopt setuptools-scm dynamic versioning (remove hardcoded version). - Add a nightly PyPI publish workflow that generates PEP 440–compliant dev versions from the latest tag with per-second UTC timestamps: `X.Y.Z.devYYYYMMDDHHMMSS`. - Publish to PyPI only on scheduled runs; manual runs build and validate but do not publish. ### Changes vs main - Added: `.github/workflows/nightly-pypi.yml` - Checkout with full history/tags. - Install build tooling (`build`, `setuptools-scm`). - Compute version from the latest tag via shell and per-second UTC time. - Force version using `SETUPTOOLS_SCM_PRETEND_VERSION` and build sdist/wheel. - Validate metadata with `twine check`. - Publish only when triggered by `schedule`. - Modified: `pyproject.toml` - Remove `version = "..."`; add `dynamic = ["version"]`. - Bump `setuptools` minimum to `>=64` to support PEP 621 dynamic versioning. - Keep `setuptools_scm` config: `version_scheme = "guess-next-dev"`, `local_scheme = "no-local-version"`. ### Rationale - Ensure PyPI-acceptable versions (no local part like `+g<sha>`; strict PEP 440). - Avoid manual base-version maintenance; derive from Git tags. - Guarantee unique nightly builds even with multiple runs on the same day. ### How to verify - Local (no publish): 1) `git fetch --tags` 2) `python -m venv .venv && source .venv/bin/activate` 3) `pip install -U pip && pip install build setuptools-scm twine` 4) `TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 0.1.0); BASE=${TAG#v}; DATE=$(date -u +%Y%m%d%H%M%S); export SETUPTOOLS_SCM_PRETEND_VERSION=${BASE}.dev${DATE}` 5) `python -m build && twine check dist/*` - GitHub Actions: - After this workflow exists on the default branch, use “Run workflow” (manual run does not publish) or wait for the next cron to publish (requires `PYPI_API_TOKEN`). ### Impact - No breaking changes to consumers. Release tags (e.g., `v0.1.1`) continue to produce stable versions. ### Secrets / Configuration - Repository secret `PYPI_API_TOKEN` is required for scheduled publishes. Pull Request resolved: #95 Reviewed By: sfzhu93 Differential Revision: D82144776 Pulled By: FindHao fbshipit-source-id: bcd1164ef4077f160a5fcba0b51990587c3ab8bf
1 parent 6ce725f commit 3ff7ac6

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

.github/workflows/nightly-pypi.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Nightly PyPI Publish
2+
on:
3+
schedule:
4+
- cron: "8 7 * * *" # 07:08 UTC daily
5+
workflow_dispatch: {} # allow manual runs (no publish)
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build-and-publish:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # setuptools-scm requires full history/tags
18+
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.11"
22+
23+
- name: Install build tools
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install build setuptools-scm
27+
28+
- name: Compute nightly version from latest tag (per-second)
29+
id: ver
30+
run: |
31+
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 0.1.0)
32+
BASE=${TAG#v}
33+
DATE=$(date -u +%Y%m%d%H%M%S)
34+
echo "NVER=${BASE}.dev${DATE}" >> $GITHUB_OUTPUT
35+
36+
- name: Build sdist/wheel with forced version
37+
run: |
38+
export SETUPTOOLS_SCM_PRETEND_VERSION=${{ steps.ver.outputs.NVER }}
39+
python -m build
40+
41+
- name: Check metadata
42+
run: |
43+
pip install twine
44+
twine check dist/*
45+
46+
- name: Publish to PyPI (API token)
47+
if: github.event_name == 'schedule'
48+
uses: pypa/gh-action-pypi-publish@release/v1
49+
with:
50+
user: __token__
51+
password: ${{ secrets.PYPI_API_TOKEN }}
52+
skip-existing: true

pyproject.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
[build-system]
2-
requires = ["setuptools>=40.8.0", "wheel"]
2+
requires = ["setuptools>=64", "wheel", "setuptools-scm>=8.0.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "tritonparse"
7-
version = "0.1.1"
7+
dynamic = ["version"]
88
dependencies = [
99
"triton>3.3.1",
1010
]
1111
requires-python = ">=3.10"
12+
description = "TritonParse: A Compiler Tracer, Visualizer, and mini-Reproducer Generator for Triton Kernels"
13+
readme = "README.md"
14+
authors = [
15+
{ name="Yueming Hao", email="yhao@meta.com" },
16+
]
17+
license = { text = "BSD-3-Clause" }
18+
1219

1320
[project.optional-dependencies]
1421
test = [
1522
"coverage>=7.0.0",
1623
]
1724

18-
1925
[tool.setuptools.packages.find]
2026
include = ["tritonparse*"]
2127

@@ -30,5 +36,9 @@ sorter = "usort"
3036
[tool.usort]
3137
first_party_detection = false
3238

39+
[tool.setuptools_scm]
40+
version_scheme = "guess-next-dev"
41+
local_scheme = "no-local-version"
42+
3343
[project.urls]
3444
"Homepage" = "https://github.com/meta-pytorch/tritonparse"

0 commit comments

Comments
 (0)