Skip to content
This repository was archived by the owner on Apr 9, 2026. It is now read-only.

Commit 7ec8de9

Browse files
Copilotjpfeuffer
andcommitted
Fix: Use READTHEDOCS_VERSION_NAME env var instead of hardcoded version, add --pre flag
Co-authored-by: jpfeuffer <8102638+jpfeuffer@users.noreply.github.com>
1 parent 70313a1 commit 7ec8de9

2 files changed

Lines changed: 49 additions & 23 deletions

File tree

docs/install_pyopenms.py

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,72 @@
11
#!/usr/bin/env python
22
"""
3-
Script to install pyopenms with the version specified in conf.py
3+
Script to install pyopenms with the version from ReadTheDocs environment variable.
44
This is used by ReadTheDocs build process to ensure the correct version is installed.
55
"""
66
import subprocess
77
import sys
8+
import os
89
import re
9-
from pathlib import Path
1010

11-
def get_version_from_conf():
12-
"""Extract version from docs/source/conf.py"""
13-
conf_path = Path(__file__).parent.resolve() / "source" / "conf.py"
11+
def get_version_from_rtd():
12+
"""
13+
Extract version from READTHEDOCS_VERSION_NAME environment variable.
1414
15-
with open(conf_path, 'r', encoding='utf-8') as f:
16-
content = f.read()
15+
The variable will be:
16+
- "latest" for latest builds
17+
- "release/X.Y.Z" for release branches
18+
- Tag names for tag builds
1719
18-
# Look for version = u'X.Y.Z' pattern (with word boundary to be more specific)
19-
match = re.search(r"\bversion\s*=\s*u?['\"]([^'\"]+)['\"]", content)
20+
Returns the version to install (e.g., "3.5.0" or "latest")
21+
"""
22+
rtd_version = os.environ.get('READTHEDOCS_VERSION_NAME', '')
2023

21-
if match:
22-
version = match.group(1)
23-
print(f"Found version in conf.py: {version}")
24+
if not rtd_version:
25+
print("Warning: READTHEDOCS_VERSION_NAME not set, defaulting to 'latest'")
26+
return 'latest'
27+
28+
print(f"READTHEDOCS_VERSION_NAME: {rtd_version}")
29+
30+
# If it's "latest", install latest version
31+
if rtd_version == "latest":
32+
return 'latest'
33+
34+
# If it's a release branch like "release/3.5.0" or "Release/3.5.0", extract the version
35+
if rtd_version.lower().startswith('release/'):
36+
version = rtd_version.split('/', 1)[1]
37+
print(f"Extracted version from release branch: {version}")
2438
return version
25-
else:
26-
raise ValueError("Could not find version in conf.py")
39+
40+
# If it looks like a version tag (e.g., "v3.5.0", "3.5.0"), use it directly
41+
# Strip leading 'v' if present
42+
version = rtd_version.lstrip('v')
43+
print(f"Using version from tag: {version}")
44+
return version
2745

2846
def install_pyopenms(version):
29-
"""Install pyopenms with specific version"""
30-
print(f"Installing pyopenms=={version}")
47+
"""Install pyopenms with specific version or latest"""
3148

32-
# Use the extra index URL for pyopenms
33-
subprocess.check_call([
49+
# Build pip install command
50+
cmd = [
3451
sys.executable, "-m", "pip", "install",
3552
"--extra-index-url", "https://pypi.cs.uni-tuebingen.de/simple/",
36-
f"pyopenms=={version}"
37-
])
53+
"--pre" # Allow pre-release versions
54+
]
55+
56+
if version == 'latest':
57+
print("Installing latest version of pyopenms")
58+
cmd.append("pyopenms")
59+
else:
60+
print(f"Installing pyopenms=={version}")
61+
cmd.append(f"pyopenms=={version}")
62+
63+
subprocess.check_call(cmd)
3864

39-
print(f"Successfully installed pyopenms=={version}")
65+
print(f"Successfully installed pyopenms")
4066

4167
if __name__ == "__main__":
4268
try:
43-
version = get_version_from_conf()
69+
version = get_version_from_rtd()
4470
install_pyopenms(version)
4571
except Exception as e:
4672
print(f"Error: {e}", file=sys.stderr)

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ ipython
99
pygments-lexer-pseudocode
1010

1111
# Note: pyopenms is installed via docs/install_pyopenms.py script
12-
# which reads the version from docs/source/conf.py to ensure version consistency
12+
# which reads the version from READTHEDOCS_VERSION_NAME environment variable

0 commit comments

Comments
 (0)