MartinPdeS-docs 0.3.2__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0/MartinPdeS_docs.egg-info}/PKG-INFO +12 -1
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/MartinPdeS_docs.egg-info/requires.txt +3 -0
- {martinpdes_docs-0.3.2/MartinPdeS_docs.egg-info → martinpdes_docs-0.4.0}/PKG-INFO +12 -1
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/README.md +9 -0
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/martinpdes_docs/sphinx.py +21 -1
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/pyproject.toml +7 -1
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/tests/test_configuration.py +33 -0
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/LICENSE +0 -0
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/MartinPdeS_docs.egg-info/SOURCES.txt +0 -0
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/MartinPdeS_docs.egg-info/dependency_links.txt +0 -0
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/MartinPdeS_docs.egg-info/top_level.txt +0 -0
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/martinpdes_docs/__init__.py +0 -0
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/martinpdes_docs/static/martinpdes_layout.css +0 -0
- {martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MartinPdeS-docs
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -11,6 +11,8 @@ Requires-Dist: sphinx-design>=0.6
|
|
|
11
11
|
Requires-Dist: sphinx-gallery>=0.16
|
|
12
12
|
Requires-Dist: numpydoc<2,>=1.8
|
|
13
13
|
Requires-Dist: pytest>=7
|
|
14
|
+
Provides-Extra: release
|
|
15
|
+
Requires-Dist: martinpdes-maintenance==0.2.2; extra == "release"
|
|
14
16
|
Dynamic: license-file
|
|
15
17
|
|
|
16
18
|
# MartinPdeS-docs
|
|
@@ -43,6 +45,15 @@ globals().update(
|
|
|
43
45
|
Project-specific values can be assigned below this call to override any
|
|
44
46
|
shared default.
|
|
45
47
|
|
|
48
|
+
Set `version="auto"` to read `__version__` from the importable package's
|
|
49
|
+
`_version.py` without importing its `__init__.py`. This sets both Sphinx's
|
|
50
|
+
`version` and `release` fields and the version switcher, and takes precedence
|
|
51
|
+
over the `tag` environment variable. The package must be importable and its
|
|
52
|
+
`_version.py` must provide a non-empty version string. With
|
|
53
|
+
`prefer_installed_package=True`, discovery follows the same package search
|
|
54
|
+
order used for documentation imports. Omitting `version` retains the existing
|
|
55
|
+
environment and distribution-metadata fallback.
|
|
56
|
+
|
|
46
57
|
For a multi-section Sphinx-Gallery, pass the section names instead of
|
|
47
58
|
repeating the directory mappings:
|
|
48
59
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MartinPdeS-docs
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -11,6 +11,8 @@ Requires-Dist: sphinx-design>=0.6
|
|
|
11
11
|
Requires-Dist: sphinx-gallery>=0.16
|
|
12
12
|
Requires-Dist: numpydoc<2,>=1.8
|
|
13
13
|
Requires-Dist: pytest>=7
|
|
14
|
+
Provides-Extra: release
|
|
15
|
+
Requires-Dist: martinpdes-maintenance==0.2.2; extra == "release"
|
|
14
16
|
Dynamic: license-file
|
|
15
17
|
|
|
16
18
|
# MartinPdeS-docs
|
|
@@ -43,6 +45,15 @@ globals().update(
|
|
|
43
45
|
Project-specific values can be assigned below this call to override any
|
|
44
46
|
shared default.
|
|
45
47
|
|
|
48
|
+
Set `version="auto"` to read `__version__` from the importable package's
|
|
49
|
+
`_version.py` without importing its `__init__.py`. This sets both Sphinx's
|
|
50
|
+
`version` and `release` fields and the version switcher, and takes precedence
|
|
51
|
+
over the `tag` environment variable. The package must be importable and its
|
|
52
|
+
`_version.py` must provide a non-empty version string. With
|
|
53
|
+
`prefer_installed_package=True`, discovery follows the same package search
|
|
54
|
+
order used for documentation imports. Omitting `version` retains the existing
|
|
55
|
+
environment and distribution-metadata fallback.
|
|
56
|
+
|
|
46
57
|
For a multi-section Sphinx-Gallery, pass the section names instead of
|
|
47
58
|
repeating the directory mappings:
|
|
48
59
|
|
|
@@ -28,6 +28,15 @@ globals().update(
|
|
|
28
28
|
Project-specific values can be assigned below this call to override any
|
|
29
29
|
shared default.
|
|
30
30
|
|
|
31
|
+
Set `version="auto"` to read `__version__` from the importable package's
|
|
32
|
+
`_version.py` without importing its `__init__.py`. This sets both Sphinx's
|
|
33
|
+
`version` and `release` fields and the version switcher, and takes precedence
|
|
34
|
+
over the `tag` environment variable. The package must be importable and its
|
|
35
|
+
`_version.py` must provide a non-empty version string. With
|
|
36
|
+
`prefer_installed_package=True`, discovery follows the same package search
|
|
37
|
+
order used for documentation imports. Omitting `version` retains the existing
|
|
38
|
+
environment and distribution-metadata fallback.
|
|
39
|
+
|
|
31
40
|
For a multi-section Sphinx-Gallery, pass the section names instead of
|
|
32
41
|
repeating the directory mappings:
|
|
33
42
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"""Configurable defaults for the shared project documentation sites."""
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
+
import runpy
|
|
4
5
|
from collections.abc import Mapping, Sequence
|
|
6
|
+
from importlib.util import find_spec
|
|
5
7
|
import sys
|
|
6
8
|
from importlib.metadata import (
|
|
7
9
|
PackageNotFoundError,
|
|
@@ -44,6 +46,19 @@ def _resolve_doc_asset(path: str) -> str:
|
|
|
44
46
|
|
|
45
47
|
def _resolve_version(package: str, version: str | None) -> str:
|
|
46
48
|
"""Resolve the documentation version without importing the package."""
|
|
49
|
+
if version == "auto":
|
|
50
|
+
spec = find_spec(package)
|
|
51
|
+
locations = spec.submodule_search_locations if spec is not None else None
|
|
52
|
+
if locations is None:
|
|
53
|
+
raise ValueError(f"Cannot find package {package!r} to read its _version.py.")
|
|
54
|
+
for location in locations:
|
|
55
|
+
version_file = Path(location) / "_version.py"
|
|
56
|
+
if version_file.is_file():
|
|
57
|
+
resolved = runpy.run_path(str(version_file)).get("__version__")
|
|
58
|
+
if not isinstance(resolved, str) or not resolved:
|
|
59
|
+
raise ValueError(f"{version_file} must define a non-empty __version__ string.")
|
|
60
|
+
return resolved
|
|
61
|
+
raise ValueError(f"Cannot find _version.py in package {package!r}.")
|
|
47
62
|
if version is not None:
|
|
48
63
|
return version
|
|
49
64
|
|
|
@@ -102,7 +117,9 @@ def configure(
|
|
|
102
117
|
directories; use ``gallery_default_thumb`` for a project-specific raster
|
|
103
118
|
fallback; use ``gallery_options`` for less common Sphinx-Gallery settings;
|
|
104
119
|
and set ``prefer_installed_package`` for projects whose documentation must
|
|
105
|
-
import a built wheel instead of the source checkout.
|
|
120
|
+
import a built wheel instead of the source checkout. Set ``version="auto"``
|
|
121
|
+
to read ``__version__`` from the importable package's ``_version.py`` and
|
|
122
|
+
use it for both Sphinx version fields and the version switcher.
|
|
106
123
|
"""
|
|
107
124
|
if prefer_installed_package:
|
|
108
125
|
_prefer_installed_package(package)
|
|
@@ -275,4 +292,7 @@ def configure(
|
|
|
275
292
|
}
|
|
276
293
|
if gallery is not None:
|
|
277
294
|
configuration["sphinx_gallery_conf"] = gallery
|
|
295
|
+
if version == "auto":
|
|
296
|
+
configuration["version"] = resolved_version
|
|
297
|
+
configuration["release"] = resolved_version
|
|
278
298
|
return configuration
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "MartinPdeS-docs"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "Shared Sphinx configuration for MartinPdeS scientific Python packages."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -25,3 +25,9 @@ martinpdes_docs = ["static/*.css"]
|
|
|
25
25
|
|
|
26
26
|
[tool.pytest.ini_options]
|
|
27
27
|
testpaths = ["tests"]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
release = ["martinpdes-maintenance==0.2.2"]
|
|
31
|
+
|
|
32
|
+
[tool.mps-maintenance]
|
|
33
|
+
conda-recipe = "conda.recipe/meta.yaml"
|
|
@@ -2,6 +2,8 @@ from importlib.metadata import distribution
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
import sys
|
|
4
4
|
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
5
7
|
from martinpdes_docs import configure
|
|
6
8
|
|
|
7
9
|
|
|
@@ -139,6 +141,37 @@ def test_version_can_be_resolved_from_the_environment(monkeypatch):
|
|
|
139
141
|
assert config["html_theme_options"]["switcher"]["version_match"] == "v2.3.4"
|
|
140
142
|
|
|
141
143
|
|
|
144
|
+
def test_auto_version_reads_package_file_without_importing_package(tmp_path, monkeypatch):
|
|
145
|
+
package = tmp_path / "example_auto_version"
|
|
146
|
+
package.mkdir()
|
|
147
|
+
(package / "__init__.py").write_text("raise RuntimeError('package must not be imported')\n")
|
|
148
|
+
(package / "_version.py").write_text('__version__ = version = "1.2.3"\n')
|
|
149
|
+
monkeypatch.syspath_prepend(str(tmp_path))
|
|
150
|
+
monkeypatch.setenv("tag", "v9.9.9")
|
|
151
|
+
|
|
152
|
+
config = configure(
|
|
153
|
+
project="Example", package="example_auto_version",
|
|
154
|
+
repository="MartinPdeS/Example", version="auto",
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
assert config["version"] == config["release"] == "1.2.3"
|
|
158
|
+
assert config["html_theme_options"]["switcher"]["version_match"] == "1.2.3"
|
|
159
|
+
assert "example_auto_version" not in sys.modules
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def test_auto_version_rejects_missing_or_invalid_version_file(tmp_path, monkeypatch):
|
|
163
|
+
package = tmp_path / "example_invalid_version"
|
|
164
|
+
package.mkdir()
|
|
165
|
+
(package / "__init__.py").write_text("")
|
|
166
|
+
monkeypatch.syspath_prepend(str(tmp_path))
|
|
167
|
+
|
|
168
|
+
with pytest.raises(ValueError, match="Cannot find _version.py"):
|
|
169
|
+
configure(project="Example", package="example_invalid_version", version="auto")
|
|
170
|
+
(package / "_version.py").write_text("__version__ = None\n")
|
|
171
|
+
with pytest.raises(ValueError, match="non-empty __version__"):
|
|
172
|
+
configure(project="Example", package="example_invalid_version", version="auto")
|
|
173
|
+
|
|
174
|
+
|
|
142
175
|
def test_installed_package_can_be_preferred(monkeypatch):
|
|
143
176
|
installed_site = str(distribution("MartinPdeS-docs").locate_file(""))
|
|
144
177
|
monkeypatch.setattr(sys, "path", ["checkout", installed_site, "other"])
|
|
File without changes
|
|
File without changes
|
{martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/MartinPdeS_docs.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{martinpdes_docs-0.3.2 → martinpdes_docs-0.4.0}/martinpdes_docs/static/martinpdes_layout.css
RENAMED
|
File without changes
|
|
File without changes
|