Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"qlib/data/_libs/rolling" can not be import #1880

Open
Peakara opened this issue Dec 29, 2024 · 2 comments
Open

"qlib/data/_libs/rolling" can not be import #1880

Peakara opened this issue Dec 29, 2024 · 2 comments
Labels
question Further information is requested

Comments

@Peakara
Copy link

Peakara commented Dec 29, 2024

❓ Questions and Help

We sincerely suggest you to carefully read the documentation of our library as well as the official paper. After that, if you still feel puzzled, please describe the question clearly under this issue.

location in : qlib/data/_libs/
expanding, rolling can't import beacause of ".pyx" file.

@Peakara Peakara added the question Further information is requested label Dec 29, 2024
@Peakara
Copy link
Author

Peakara commented Dec 29, 2024

  1. we can create "setup.py" in the same directory of rolling.pyx and expanding.pyx
  2. in this directory, run command: python setup.py build _ext --inplace

##############
#用于转换pyx文件#
##############

#命令行运行:python setup.py build_ext --inplace

from setuptools import setup, Extension
from Cython.Build import cythonize
import numpy

#定义扩展模块
extensions = [
Extension(
"expanding", # 模块名
["expanding.pyx"], # 源文件
include_dirs=[numpy.get_include()], # 添加 NumPy 头文件路径
extra_compile_args=["-O3"], # 编译参数
extra_link_args=["-Wl,-rpath,/usr/local/lib"], # 链接参数
language="c++", # 使用 C++ 编译器
),
Extension(
"rolling", # 模块名
["rolling.pyx"], # 源文件
include_dirs=[numpy.get_include()], # 添加 NumPy 头文件路径
extra_compile_args=["-O3"], # 编译参数
extra_link_args=["-Wl,-rpath,/usr/local/lib"], # 链接参数
language="c++", # 使用 C++ 编译器
),
]

#配置 setup
setup(
ext_modules=cythonize(
extensions,
compiler_directives={"language_level": "3"} # Python 3 语法
),
)

@SunsetWolf
Copy link
Collaborator

Hi, @Peakara
I saw your issue and tried to reproduce your problem, I created a new python 3.10 virtual environment, pulled the latest code, built it using python setup.py build_ext --inplace and tried to run examples/benchmarks/LightGBM/ workflow_config_lightgbm_Alpha158.yaml and everything seems to work fine, providing more information to help us reproduce the problem.
Also, we have recently made some upgrades from setup.py to pyproject.toml and created a Makefile, you can try pull the latest code and installing it using make install or make dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants