From 9b9accdd687b1565f061baa149b274fd18a898e2 Mon Sep 17 00:00:00 2001 From: Linlang Date: Tue, 17 Dec 2024 20:22:19 +0800 Subject: [PATCH] fix build error --- .github/workflows/python-publish.yml | 6 +--- setup.cfg | 3 -- setup.py | 41 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 8 deletions(-) delete mode 100644 setup.cfg create mode 100644 setup.py diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 7f8226f87..46dd9b388 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -49,13 +49,9 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - # - name: update gcc - # run: | - # yum install -y centos-release-scl - # yum install -y devtoolset-8-gcc devtoolset-8-gcc-c++ - name: Install dependencies run: | - pip install twine + python -m pip list - name: Build and publish run: | ls dist diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b406f824c..000000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[metadata] -name = qlib -version = attr: qlib.__version__ diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..d9e338315 --- /dev/null +++ b/setup.py @@ -0,0 +1,41 @@ +from setuptools import setup, Extension +import numpy +import os + + +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() + + +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.") + + +NUMPY_INCLUDE = numpy.get_include() + +VERSION = get_version("qlib/__init__.py") + + +setup( + version=VERSION, + ext_modules=[ + Extension( + "qlib.data._libs.rolling", + ["qlib/data/_libs/rolling.pyx"], + language="c++", + include_dirs=[NUMPY_INCLUDE], + ), + Extension( + "qlib.data._libs.expanding", + ["qlib/data/_libs/expanding.pyx"], + language="c++", + include_dirs=[NUMPY_INCLUDE], + ), + ] +)