Skip to content

Commit ae0df38

Browse files
committed
Set __version__ in the runtime package
* Return the version key in ``setup()`` * Add static type annotations to ``setup()`` * Fix the Python version for ``tomli``
1 parent 2f15ba6 commit ae0df38

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ How to release
22
--------------
33

44
- Update ``CHANGELOG.rst``
5-
- Bump version (YYYY.MM) in ``pyproject.toml``
5+
- Bump version (YYYY.MM) in ``python_docs_theme/__init__.py``
66
- Commit
77
- Push to check tests pass on
88
`GitHub Actions <https://github.com/python/python-docs-theme/actions>`__

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ requires = [
66

77
[project]
88
name = "python-docs-theme"
9-
version = "2024.12"
109
description = "The Sphinx theme for the CPython docs and related projects"
1110
readme = "README.md"
1211
license.file = "LICENSE"
@@ -28,10 +27,11 @@ classifiers = [
2827
"Topic :: Documentation",
2928
"Topic :: Software Development :: Documentation",
3029
]
30+
dynamic = [ "version" ]
31+
3132
dependencies = [
3233
"sphinx>=3.4",
3334
]
34-
3535
urls.Code = "https://github.com/python/python-docs-theme"
3636
urls.Download = "https://pypi.org/project/python-docs-theme/"
3737
urls.Homepage = "https://github.com/python/python-docs-theme/"

python_docs_theme/__init__.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
from __future__ import annotations
22

33
import hashlib
4-
import os
54
from functools import cache
65
from pathlib import Path
7-
from typing import Any
6+
from typing import TYPE_CHECKING
7+
8+
if TYPE_CHECKING:
9+
from typing import Any
10+
11+
from sphinx.application import Sphinx
12+
from sphinx.util.typing import ExtensionMetadata
813

914
import sphinx.application
1015
from sphinx.builders.html import StandaloneHTMLBuilder
1116

12-
THEME_PATH = Path(__file__).parent.resolve()
17+
__version__ = "2024.12"
18+
19+
THEME_PATH = Path(__file__).resolve().parent
1320

1421

1522
@cache
@@ -52,15 +59,15 @@ def _html_page_context(
5259
)
5360

5461

55-
def setup(app):
62+
def setup(app: Sphinx) -> ExtensionMetadata:
5663
app.require_sphinx("3.4")
5764

58-
current_dir = os.path.abspath(os.path.dirname(__file__))
59-
app.add_html_theme("python_docs_theme", current_dir)
65+
app.add_html_theme("python_docs_theme", str(THEME_PATH))
6066

6167
app.connect("html-page-context", _html_page_context)
6268

6369
return {
70+
"version": __version__,
6471
"parallel_read_safe": True,
6572
"parallel_write_safe": True,
6673
}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
setuptools
33
Babel
44
Jinja2
5-
tomli; python_version < "3.10"
5+
tomli; python_version < "3.11"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy