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 326dac8ed0..d7a8fc5fdf 100644 --- a/setup.py +++ b/setup.py @@ -2,22 +2,12 @@ import numpy from setuptools import Extension, setup -from setuptools_scm import get_version - - -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() -VERSION = get_version(root=".", relative_to=__file__) - setup( - version=VERSION, ext_modules=[ Extension( "qlib.data._libs.rolling",