Skip to content

Commit ac3fe94

Browse files
chore(build): rely on integrated setuptools_scm instead of manual call (#2032)
* dont manually call setuptools_scm - its integrated setuptools_scm automatically set the version attribute - manually setting it wrong * fix(docs): set fallback version for setuptools-scm to fix autodoc import errors on Read the Docs --------- Co-authored-by: SunsetWolf <[email protected]>
1 parent 66c3622 commit ac3fe94

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
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 & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,12 @@
22

33
import numpy
44
from setuptools import Extension, setup
5-
from setuptools_scm import get_version
6-
7-
8-
def read(rel_path: str) -> str:
9-
here = os.path.abspath(os.path.dirname(__file__))
10-
with open(os.path.join(here, rel_path), encoding="utf-8") as fp:
11-
return fp.read()
125

136

147
NUMPY_INCLUDE = numpy.get_include()
158

169

17-
VERSION = get_version(root=".", relative_to=__file__)
18-
1910
setup(
20-
version=VERSION,
2111
ext_modules=[
2212
Extension(
2313
"qlib.data._libs.rolling",

0 commit comments

Comments
 (0)