Skip to content

Commit

Permalink
feat(python): automatic release pyfury on macos and windows (#2045)
Browse files Browse the repository at this point in the history
## 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.
-->
  • Loading branch information
chaokunyang authored Feb 7, 2025
1 parent 0702b23 commit 3a2fb0f
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 32 deletions.
64 changes: 38 additions & 26 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,57 @@ 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

Check warning on line 32 in .github/workflows/release.yaml

View workflow job for this annotation

GitHub Actions / 🍏 YAML

32:63 [comments] too few spaces before comment

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
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/
43 changes: 37 additions & 6 deletions ci/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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() {
Expand All @@ -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
Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def parse_version():
"*.so",
"*.dylib",
"*.dll",
"*.pyd",
]


Expand Down

0 comments on commit 3a2fb0f

Please sign in to comment.