diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index ef0aa98e48..ebaf2cffe7 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -12,15 +12,18 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-latest] - # FIXME: macos-latest will raise error now. - # not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129 + os: [windows-latest, macos-13, macos-latest] 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: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -29,33 +32,34 @@ jobs: - name: Build wheel on ${{ matrix.os }} run: | make build - - name: Build and publish + - name: Upload to PyPi env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | - twine upload dist/* + twine check dist/*.whl + twine upload dist/*.whl --verbose deploy_with_manylinux: runs-on: ubuntu-latest 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 - 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: - # not supporting 3.6 due to annotations is not supported https://stackoverflow.com/a/52890129 - python-versions: 'cp37-cp37m cp38-cp38' + python-versions: 'cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312' build-requirements: 'numpy cython' - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.7 - name: Install dependencies run: | - pip install twine - - name: Build and publish + python -m pip install twine + - name: Upload to PyPi env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | - twine upload dist/pyqlib-*-manylinux*.whl + twine check dist/pyqlib-*-manylinux*.whl + twine upload dist/pyqlib-*-manylinux*.whl --verbose diff --git a/.github/workflows/test_qlib_from_pip.yml b/.github/workflows/test_qlib_from_pip.yml index 65e31131a8..4efe10dc42 100644 --- a/.github/workflows/test_qlib_from_pip.yml +++ b/.github/workflows/test_qlib_from_pip.yml @@ -13,30 +13,17 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - # Since macos-latest changed from 12.7.4 to 14.4.1, - # the minimum python version that matches a 14.4.1 version of macos is 3.10, - # If you want to use python 3.7 in github action, then the latest macos system version is macos-13, - # after macos-13 python 3.7 is no longer supported. - # so we limit the macos version to macos-13. - 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] + os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-15] + # In github action, using python 3.7, pip install will not match the latest version of the package. + # Also, python 3.7 is no longer supported from macos-14, and will be phased out from macos-13 in the near future. + # All things considered, we have removed python 3.7. + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - name: Test qlib from pip 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 }} - 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 with: python-version: ${{ matrix.python-version }} @@ -47,13 +34,10 @@ jobs: - name: Qlib installation test run: | - # 2024-05-30 scs has released a new version: 3.2.4.post2, - # 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 + python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pyqlib==0.9.5.80 - 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: | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)" HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm diff --git a/.github/workflows/test_qlib_from_source.yml b/.github/workflows/test_qlib_from_source.yml index 4dfa1f1cb2..9d36479790 100644 --- a/.github/workflows/test_qlib_from_source.yml +++ b/.github/workflows/test_qlib_from_source.yml @@ -14,13 +14,10 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - # Since macos-latest changed from 12.7.4 to 14.4.1, - # the minimum python version that matches a 14.4.1 version of macos is 3.10, - # If you want to use python 3.7 in github action, then the latest macos system version is macos-13, - # after macos-13 python 3.7 is no longer supported. - # 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 + os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-15] + # In github action, using python 3.7, pip install will not match the latest version of the package. + # Also, python 3.7 is no longer supported from macos-14, and will be phased out from macos-13 in the near future. + # All things considered, we have removed python 3.7. python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: @@ -37,7 +34,7 @@ jobs: python -m pip install --upgrade pip - 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: | 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 - 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: | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)" HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm diff --git a/.github/workflows/test_qlib_from_source_slow.yml b/.github/workflows/test_qlib_from_source_slow.yml index d302fe3072..21e2f2ef37 100644 --- a/.github/workflows/test_qlib_from_source_slow.yml +++ b/.github/workflows/test_qlib_from_source_slow.yml @@ -14,13 +14,10 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - # Since macos-latest changed from 12.7.4 to 14.4.1, - # the minimum python version that matches a 14.4.1 version of macos is 3.10, - # If you want to use python 3.7 in github action, then the latest macos system version is macos-13, - # after macos-13 python 3.7 is no longer supported. - # 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 + os: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-13, macos-14, macos-15] + # In github action, using python 3.7, pip install will not match the latest version of the package. + # Also, python 3.7 is no longer supported from macos-14, and will be phased out from macos-13 in the near future. + # All things considered, we have removed python 3.7. python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] 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 - 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: | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Microsoft/qlib/main/.github/brew_install.sh)" HOMEBREW_NO_AUTO_UPDATE=1 brew install lightgbm diff --git a/Makefile b/Makefile index 27824a6d3d..03dfc7310c 100644 --- a/Makefile +++ b/Makefile @@ -181,7 +181,7 @@ lint: black pylint flake8 mypy nbqa # Build the package. build: - python -m build + python -m build --wheel # Upload the package. upload: @@ -192,4 +192,4 @@ upload: ######################################################################################## docs-gen: - python -m sphinx.cmd.build -W docs $(PUBLIC_DIR) \ No newline at end of file + python -m sphinx.cmd.build -W docs $(PUBLIC_DIR) diff --git a/pyproject.toml b/pyproject.toml index 547625d53e..bb8cb07f26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ name = "pyqlib" dynamic = ["version"] description = "A Quantitative-research Platform" requires-python = ">=3.8.0" +readme = {file = "README.md", content-type = "text/markdown"} dependencies = [ "pyyaml", diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b406f824c8..0000000000 --- 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 0000000000..96b2f59dce --- /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], + ), + ], +)