diff --git a/qlib/__init__.py b/qlib/__init__.py index 19a7e09af..fe217f491 100644 --- a/qlib/__init__.py +++ b/qlib/__init__.py @@ -2,8 +2,7 @@ # Licensed under the MIT License. from pathlib import Path -_version_path = Path(__file__).absolute().parent / "VERSION.txt" # This file is copyed from setup.py -__version__ = _version_path.read_text(encoding="utf-8").strip() +__version__ = "0.8.0.99" __version__bak = __version__ # This version is backup for QlibConfig.reset_qlib_version import os from typing import Union diff --git a/setup.py b/setup.py index 870dca698..508824955 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,21 @@ import numpy from setuptools import find_packages, setup, Extension + +def read(rel_path: str) -> str: + here = os.path.abspath(os.path.dirname(__file__)) + with open(os.path.join(here, rel_path)) as fp: + return fp.read() + + +def get_version(rel_path: str) -> str: + for line in read(rel_path).splitlines(): + if line.startswith("__version__"): + delim = '"' if '"' in line else "'" + return line.split(delim)[1] + raise RuntimeError("Unable to find version string.") + + # Package meta-data. NAME = "pyqlib" DESCRIPTION = "A Quantitative-research Platform" @@ -14,11 +29,7 @@ REQUIRES_PYTHON = ">=3.5.0" from pathlib import Path from shutil import copyfile -CURRENT_DIR = Path(__file__).absolute().parent -_version_src = CURRENT_DIR / "VERSION.txt" -_version_dst = CURRENT_DIR / "qlib" / "VERSION.txt" -copyfile(_version_src, _version_dst) -VERSION = _version_dst.read_text(encoding="utf-8").strip() +VERSION = get_version("qlib/__init__.py") # Detect Cython try: