Skip to content

Enable setuptools-scm and nightly PyPI publishing#95

Closed
FindHao wants to merge 4 commits intomainfrom
findhao/setup_auto_pypi
Closed

Enable setuptools-scm and nightly PyPI publishing#95
FindHao wants to merge 4 commits intomainfrom
findhao/setup_auto_pypi

Conversation

@FindHao
Copy link
Copy Markdown
Member

@FindHao FindHao commented Sep 10, 2025

fix #94

Summary

  • 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.

Summary:
This commit updates the `pyproject.toml` file to enhance project metadata and dependencies, including the addition of authors and license information. It also introduces a new GitHub Actions workflow for nightly publishing to PyPI, ensuring automated versioning and deployment.

Changes:
- Updated `setuptools` and `wheel` requirements in `pyproject.toml`.
- Added dynamic versioning and project description in `pyproject.toml`.
- Created a new workflow file for nightly publishing to PyPI.

This enhancement improves project maintainability and automates the release process.
Summary:
This commit modifies the condition for publishing to PyPI in the nightly workflow. The check for a non-empty `PYPI_API_TOKEN` has been removed, allowing the publish step to execute regardless of the token's presence.

Changes:
- Updated the conditional statement in `.github/workflows/nightly-pypi.yml` for the PyPI publish step.

This change simplifies the publishing process and ensures that the workflow runs as scheduled.
Summary:
This commit simplifies the name of the nightly PyPI publish workflow by removing the reference to the API token. The workflow will now be referred to simply as "Nightly PyPI Publish".

Changes:
- Updated the workflow name in `.github/workflows/nightly-pypi.yml`.

This change enhances clarity and aligns with the recent modifications to the publishing conditions.
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 10, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@FindHao has imported this pull request. If you are a Meta employee, you can view this in D82144776.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@FindHao has imported this pull request. If you are a Meta employee, you can view this in D82144776.

Summary:
This commit modifies the authors section in the `pyproject.toml` file by removing the duplicate entry and ensuring proper formatting.

Changes:
- Removed duplicate authors entry in `pyproject.toml`.
- Ensured authors are listed correctly in the project metadata.

This update enhances the clarity of project authorship information.
@FindHao FindHao force-pushed the findhao/setup_auto_pypi branch from d6e6118 to f404b7d Compare September 10, 2025 20:28
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@FindHao has imported this pull request. If you are a Meta employee, you can view this in D82144776.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@FindHao merged this pull request in 3ff7ac6.

@FindHao FindHao deleted the findhao/setup_auto_pypi branch September 19, 2025 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup automatic update of pypi package

2 participants