Skip to content

Commit 871e2bd

Browse files
authored
fix: robustness to higher Python versions
1 parent 59cc66a commit 871e2bd

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/abstractions/backends.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Edit flashinfer cascade.py to make it compatible with Python 3.8
22
from src.path import root
33
import os
4+
import platform
45

5-
path = os.path.join(
6-
os.environ["CONDA_PREFIX"], "lib/python3.8/site-packages/flashinfer/cascade.py"
7-
)
8-
with open(path, "r") as f:
9-
content = f.read()
10-
content = content.replace("list[", "List[").replace(
11-
"import Optional", "import List, Optional"
12-
)
13-
with open(path, "w") as f:
14-
f.write(content)
6+
if "3.8" in platform.python_version():
7+
path = os.path.join(
8+
os.environ["CONDA_PREFIX"], "lib/python3.8/site-packages/flashinfer/cascade.py"
9+
)
10+
with open(path, "r") as f:
11+
content = f.read()
12+
content = content.replace("list[", "List[").replace(
13+
"import Optional", "import List, Optional"
14+
)
15+
with open(path, "w") as f:
16+
f.write(content)
1517

1618
import torch
1719
import time

0 commit comments

Comments
 (0)