This is an automated email from the ASF dual-hosted git repository.

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fury.git


The following commit(s) were added to refs/heads/main by this push:
     new 3a2fb0f0 feat(python): automatic release pyfury on macos and windows 
(#2045)
3a2fb0f0 is described below

commit 3a2fb0f0e22dc879b790d1aedfd691414a136b05
Author: Shawn Yang <[email protected]>
AuthorDate: Fri Feb 7 12:09:31 2025 +0800

    feat(python): automatic release pyfury on macos and windows (#2045)
    
    ## What does this PR do?
    
    - Add automatic release pyfury on macos windows
    - Fix windows wheel build missing add pyd files
    
    ## Related issues
    
    #798
    #1885
    
    ## Does this PR introduce any user-facing change?
    
    <!--
    If any user-facing interface changes, please [open an
    issue](https://github.com/apache/fury/issues/new/choose) describing the
    need to do so and update the document if necessary.
    -->
    
    - [ ] Does this PR introduce any public API change?
    - [ ] Does this PR introduce any binary protocol compatibility change?
    
    ## Benchmark
    
    <!--
    When the PR has an impact on performance (if you don't know whether the
    PR will have an impact on performance, you can submit the PR first, and
    if it will have impact on performance, the code reviewer will explain
    it), be sure to attach a benchmark data here.
    -->
---
 .github/workflows/release.yaml | 64 +++++++++++++++++++++++++-----------------
 ci/deploy.sh                   | 43 ++++++++++++++++++++++++----
 python/setup.py                |  1 +
 3 files changed, 76 insertions(+), 32 deletions(-)

diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 109204e9..a419dcd4 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 e989d4ee..4d5073f7 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 1fb1e766..e3c106a3 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -114,6 +114,7 @@ _pkg_files = [
     "*.so",
     "*.dylib",
     "*.dll",
+    "*.pyd",
 ]
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to