Skip to content

Commit 30a45ab

Browse files
authored
Merge pull request #117 from sphinx-contrib/modernize
Modernize CI and build system
2 parents cdc9cb5 + f9384df commit 30a45ab

File tree

8 files changed

+176
-158
lines changed

8 files changed

+176
-158
lines changed

.github/workflows/build.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: build
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
name: Build and Test Package
10+
strategy:
11+
matrix:
12+
version:
13+
- '3.8'
14+
- '3.9'
15+
- '3.10'
16+
- '3.11'
17+
- '3.12'
18+
os: [ubuntu-latest, windows-latest]
19+
runs-on: ${{ matrix.os }}
20+
21+
steps:
22+
- name: Check out repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: ${{ matrix.version }}
29+
30+
- name: Install package
31+
run: pip install .
32+
33+
- name: Run tests
34+
run: python -m unittest discover -v
35+
36+
- name: Build documentation
37+
run: |-
38+
mkdir html
39+
git fetch --all
40+
python -I -m sphinx_multiversion -W docs html
41+
42+
- name: Upload the Docs
43+
uses: actions/upload-artifact@v4
44+
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.12'
45+
with:
46+
name: docs
47+
path: html/
48+
49+
- name: Install pypa/build
50+
run: pip install build
51+
52+
- name: Build a binary wheel and a source tarball
53+
run: python3 -m build
54+
55+
- name: Store the distribution packages
56+
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.12'
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: python-package-distributions
60+
path: dist/
61+
62+
deploy-docs:
63+
name: Deploy Docs to GitHub Pages
64+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' }}
65+
runs-on: ubuntu-latest
66+
needs: [build]
67+
permissions:
68+
pages: write # to deploy to Pages
69+
id-token: write # to verify the deployment originates from an appropriate source
70+
environment:
71+
name: github-pages
72+
url: ${{ steps.deployment.outputs.page_url }}
73+
74+
steps:
75+
- name: Deploy to GitHub Pages
76+
id: deployment
77+
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
78+
with:
79+
artifact_name: docs
80+
81+
deploy-testpypi:
82+
name: Deploy Distribution to Test PyPI
83+
if: false # Currently disabled
84+
needs: [build]
85+
runs-on: ubuntu-latest
86+
environment:
87+
name: testpypi
88+
url: https://test.pypi.org/p/sphinx-multiversion
89+
permissions:
90+
id-token: write
91+
92+
steps:
93+
- name: Download the Distributions
94+
uses: actions/download-artifact@v4
95+
with:
96+
name: python-package-distributions
97+
path: dist/
98+
99+
- name: Publish Distributions to Test PyPI
100+
uses: pypa/gh-action-pypi-publish@release/v1
101+
102+
deploy-pypi:
103+
name: Deploy Distribution to PyPI
104+
if: startsWith(github.ref, 'refs/tags/')
105+
needs: [build]
106+
runs-on: ubuntu-latest
107+
environment:
108+
name: pypi
109+
url: https://pypi.org/p/sphinx-multiversion
110+
permissions:
111+
id-token: write
112+
113+
steps:
114+
- name: Download the Distributions
115+
uses: actions/download-artifact@v4
116+
with:
117+
name: python-package-distributions
118+
path: dist/
119+
120+
- name: Publish Distributions to PyPI
121+
uses: pypa/gh-action-pypi-publish@release/v1
122+

.pre-commit-config.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v2.3.0
3+
rev: v4.6.0
44
hooks:
55
- id: trailing-whitespace
6-
- id: flake8
76
- id: check-merge-conflict
87
- id: check-yaml
98
- id: check-executables-have-shebangs
109
- id: mixed-line-ending
11-
- repo: https://github.com/psf/black
12-
rev: stable
13-
hooks:
14-
- id: black
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: v0.6.8
12+
hooks:
13+
- id: ruff
14+
args: [ --fix ]
15+
- id: ruff-format
1516
- repo: local
1617
hooks:
1718
- id: version-check

.pre-commit/version_check.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import pkgutil
55
import re
66
import runpy
7-
import subprocess
87
import sys
98

109
import docutils.nodes
@@ -79,15 +78,6 @@ def get_sphinxconfpy_version(rootdir):
7978
return sphinx_conf["version"], sphinx_conf["release"]
8079

