|
41 | 41 | ompi_key, ompi_val = ompi_line.split("=")
|
42 | 42 | ompi_data[ompi_key.strip()] = ompi_val.strip()
|
43 | 43 |
|
44 |
| -# "release" is a sphinx config variable -- assign it to the computed |
45 |
| -# Open MPI version number. |
46 |
| -series = f"{ompi_data['major']}.{ompi_data['minor']}.x" |
47 |
| -release = f"{ompi_data['major']}.{ompi_data['minor']}.{ompi_data['release']}{ompi_data['greek']}" |
48 |
| - |
| 44 | +ompi_series = f"v{ompi_data['major']}.{ompi_data['minor']}.x" |
| 45 | +ompi_ver = f"v{ompi_data['major']}.{ompi_data['minor']}.{ompi_data['release']}{ompi_data['greek']}" |
| 46 | + |
| 47 | +# "release" is a sphinx config variable: assign it to the computed |
| 48 | +# Open MPI version number. The ompi_ver string begins with a "v"; the |
| 49 | +# Sphinx release variable should not include this prefix "v". |
| 50 | +release = ompi_ver[1:] |
| 51 | + |
| 52 | +# If we are building in a ReadTheDocs.io environment, there will be a |
| 53 | +# READTHEDOCS environment variables that tell us what version to use. |
| 54 | +# Relevant RTD env variables (documented |
| 55 | +# https://docs.readthedocs.io/en/stable/builds.html#build-environment): |
| 56 | +# |
| 57 | +# - READTHEDOCS: will be "True" |
| 58 | +# - READTHEDOCS_VERSION: The RTD slug of the version which is being |
| 59 | +# built (e.g., "latest") |
| 60 | +# - READTHEDOCS_VERSION_NAME: Corresponding version name as displayed |
| 61 | +# in RTD's version switch menu (e.g., "stable") |
| 62 | +# - READTHEDOCS_VERSION_TYPE: Type of the event triggering the build |
| 63 | +# (e.g., "branch", "tag", "external" (for PRs), or "unknown"). |
| 64 | +# |
| 65 | +# If we're building in an RTD environment for a tag or external (i.e., |
| 66 | +# PR), use the RTD version -- not what we just read from the VERSIONS |
| 67 | +# file. |
| 68 | +import os |
| 69 | +key = 'READTHEDOCS' |
| 70 | +if key in os.environ and os.environ[key] == 'True': |
| 71 | + print("OMPI: found ReadTheDocs build environment") |
| 72 | + |
| 73 | + rtd_v = os.environ['READTHEDOCS_VERSION'] |
| 74 | + if os.environ['READTHEDOCS_VERSION_TYPE'] == 'external': |
| 75 | + # Make "release" be shorter than the full "ompi_ver" value. |
| 76 | + release = f'PR #{rtd_v}' |
| 77 | + ompi_ver += f' (Github PR #{rtd_v})' |
| 78 | + else: |
| 79 | + ompi_ver = rtd_v |
| 80 | + |
| 81 | + # The "release" Sphinx variable is supposed to be expressed as |
| 82 | + # a simple value, such as "A.B.C[rcX]" (without a leading |
| 83 | + # "v"). The ompi_ver value will be one of two things: |
| 84 | + # |
| 85 | + # - a git branch name (of the form "vA.B.x") |
| 86 | + # - a git tag (of the form "A.B.C[rcX]") |
| 87 | + # |
| 88 | + # If there's a leading "v", we need to strip it. |
| 89 | + release = ompi_ver |
| 90 | + if ompi_ver[0] == 'v': |
| 91 | + release = ompi_ver[1:] |
| 92 | + |
| 93 | + # Override the branch names "master" and "main" (that would have |
| 94 | + # come from the ReadTheDocs version slug) to be "head of |
| 95 | + # development". |
| 96 | + if release == 'main' or release == 'master': |
| 97 | + ompi_ver = 'head of development' |
| 98 | + |
| 99 | + print(f"OMPI: release = {release}") |
| 100 | + print(f"OMPI: ompi_ver = {ompi_ver}") |
49 | 101 |
|
50 | 102 | # -- General configuration ---------------------------------------------------
|
51 | 103 |
|
@@ -125,6 +177,6 @@ def _doit(topdir):
|
125 | 177 | .. |rarrow| unicode:: U+02192 .. Right arrow
|
126 | 178 |
|
127 | 179 | .. |year| replace:: {year}
|
128 |
| -.. |ompi_ver| replace:: v{release} |
129 |
| -.. |ompi_series| replace:: v{series} |
| 180 | +.. |ompi_ver| replace:: {ompi_ver} |
| 181 | +.. |ompi_series| replace:: {ompi_series} |
130 | 182 | """
|
0 commit comments