diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 089f0fd357b..ae1abe97835 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,16 @@ name: Release + on: push: - branches: - - main + branches: [ main ] + pull_request: + branches: [ main ] + + #on: + # push: + # branches: + # - main permissions: contents: read @@ -31,30 +38,30 @@ jobs: steps: - uses: actions/checkout@v4 - if: needs.release.outputs.release_created == 'true' + #if: needs.release.outputs.release_created == 'true' with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - if: needs.release.outputs.release_created == 'true' + #if: needs.release.outputs.release_created == 'true' uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Build wheel on Linux - if: needs.release.outputs.release_created == 'true' + #if: needs.release.outputs.release_created == 'true' uses: RalfG/python-wheels-manylinux-build@v0.7.1-manylinux2014_x86_64 with: python-versions: 'cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312' build-requirements: 'numpy cython' - name: Install dependencies - if: needs.release.outputs.release_created == 'true' + #if: needs.release.outputs.release_created == 'true' run: | python -m pip install twine - name: Upload to PyPi - if: needs.release.outputs.release_created == 'true' + #if: needs.release.outputs.release_created == 'true' env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.TESTPYPI }} @@ -77,28 +84,28 @@ jobs: steps: - uses: actions/checkout@v4 - if: needs.release.outputs.release_created == 'true' + #if: needs.release.outputs.release_created == 'true' with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - if: needs.release.outputs.release_created == 'true' + #if: needs.release.outputs.release_created == 'true' uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies - if: needs.release.outputs.release_created == 'true' + #if: needs.release.outputs.release_created == 'true' run: | make dev - name: Build wheel on ${{ matrix.os }} - if: needs.release.outputs.release_created == 'true' + #if: needs.release.outputs.release_created == 'true' run: | make build - name: Upload to PyPi - if: needs.release.outputs.release_created == 'true' + #if: needs.release.outputs.release_created == 'true' env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.TESTPYPI }} diff --git a/Makefile b/Makefile index 6e13aa13641..95d0737f211 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,7 @@ dev: prerequisite all # Check lint with black. black: - black . -l 120 --check --diff + black . -l 120 --check --diff --exclude qlib/_version.py # Check code folder with pylint. # TODO: These problems we will solve in the future. Important among them are: W0221, W0223, W0237, E1102 @@ -195,7 +195,7 @@ lint: black pylint flake8 mypy nbqa # Build the package. build: - python -m build --wheel + python -m build # Upload the package. upload: diff --git a/pyproject.toml b/pyproject.toml index fe48d090c0b..d8d8c833b81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -117,3 +117,4 @@ qrun = "qlib.cli.run:run" [tool.setuptools_scm] local_scheme = "no-local-version" version_scheme = "guess-next-dev" +write_to = "qlib/_version.py" diff --git a/qlib/__init__.py b/qlib/__init__.py index 687e317ced7..b43dd6fc42a 100644 --- a/qlib/__init__.py +++ b/qlib/__init__.py @@ -4,7 +4,10 @@ from setuptools_scm import get_version -__version__ = get_version(root="..", relative_to=__file__) +try: + from ._version import version as __version__ +except ImportError: + __version__ = get_version(root="..", relative_to=__file__) __version__bak = __version__ # This version is backup for QlibConfig.reset_qlib_version import logging import os diff --git a/setup.py b/setup.py index 8c7127613ee..d7a8fc5fdf9 100644 --- a/setup.py +++ b/setup.py @@ -4,15 +4,9 @@ from setuptools import Extension, setup -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() - - NUMPY_INCLUDE = numpy.get_include() -# delete setuptools_scm + setup( ext_modules=[ Extension(