8180

82-
def get_setuppy_version(rootdir):
83-
"""Get version from setup.py."""
84-
setupfile = os.path.join(rootdir, "setup.py")
85-
cmd = (sys.executable, setupfile, "--version")
86-
release = subprocess.check_output(cmd).decode().rstrip(os.linesep)
87-
version = release.rpartition(".")[0]
88-
return version, release
89-
90-
9181
def get_package_version(rootdir):
9282
"""Get version from package __init__.py."""
9383
sys.path.insert(0, os.path.join(rootdir))
@@ -110,7 +100,6 @@ def get_package_version(rootdir):
110100
def main():
111101
rootdir = os.path.join(os.path.dirname(__file__), "..")
112102

113-
setuppy_version, setuppy_release = get_setuppy_version(rootdir)
114103
package_version, package_release = get_package_version(rootdir)
115104
confpy_version, confpy_release = get_sphinxconfpy_version(rootdir)
116105
changelog_version, changelog_release = get_sphinxchangelog_version(rootdir)
@@ -121,7 +110,6 @@ def main():
121110
len(repr(x))
122111
for x in (
123112
version_head,
124-
setuppy_version,
125113
package_version,
126114
confpy_version,
127115
changelog_version,
@@ -135,7 +123,6 @@ def main():
135123
len(repr(x))
136124
for x in (
137125
release_head,
138-
setuppy_release,
139126
package_release,
140127
confpy_release,
141128
changelog_release,
@@ -147,9 +134,6 @@ def main():
147134
f"File {version_head} {release_head}\n"
148135
f"------------------------------- {'-' * version_width}"
149136
f" {'-' * release_width}\n"
150-
f"setup.py "
151-
f" {setuppy_version!r:>{version_width}}"
152-
f" {setuppy_release!r:>{release_width}}\n"
153137
f"sphinx_multiversion/__init__.py"
154138
f" {package_version!r:>{version_width}}"
155139
f" {package_release!r:>{release_width}}\n"
@@ -161,13 +145,11 @@ def main():
161145
f" {changelog_release!r:>{release_width}}\n"
162146
)
163147

164-
assert setuppy_version == confpy_version
165-
assert setuppy_version == package_version
166-
assert setuppy_version == changelog_version
148+
assert package_version == confpy_version
149+
assert package_version == changelog_version
167150

168-
assert setuppy_release == confpy_release
169-
assert setuppy_release == package_release
170-
assert setuppy_release == changelog_release
151+
assert package_release == confpy_release
152+
assert package_release == changelog_release
171153

172154

173155
if __name__ == "__main__":

.travis.yml

Lines changed: 0 additions & 96 deletions
This file was deleted.

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""Sphinx configuration file."""
3+
34
import time
45

56
author = "Jan Holthuis"

pyproject.toml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1-
[tool.black]
1+
[build-system]
2+
requires = ["hatchling", "hatch-requirements-txt"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "sphinx-multiversion"
7+
dynamic = ["version", "dependencies"]
8+
description = "Add support for multiple versions to sphinx"
9+
readme = "README.md"
10+
license = "BSD-2-Clause"
11+
authors = [
12+
{ name = "Jan Holthuis", email = "[email protected]" },
13+
]
14+
classifiers = [
15+
"License :: OSI Approved :: BSD License",
16+
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3.8",
18+
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
"Programming Language :: Python :: 3.12",
22+
]
23+
24+
[project.scripts]
25+
sphinx-multiversion = "sphinx_multiversion:main"
26+
27+
[project.urls]
28+
Homepage = "https://holzhaus.github.io/sphinx-multiversion/"
29+
30+
[tool.hatch.version]
31+
path = "sphinx_multiversion/__init__.py"
32+
33+
[tool.hatch.metadata.hooks.requirements_txt]
34+
files = ["requirements.txt"]
35+
36+
[tool.hatch.build.targets.sdist]
37+
include = [
38+
"/sphinx_multiversion",
39+
]
40+
41+
[tool.ruff]
242
line-length = 79

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sphinx
1+
sphinx>=2.1

0 commit comments

Comments
 (0)