diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 109204e976..a419dcd44f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,16 +23,14 @@ on: - "v*" jobs: - release-python: - name: Publish Fury Python to PyPI - runs-on: ubuntu-20.04 - if: github.repository == 'apache/fury' - environment: - name: pypi - url: https://pypi.org/project/pyfury + build-wheels: + name: Build Wheels + runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.8, 3.9, 3.10.12, 3.11, 3.12] + python-version: [3.8, 3.9, "3.10", 3.11, 3.12] + os: [ubuntu-latest, macos-13, macos-14, windows-2022] # macos-13: x86, macos-14: arm64 + steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -40,28 +38,42 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install bazel - run: ./ci/run_ci.sh install_bazel - - name: Update version in setup.py + shell: bash run: | - echo "GITHUB_REF: $GITHUB_REF" - tag=$(echo $GITHUB_REF | cut -d / -f 3) - echo "tag: $tag" - version=${tag:1} - echo "version $version" - ci/deploy.sh bump_py_version $version + if [ "$RUNNER_OS" == "Windows" ]; then + ./ci/run_ci.sh install_bazel_windows + else + ./ci/run_ci.sh install_bazel + fi + - name: Update version in setup.py + shell: bash + run: ci/deploy.sh bump_py_version - name: Build a binary wheel + shell: bash run: | - ci/deploy.sh install_pyarrow - pip install setuptools wheel Cython numpy pytest - cd python - pip list - export PATH=~/bin:$PATH - echo "Build pyfury" - python setup.py bdist_wheel --dist-dir=../dist - ../ci/deploy.sh rename_linux_wheels $PWD/../dist - - name: Publish wheel to PyPI + ci/deploy.sh build_pyfury + ci/deploy.sh rename_wheels dist + - name: Upload Wheel Artifact + uses: actions/upload-artifact@v4 + with: + name: pyfury-wheels-${{ matrix.os }}-${{ matrix.python-version }} + path: dist/*.whl + + publish-wheels: + name: Publish Wheels + runs-on: ubuntu-latest + needs: build-wheels + steps: + - name: Download Wheel Artifacts + uses: actions/download-artifact@v4 + with: + path: downloaded_wheels/ + merge-multiple: true + - name: Display structure of downloaded files + run: ls -R downloaded_wheels + - name: Publish Wheels to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} - packages-dir: dist + packages-dir: downloaded_wheels/ diff --git a/ci/deploy.sh b/ci/deploy.sh index e989d4eee5..4d5073f7e4 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -55,10 +55,20 @@ create_py_envs() { conda env list } -rename_linux_wheels() { +rename_wheels() { for path in "$1"/*.whl; do if [ -f "${path}" ]; then - mv "${path}" "${path//linux/manylinux1}" + # Rename linux to manylinux1 + new_path="${path//linux/manylinux1}" + if [ "${path}" != "${new_path}" ]; then + mv "${path}" "${new_path}" + fi + + # Copy macosx_14_0_x86_64 to macosx_10_12_x86_64 + if [[ "${path}" == *macosx_14_0_x86_64.whl ]]; then + copy_path="${path//macosx_14_0_x86_64/macosx_10_12_x86_64}" + mv "${path}" "${copy_path}" + fi fi done } @@ -80,7 +90,16 @@ bump_java_version() { } bump_py_version() { - python "$ROOT/ci/release.py" bump_version -l python -version "$1" + local version="$1" + if [ -z "$version" ]; then + # Get the latest tag from the current Git repository + version=$(git describe --tags --abbrev=0) + # Check if the tag starts with 'v' and strip it + if [[ $version == v* ]]; then + version="${version:1}" + fi + fi + python "$ROOT/ci/release.py" bump_version -l python -version "$version" } bump_javascript_version() { @@ -92,6 +111,20 @@ deploy_jars() { mvn -T10 clean deploy --no-transfer-progress -DskipTests -Prelease } +build_pyfury() { + echo "Python version $(python -V), path $(which python)" + install_pyarrow + pip install Cython wheel "numpy<2.0.0" pytest + pushd "$ROOT/python" + pip list + echo "Install pyfury" + # Fix strange installed deps not found + pip install setuptools -U + bazel build //:cp_fury_so + python setup.py bdist_wheel --dist-dir=../dist + popd +} + deploy_python() { source $(conda info --base)/etc/profile.d/conda.sh if command -v pyenv; then @@ -118,9 +151,7 @@ deploy_python() { python setup.py bdist_wheel mv dist/pyfury*.whl "$WHEEL_DIR" done - if [[ "$OSTYPE" == "linux"* ]]; then - rename_linux_wheels "$WHEEL_DIR" - fi + rename_wheels "$WHEEL_DIR" twine check "$WHEEL_DIR"/pyfury*.whl twine upload -r pypi "$WHEEL_DIR"/pyfury*.whl } diff --git a/python/setup.py b/python/setup.py index 1fb1e76603..e3c106a3f0 100644 --- a/python/setup.py +++ b/python/setup.py @@ -114,6 +114,7 @@ def parse_version(): "*.so", "*.dylib", "*.dll", + "*.pyd", ]