From a7e2e23f543bf8be5f3c72ca78865a53604fd46d Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Mon, 13 Oct 2025 12:21:47 +0200 Subject: [PATCH 1/2] dont manually call setuptools_scm - its integrated setuptools_scm automatically set the version attribute - manually setting it wrong --- setup.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/setup.py b/setup.py index 326dac8ed0..60e39674a5 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,6 @@ import numpy from setuptools import Extension, setup -from setuptools_scm import get_version def read(rel_path: str) -> str: @@ -14,10 +13,7 @@ def read(rel_path: str) -> str: NUMPY_INCLUDE = numpy.get_include() -VERSION = get_version(root=".", relative_to=__file__) - setup( - version=VERSION, ext_modules=[ Extension( "qlib.data._libs.rolling", From d6529fa5f14df1d1d2f52edf5e73b823d79e7982 Mon Sep 17 00:00:00 2001 From: SunsetWolf Date: Mon, 10 Nov 2025 07:29:58 +0000 Subject: [PATCH 2/2] fix(docs): set fallback version for setuptools-scm to fix autodoc import errors on Read the Docs --- Makefile | 2 +- pyproject.toml | 1 + qlib/__init__.py | 5 ++++- setup.py | 6 ------ 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 6e13aa1364..6564c4247b 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,7 @@ dev: prerequisite all # Check lint with black. black: - black . -l 120 --check --diff + black . -l 120 --check --diff --exclude qlib/_version.py # Check code folder with pylint. # TODO: These problems we will solve in the future. Important among them are: W0221, W0223, W0237, E1102 diff --git a/pyproject.toml b/pyproject.toml index fe48d090c0..d8d8c833b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -117,3 +117,4 @@ qrun = "qlib.cli.run:run" [tool.setuptools_scm] local_scheme = "no-local-version" version_scheme = "guess-next-dev" +write_to = "qlib/_version.py" diff --git a/qlib/__init__.py b/qlib/__init__.py index 687e317ced..b43dd6fc42 100644 --- a/qlib/__init__.py +++ b/qlib/__init__.py @@ -4,7 +4,10 @@ from setuptools_scm import get_version -__version__ = get_version(root="..", relative_to=__file__) +try: + from ._version import version as __version__ +except ImportError: + __version__ = get_version(root="..", relative_to=__file__) __version__bak = __version__ # This version is backup for QlibConfig.reset_qlib_version import logging import os diff --git a/setup.py b/setup.py index 60e39674a5..d7a8fc5fdf 100644 --- a/setup.py +++ b/setup.py @@ -4,12 +4,6 @@ from setuptools import Extension, setup -def read(rel_path: str) -> str: - here = os.path.abspath(os.path.dirname(__file__)) - with open(os.path.join(here, rel_path), encoding="utf-8") as fp: - return fp.read() - - NUMPY_INCLUDE = numpy.get_include()