Skip to content

Commit 6fa7b10

Browse files
committed
added scripts to build vesper's environment
1 parent 2e8791b commit 6fa7b10

2 files changed

Lines changed: 187 additions & 0 deletions

File tree

requirements.txt

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
argcomplete==2.0.0
2+
asttokens==3.0.0
3+
attrs==25.3.0
4+
backcall==0.2.0
5+
beautifulsoup4==4.13.3
6+
biopython==1.83
7+
bleach==6.2.0
8+
Brotli==1.1.0
9+
certifi==2025.1.31
10+
cffi==1.16.0
11+
charset-normalizer==3.4.1
12+
contourpy==1.2.0
13+
cssselect2==0.7.0
14+
cstag==1.0.5
15+
cstag-cli==1.0.0
16+
cycler==0.12.1
17+
decorator==5.2.1
18+
defusedxml==0.7.1
19+
distlib==0.3.4
20+
docopt==0.6.2
21+
edlib==1.3.9
22+
executing==2.2.0
23+
fastjsonschema==2.21.1
24+
filelock==3.6.0
25+
fonttools==4.49.0
26+
html5lib==1.1
27+
idna==3.10
28+
importlib_metadata==8.6.1
29+
importlib_resources==6.1.2
30+
ipython==8.12.3
31+
jedi==0.19.2
32+
Jinja2==3.1.6
33+
joblib==1.3.2
34+
jsonschema==4.23.0
35+
jsonschema-specifications==2024.10.1
36+
jupyter_client==8.6.3
37+
jupyter_core==5.7.2
38+
jupyterlab_pygments==0.3.0
39+
kaleido==0.2.1
40+
kiwisolver==1.4.5
41+
kneebow==1.0.1
42+
MarkupSafe==3.0.2
43+
matplotlib==3.8.3
44+
matplotlib-inline==0.1.7
45+
mistune==3.1.3
46+
nbclient==0.10.2
47+
nbconvert==7.16.6
48+
nbformat==5.10.4
49+
numpy==1.26.4
50+
packaging==21.3
51+
pandas==2.2.2
52+
pandocfilters==1.5.1
53+
Paralleltask==0.2.3
54+
parso==0.8.4
55+
pexpect==4.9.0
56+
pickleshare==0.7.5
57+
pillow==10.2.0
58+
pipx==1.1.0
59+
platformdirs==2.5.2
60+
plotly==5.19.0
61+
prompt_toolkit==3.0.50
62+
psutil==7.0.0
63+
ptyprocess==0.7.0
64+
pure_eval==0.2.3
65+
pyarrow==15.0.2
66+
pybind11==2.13.6
67+
pycparser==2.22
68+
pydyf==0.10.0
69+
Pygments==2.19.1
70+
pyparsing==3.0.9
71+
pyphen==0.15.0
72+
pysam==0.22.0
73+
python-dateutil==2.8.2
74+
Python-Deprecated==1.1.0
75+
pytz==2024.1
76+
PyYAML==6.0.1
77+
pyzmq==26.3.0
78+
referencing==0.36.2
79+
requests==2.32.3
80+
rpds-py==0.24.0
81+
scipy==1.12.0
82+
six==1.16.0
83+
sniffles==2.2
84+
soupsieve==2.6
85+
stack-data==0.6.3
86+
tenacity==8.2.3
87+
threadpoolctl==3.3.0
88+
tinycss2==1.3.0
89+
tornado==6.4.2
90+
traitlets==5.14.3
91+
typing_extensions==4.13.0
92+
tzdata==2024.1
93+
urllib3==1.26.15
94+
userpath==1.8.0
95+
virtualenv==20.14.1
96+
wcwidth==0.2.13
97+
webencodings==0.5.1
98+
yarg==0.1.9
99+
zipp==3.21.0
100+
zopfli==0.2.3

setup_vesper_env.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import os
2+
import subprocess
3+
import sys
4+
5+
def run_command(command, check=True):
6+
"""
7+
Runs a shell command and handles errors gracefully.
8+
"""
9+
try:
10+
print(f"Running: {command}")
11+
subprocess.run(command, shell=True, check=check, text=True)
12+
except subprocess.CalledProcessError as e:
13+
print(f"Error: Command '{command}' failed with exit code {e.returncode}")
14+
sys.exit(1)
15+
16+
def patch_cstag_lazy_import():
17+
"""
18+
Patch cstag's to_pdf.py to lazy-import weasyprint only when needed.
19+
"""
20+
to_pdf_path = os.path.join(sys.prefix, "lib", "python3.9", "site-packages", "cstag", "to_pdf.py")
21+
22+
if not os.path.exists(to_pdf_path):
23+
print(f"⚠️ cstag's to_pdf.py not found at {to_pdf_path}. Skipping patch.")
24+
return
25+
26+
with open(to_pdf_path, "r") as f:
27+
lines = f.readlines()
28+
29+
new_lines = []
30+
import_removed = False
31+
for line in lines:
32+
if "from weasyprint import HTML" in line and not import_removed:
33+
print("🔧 Removing top-level weasyprint import...")
34+
import_removed = True
35+
continue
36+
new_lines.append(line)
37+
38+
for i, line in enumerate(new_lines):
39+
if line.strip().startswith("def to_pdf("):
40+
indent = ' ' * (len(line) - len(line.lstrip()) + 4)
41+
new_lines.insert(i + 1, f"{indent}from weasyprint import HTML # lazy import\n")
42+
print("✅ Injected lazy import inside `to_pdf()`.")
43+
break
44+
else:
45+
print("❌ Couldn't find `def to_pdf()` in cstag. No changes made.")
46+
return
47+
48+
with open(to_pdf_path, "w") as f:
49+
f.writelines(new_lines)
50+
51+
print("🎉 Successfully patched cstag to lazy-load weasyprint.")
52+
53+
def main():
54+
### ensure script is running in a virtual environment ###
55+
if not hasattr(sys, 'real_prefix') and not (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix):
56+
print("Please activate your virtual environment before running this script.")
57+
sys.exit(1)
58+
59+
### Define installation path ###
60+
env_bin = os.path.join(sys.prefix, "bin")
61+
62+
print(f"Virtual environment detected: {sys.prefix}")
63+
print(f"Installing tools into: {env_bin}")
64+
65+
### Upgrade pip and install Python dependencies ###
66+
run_command("pip install --upgrade pip")
67+
run_command("pip install -r requirements.txt")
68+
69+
### Install Samtools ###
70+
run_command("wget https://github.com/samtools/samtools/releases/download/1.16.1/samtools-1.16.1.tar.bz2")
71+
run_command("tar -xvjf samtools-1.16.1.tar.bz2")
72+
run_command("cd samtools-1.16.1 && ./configure --prefix=$VIRTUAL_ENV --disable-lzma --without-curses && make && make install && cd ..")
73+
74+
### Patch cstag's PDF import ###
75+
patch_cstag_lazy_import()
76+
77+
### Clean up temporary files ###
78+
run_command("rm -f samtools-1.16.1.tar.bz2")
79+
run_command("rm -rf samtools-1.16.1")
80+
81+
### Verify installations ###
82+
run_command(f"{env_bin}/samtools --version")
83+
84+
print("\nAll tools installed successfully!")
85+
86+
if __name__ == "__main__":
87+
main()

0 commit comments

Comments
 (0)