Skip to content

Commit d6529fa

Browse files
committed
fix(docs): set fallback version for setuptools-scm to fix autodoc import errors on Read the Docs
1 parent a7e2e23 commit d6529fa

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ dev: prerequisite all
113113

114114
# Check lint with black.
115115
black:
116-
black . -l 120 --check --diff
116+
black . -l 120 --check --diff --exclude qlib/_version.py
117117

118118
# Check code folder with pylint.
119119
# TODO: These problems we will solve in the future. Important among them are: W0221, W0223, W0237, E1102

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,4 @@ qrun = "qlib.cli.run:run"
117117
[tool.setuptools_scm]
118118
local_scheme = "no-local-version"
119119
version_scheme = "guess-next-dev"
120+
write_to = "qlib/_version.py"

qlib/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
from setuptools_scm import get_version
66

7-
__version__ = get_version(root="..", relative_to=__file__)
7+
try:
8+
from ._version import version as __version__
9+
except ImportError:
10+
__version__ = get_version(root="..", relative_to=__file__)
811
__version__bak = __version__ # This version is backup for QlibConfig.reset_qlib_version
912
import logging
1013
import os

setup.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
from setuptools import Extension, setup
55

66

7-
def read(rel_path: str) -> str:
8-
here = os.path.abspath(os.path.dirname(__file__))
9-
with open(os.path.join(here, rel_path), encoding="utf-8") as fp:
10-
return fp.read()
11-
12-
137
NUMPY_INCLUDE = numpy.get_include()
148

159

0 commit comments

Comments
 (0)