mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-11 14:56:55 +08:00
40
.github/workflows/python-publish.yml
vendored
40
.github/workflows/python-publish.yml
vendored
@@ -12,15 +12,18 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-latest]
|
os: [windows-latest, macos-13, macos-latest]
|
||||||
# FIXME: macos-latest will raise error now.
|
|
||||||
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
|
|
||||||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||||
|
exclude:
|
||||||
|
- os: macos-13
|
||||||
|
python-version: "3.11"
|
||||||
|
- os: macos-13
|
||||||
|
python-version: "3.12"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@@ -29,33 +32,34 @@ jobs:
|
|||||||
- name: Build wheel on ${{ matrix.os }}
|
- name: Build wheel on ${{ matrix.os }}
|
||||||
run: |
|
run: |
|
||||||
make build
|
make build
|
||||||
- name: Build and publish
|
- name: Upload to PyPi
|
||||||
env:
|
env:
|
||||||
TWINE_USERNAME: __token__
|
TWINE_USERNAME: __token__
|
||||||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
twine upload dist/*
|
twine check dist/*.whl
|
||||||
|
twine upload dist/*.whl --verbose
|
||||||
|
|
||||||
deploy_with_manylinux:
|
deploy_with_manylinux:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Build wheel on Linux
|
- name: Build wheel on Linux
|
||||||
uses: RalfG/python-wheels-manylinux-build@v0.3.1-manylinux2010_x86_64
|
uses: RalfG/python-wheels-manylinux-build@v0.7.1-manylinux2014_x86_64
|
||||||
with:
|
with:
|
||||||
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
|
python-versions: 'cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312'
|
||||||
python-versions: 'cp37-cp37m cp38-cp38'
|
|
||||||
build-requirements: 'numpy cython'
|
build-requirements: 'numpy cython'
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.7
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install twine
|
python -m pip install twine
|
||||||
- name: Build and publish
|
- name: Upload to PyPi
|
||||||
env:
|
env:
|
||||||
TWINE_USERNAME: __token__
|
TWINE_USERNAME: __token__
|
||||||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
twine upload dist/pyqlib-*-manylinux*.whl
|
twine check dist/pyqlib-*-manylinux*.whl
|
||||||
|
twine upload dist/pyqlib-*-manylinux*.whl --verbose
|
||||||
|
|||||||
30
.github/workflows/test_qlib_from_pip.yml
vendored
30
.github/workflows/test_qlib_from_pip.yml
vendored
@@ -13,30 +13,17 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# Since macos-latest changed from 12.7.4 to 14.4.1,
|
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-15]
|
||||||
# the minimum python version that matches a 14.4.1 version of macos is 3.10,
|
# In github action, using python 3.7, pip install will not match the latest version of the package.
|
||||||
# If you want to use python 3.7 in github action, then the latest macos system version is macos-13,
|
# Also, python 3.7 is no longer supported from macos-14, and will be phased out from macos-13 in the near future.
|
||||||
# after macos-13 python 3.7 is no longer supported.
|
# All things considered, we have removed python 3.7.
|
||||||
# so we limit the macos version to macos-13.
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||||
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13]
|
|
||||||
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
|
|
||||||
python-version: [3.7, 3.8]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Test qlib from pip
|
- name: Test qlib from pip
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Since version 3.7 of python for MacOS is installed in CI, version 3.7.17, this version causes "_bz not found error".
|
|
||||||
# So we make the version number of python 3.7 for MacOS more specific.
|
|
||||||
# refs: https://github.com/actions/setup-python/issues/682
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
if: (matrix.os == 'macos-latest' && matrix.python-version == '3.7') || (matrix.os == 'macos-13' && matrix.python-version == '3.7')
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: "3.7.16"
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
if: (matrix.os != 'macos-latest' || matrix.python-version != '3.7') && (matrix.os != 'macos-13' || matrix.python-version != '3.7')
|
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
@@ -47,13 +34,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Qlib installation test
|
- name: Qlib installation test
|
||||||
run: |
|
run: |
|
||||||
# 2024-05-30 scs has released a new version: 3.2.4.post2,
|
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pyqlib==0.9.5.80
|
||||||
# This will cause the CI to fail, so we have limited the version of scs for now.
|
|
||||||
python -m pip install "scs<=3.2.4"
|
|
||||||
python -m pip install pyqlib
|
|
||||||
|
|
||||||
- name: Install Lightgbm for MacOS
|
- name: Install Lightgbm for MacOS
|
||||||
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-latest' }}
|
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' }}
|
||||||
run: |
|
run: |
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)"
|
||||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm
|
HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm
|
||||||
|
|||||||
15
.github/workflows/test_qlib_from_source.yml
vendored
15
.github/workflows/test_qlib_from_source.yml
vendored
@@ -14,13 +14,10 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# Since macos-latest changed from 12.7.4 to 14.4.1,
|
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-15]
|
||||||
# the minimum python version that matches a 14.4.1 version of macos is 3.10,
|
# In github action, using python 3.7, pip install will not match the latest version of the package.
|
||||||
# If you want to use python 3.7 in github action, then the latest macos system version is macos-13,
|
# Also, python 3.7 is no longer supported from macos-14, and will be phased out from macos-13 in the near future.
|
||||||
# after macos-13 python 3.7 is no longer supported.
|
# All things considered, we have removed python 3.7.
|
||||||
# so we limit the macos version to macos-13.
|
|
||||||
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-latest]
|
|
||||||
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
|
|
||||||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -37,7 +34,7 @@ jobs:
|
|||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
|
|
||||||
- name: Installing pytorch for macos
|
- name: Installing pytorch for macos
|
||||||
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-latest' }}
|
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' }}
|
||||||
run: |
|
run: |
|
||||||
python -m pip install torch torchvision torchaudio
|
python -m pip install torch torchvision torchaudio
|
||||||
|
|
||||||
@@ -87,7 +84,7 @@ jobs:
|
|||||||
python scripts/get_data.py download_data --file_name rl_data.zip --target_dir tests/.data/rl
|
python scripts/get_data.py download_data --file_name rl_data.zip --target_dir tests/.data/rl
|
||||||
|
|
||||||
- name: Install Lightgbm for MacOS
|
- name: Install Lightgbm for MacOS
|
||||||
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-latest' }}
|
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' }}
|
||||||
run: |
|
run: |
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)"
|
||||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm
|
HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm
|
||||||
|
|||||||
13
.github/workflows/test_qlib_from_source_slow.yml
vendored
13
.github/workflows/test_qlib_from_source_slow.yml
vendored
@@ -14,13 +14,10 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# Since macos-latest changed from 12.7.4 to 14.4.1,
|
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-15]
|
||||||
# the minimum python version that matches a 14.4.1 version of macos is 3.10,
|
# In github action, using python 3.7, pip install will not match the latest version of the package.
|
||||||
# If you want to use python 3.7 in github action, then the latest macos system version is macos-13,
|
# Also, python 3.7 is no longer supported from macos-14, and will be phased out from macos-13 in the near future.
|
||||||
# after macos-13 python 3.7 is no longer supported.
|
# All things considered, we have removed python 3.7.
|
||||||
# so we limit the macos version to macos-13.
|
|
||||||
os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-latest]
|
|
||||||
# not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129
|
|
||||||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -41,7 +38,7 @@ jobs:
|
|||||||
python scripts/get_data.py qlib_data --name qlib_data_simple --target_dir ~/.qlib/qlib_data/cn_data --interval 1d --region cn
|
python scripts/get_data.py qlib_data --name qlib_data_simple --target_dir ~/.qlib/qlib_data/cn_data --interval 1d --region cn
|
||||||
|
|
||||||
- name: Install Lightgbm for MacOS
|
- name: Install Lightgbm for MacOS
|
||||||
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-latest' }}
|
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' }}
|
||||||
run: |
|
run: |
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)"
|
||||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm
|
HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -181,7 +181,7 @@ lint: black pylint flake8 mypy nbqa
|
|||||||
|
|
||||||
# Build the package.
|
# Build the package.
|
||||||
build:
|
build:
|
||||||
python -m build
|
python -m build --wheel
|
||||||
|
|
||||||
# Upload the package.
|
# Upload the package.
|
||||||
upload:
|
upload:
|
||||||
@@ -192,4 +192,4 @@ upload:
|
|||||||
########################################################################################
|
########################################################################################
|
||||||
|
|
||||||
docs-gen:
|
docs-gen:
|
||||||
python -m sphinx.cmd.build -W docs $(PUBLIC_DIR)
|
python -m sphinx.cmd.build -W docs $(PUBLIC_DIR)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ name = "pyqlib"
|
|||||||
dynamic = ["version"]
|
dynamic = ["version"]
|
||||||
description = "A Quantitative-research Platform"
|
description = "A Quantitative-research Platform"
|
||||||
requires-python = ">=3.8.0"
|
requires-python = ">=3.8.0"
|
||||||
|
readme = {file = "README.md", content-type = "text/markdown"}
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pyyaml",
|
"pyyaml",
|
||||||
|
|||||||
41
setup.py
Normal file
41
setup.py
Normal file
@@ -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],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user