Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using uv for dev setup, build, publish #114

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .devcontainer/on_create_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

set -ex

pip install -U pip setuptools wheel setuptools_scm
pip install -r requirements-dev.txt
curl -LsSf https://astral.sh/uv/install.sh | sh
. $HOME/.cargo/env
uv tool install -U ruff
uv tool install -U tox --with tox-uv

# Install Transifex CLI tool into /usr/local/bin
# refer to Installation instructions https://github.com/transifex/cli#installation
Expand Down
137 changes: 137 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Test
on:
push:
paths-ignore:
- 'doc/**'
pull_request:
paths-ignore:
- 'doc/**'
release:
types: [released]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: [3.9, '3.10', '3.11', '3.12', '3.13']

steps:
- name: Print github context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo $GITHUB_CONTEXT

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
cache-suffix: ${{ matrix.python-version }}

- name: Install Python
run: uv python install ${{ matrix.python-version }}
env:
UV_PYTHON_PREFERENCE: only-managed

- name: Install Transifex CLI
run: |
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
mv tx /usr/local/bin/tx

- name: Tox tests
run: uv run --only-dev tox -- -v --durations=25

build:
name: build distribution
if: github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master'
needs:
- tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Python
uses: astral-sh/setup-uv@v3

- name: build package
run: uv build

- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: distributions
path: dist/

pypi-publish:
name: Upload release to PyPI
if: github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/sphinx-intl
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: distributions
path: dist/

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true

# for test
password: ${{ secrets.TESTPYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/

# for production
# password: ${{ secrets.PYPI_TOKEN }}

github-release:
name: GitHub release
if: github.repository_owner == 'sphinx-doc'
runs-on: ubuntu-latest
needs:
- pypi-publish
environment: release
permissions:
contents: write # for softprops/action-gh-release to create GitHub release

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Get release version
id: get_version
uses: actions/github-script@v7
with:
script: core.setOutput('version', context.ref.replace("refs/tags/", ""))

- name: Create GitHub release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: "sphinx-intl ${{ steps.get_version.outputs.version }}"
body: "Changelog: https://sphinx-intl.readthedocs.io/en/master/changes.html"
80 changes: 0 additions & 80 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
uv.lock

# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python

Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
include *.rst
include requirements-*.txt
include tox.ini
recursive-include tests *
prune tests/__pycache__
Expand Down
14 changes: 5 additions & 9 deletions checklist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

Procedure:

1. check GitHub Actions test results: https://github.com/sphinx-doc/sphinx-intl/actions
2. update release version/date in ``CHANGES.rst``
3. ``python -m build``, see details: setup.cfg
4. ``twine upload dist/<target-package-file>``
5. check PyPI page: https://pypi.org/p/sphinx-intl
6. tagging with version name that MUST following semver. e.g.: ``git tag 1.0.1``
7. ``git push --tags`` to push tag
8. bump version in ``sphinx_intl/__init__.py`` and ``CHANGES.rst`` then commit/push
them onto GitHub
1. update release version/date in ``CHANGES.rst``
2. create GitHub Release with new version tag, it will create a release on PyPI.
tag MUST following semver. e.g.: ``2.3.1``
3. check PyPI page: https://pypi.org/p/sphinx-intl
4. bump version in ``CHANGES.rst`` then commit/push it onto GitHub
4 changes: 2 additions & 2 deletions doc/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Setup development environment
* Requires supported Python version
* Do setup under sphinx-intl.git repository root as::

$ pip install -U pip setuptools wheel setuptools_scm
$ pip install -r requirements-dev.txt
$ pip install -U uv
$ uv sync

* Install Transifex CLI tool (refer to `Installation instructions <https://github.com/transifex/cli>`_)::

Expand Down
23 changes: 17 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,34 @@ test = [
"pytest",
]

[dependency-groups]
dev = [
"pytest",
"ruff>=0.8.0",
"tox-gh-actions>=3.2.0",
"tox-uv>=1.16.0",
]

[project.urls]
Homepage = "https://github.com/sphinx-doc/sphinx-intl"
Documentation = "https://sphinx-intl.readthedocs.io"

[project.scripts]
sphinx-intl = "sphinx_intl.commands:main"

[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
include-package-data = true

[tool.setuptools.dynamic]
version = {attr = "sphinx_intl.__version__"}

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
# this empty section means: use_scm_version=True

[tool.mypy]
ignore_missing_imports = true
strict_optional = false

[tool.uv.sources]
sphinx-intl = { workspace = true }
6 changes: 0 additions & 6 deletions requirements-dev.txt

This file was deleted.

17 changes: 0 additions & 17 deletions setup.cfg

This file was deleted.

8 changes: 7 additions & 1 deletion sphinx_intl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
__version__ = "2.3.0"
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version("sphinx_intl")
except PackageNotFoundError:
# package is not installed
pass
19 changes: 3 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ envlist =
python =
3.9: py39
3.10: py310
3.11: py311
3.11: py311, lint, check
3.12: py312
3.13: py313

Expand Down Expand Up @@ -41,22 +41,9 @@ commands=mypy sphinx_intl

[testenv:dist]
usedevelop=True
deps=
build
twine
deps=twine
commands=
{envpython} -m build
twine check dist/*

[testenv:release]
deps=
build
twine
allowlist_externals=mv
commands=
-mv setup.cfg setup.cfg_
{envpython} -m build
-mv setup.cfg_ setup.cfg
uv build
twine check dist/*

[flake8]
Expand Down