Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Set__version__ in the runtime package#222

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
AA-Turner merged 4 commits intopython:mainfromAA-Turner:misc
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
2 changes: 1 addition & 1 deletionCONTRIBUTING.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ How to release
--------------

- Update ``CHANGELOG.rst``
- Bump version (YYYY.MM) in ``pyproject.toml``
- Bump version (YYYY.MM) in ``python_docs_theme/__init__.py``
- Commit
- Push to check tests pass on
`GitHub Actions <https://github.com/python/python-docs-theme/actions>`__
Expand Down
23 changes: 20 additions & 3 deletionsbabel_runner.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@
from __future__ import annotations

import argparse
import ast
import subprocess
from pathlib import Path

Expand All@@ -17,6 +18,8 @@
) from ie

PROJECT_DIR = Path(__file__).resolve().parent
PYPROJECT_TOML = PROJECT_DIR / "pyproject.toml"
INIT_PY = PROJECT_DIR / "python_docs_theme" / "__init__.py"

# Global variables used by pybabel below (paths relative to PROJECT_DIR)
DOMAIN = "messages"
Expand All@@ -29,9 +32,23 @@

def get_project_info() -> dict:
"""Retrieve project's info to populate the message catalog template"""
with open(Path(PROJECT_DIR / "pyproject.toml"), "rb") as f:
data = tomllib.load(f)
return data["project"]
pyproject_text = PYPROJECT_TOML.read_text(encoding="utf-8")
project_data = tomllib.loads(pyproject_text)["project"]

# read __version__ from __init__.py
for child in ast.parse(INIT_PY.read_bytes()).body:
if not isinstance(child, ast.Assign):
continue
target = child.targets[0]
if not isinstance(target, ast.Name) or target.id != "__version__":
continue
version_node = child.value
if not isinstance(version_node, ast.Constant):
continue
project_data["version"] = version_node.value
break

return project_data


def extract_messages() -> None:
Expand Down
3 changes: 2 additions & 1 deletionpyproject.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ requires = [

[project]
name = "python-docs-theme"
version = "2024.12"
description = "The Sphinx theme for the CPython docs and related projects"
readme = "README.md"
license.file = "LICENSE"
Expand All@@ -28,6 +27,8 @@ classifiers = [
"Topic :: Documentation",
"Topic :: Software Development :: Documentation",
]
dynamic = [ "version" ]

dependencies = [
"sphinx>=3.4",
]
Expand Down
19 changes: 13 additions & 6 deletionspython_docs_theme/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
from __future__ import annotations

import hashlib
import os
from functools import cache
from pathlib import Path
from typing import Any

import sphinx.application
from sphinx.builders.html import StandaloneHTMLBuilder

THEME_PATH = Path(__file__).parent.resolve()
TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Any

from sphinx.application import Sphinx
from sphinx.util.typing import ExtensionMetadata

__version__ = "2024.12"

THEME_PATH = Path(__file__).resolve().parent


@cache
Expand DownExpand Up@@ -52,15 +59,15 @@ def _html_page_context(
)


def setup(app):
def setup(app: Sphinx) -> ExtensionMetadata:
app.require_sphinx("3.4")

current_dir = os.path.abspath(os.path.dirname(__file__))
app.add_html_theme("python_docs_theme", current_dir)
app.add_html_theme("python_docs_theme", str(THEME_PATH))

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

return {
"version": __version__,
"parallel_read_safe": True,
"parallel_write_safe": True,
}
2 changes: 1 addition & 1 deletionrequirements.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,4 +2,4 @@
setuptools
Babel
Jinja2
tomli; python_version < "3.10"
tomli; python_version < "3.11"
Loading

[8]ページ先頭

©2009-2025 Movatter.jp