Spaces:
Runtime error
Runtime error
Create fix_qlib_version.py
Browse files- fix_qlib_version.py +30 -0
fix_qlib_version.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
file_path = '/app/qlib/source/qlib/__init__.py'
|
| 5 |
+
|
| 6 |
+
# 读取文件
|
| 7 |
+
with open(file_path, 'r') as f:
|
| 8 |
+
lines = f.readlines()
|
| 9 |
+
|
| 10 |
+
# 修改内容
|
| 11 |
+
new_lines = []
|
| 12 |
+
skip_next = False
|
| 13 |
+
for i, line in enumerate(lines):
|
| 14 |
+
if 'from setuptools_scm import get_version' in line:
|
| 15 |
+
new_lines.append('try:\n')
|
| 16 |
+
new_lines.append(' from setuptools_scm import get_version\n')
|
| 17 |
+
skip_next = True
|
| 18 |
+
elif skip_next and '__version__ = get_version' in line:
|
| 19 |
+
new_lines.append(' ' + line)
|
| 20 |
+
new_lines.append('except LookupError:\n')
|
| 21 |
+
new_lines.append(' __version__ = "0.9.0"\n')
|
| 22 |
+
skip_next = False
|
| 23 |
+
else:
|
| 24 |
+
new_lines.append(line)
|
| 25 |
+
|
| 26 |
+
# 写回文件
|
| 27 |
+
with open(file_path, 'w') as f:
|
| 28 |
+
f.writelines(new_lines)
|
| 29 |
+
|
| 30 |
+
print("Fixed qlib version detection")
|