Skip to content

Commit 9004a03

Browse files
authored
fix(python): fix pyfory pypi release (#2473)
## What does this PR do? <!-- Describe the purpose of this PR. --> ## Related issues #2381 #2472 Closes #2471 ## Does this PR introduce any user-facing change? <!-- If any user-facing interface changes, please [open an issue](https://github.com/apache/fory/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. -->
1 parent 9a246c5 commit 9004a03

2 files changed

Lines changed: 35 additions & 29 deletions

File tree

.github/workflows/release.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,26 @@ jobs:
6969
DOCKER_IMAGE="${{ env.manylinux_aarch64_image }}"
7070
PLAT="manylinux_2_28_aarch64"
7171
fi
72-
docker run --rm -e PLAT=$PLAT \
72+
PY_VERSION=${{ matrix.python-version }}
73+
echo "PY_VERSION: $PY_VERSION"
74+
PY_VERSION=${PY_VERSION//./}
75+
echo "PY_VERSION without dots: $PY_VERSION"
76+
docker run --rm -e PY_VERSION="$PY_VERSION" -e PLAT="$PLAT" \
7377
-v ${{ github.workspace }}:/work \
7478
-w /work "$DOCKER_IMAGE" \
7579
bash -c "
7680
set -e
77-
# Install build dependencies inside the container
7881
yum install -y git sudo wget
7982
git config --global --add safe.directory /work
80-
81-
# Install Bazel inside the container
83+
ls -alh /opt/python
84+
echo \"PY_VERSION: \$PY_VERSION\"
85+
ls /opt/python/cp\${PY_VERSION}-cp\${PY_VERSION}
86+
ls /opt/python/cp\${PY_VERSION}-cp\${PY_VERSION}/bin
87+
export PATH=/opt/python/cp\${PY_VERSION}-cp\${PY_VERSION}/bin:\$PATH
88+
echo \"PATH: \$PATH\"
89+
echo \"Using Python from: \$(which python)\"
90+
echo \"Python version: \$(python -V)\"
8291
bash ci/run_ci.sh install_bazel
83-
84-
# Build the wheel inside the container
8592
bash ci/deploy.sh build_pyfory
8693
"
8794
@@ -118,10 +125,12 @@ jobs:
118125
with:
119126
repository-url: https://test.pypi.org/legacy/
120127
skip-existing: true
128+
verify-metadata: false
121129
packages-dir: downloaded_wheels
122130
- name: Publish to PyPI
123131
uses: pypa/gh-action-pypi-publish@release/v1
124132
if: ${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-') }}
125133
with:
126134
skip-existing: true
135+
verify-metadata: false
127136
packages-dir: downloaded_wheels

ci/deploy.sh

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,40 +72,37 @@ build_pyfory() {
7272
# Fix strange installed deps not found
7373
pip install setuptools -U
7474

75-
# Detect host architecture and only pass x86_64 config when appropriate
76-
ARCH=$(uname -m)
77-
if [[ "$ARCH" == "x86_64" || "$ARCH" == "amd64" ]]; then
78-
bazel build --config=x86_64 //:cp_fory_so
79-
else
80-
bazel build //:cp_fory_so
81-
fi
82-
8375
python setup.py bdist_wheel --dist-dir=../dist
76+
ls -l ../dist
8477

8578
if [ -n "$PLAT" ]; then
8679
# In manylinux container, repair the wheel to embed shared libraries
8780
# and rename the wheel with the manylinux tag.
8881
PYARROW_LIB_DIR=$(python -c 'import pyarrow; print(":".join(pyarrow.get_library_dirs()))')
8982
export LD_LIBRARY_PATH="$PYARROW_LIB_DIR:$LD_LIBRARY_PATH"
90-
auditwheel repair ../dist/pyfory-*-linux_*.whl --plat "$PLAT" -w ../dist/
83+
auditwheel repair ../dist/pyfory-*-linux_*.whl --plat "$PLAT" --exclude '*arrow*' --exclude '*parquet*' --exclude '*numpy*' -w ../dist/
9184
rm ../dist/pyfory-*-linux_*.whl
9285
elif [[ "$OSTYPE" == "darwin"* ]]; then
93-
# macOS: use delocate to bundle dependencies and fix wheel tags
94-
pip install delocate
95-
mkdir -p ../dist_repaired
96-
delocate-wheel -w ../dist_repaired/ ../dist/pyfory-*-macosx*.whl
97-
rm ../dist/pyfory-*-macosx*.whl
98-
mv ../dist_repaired/* ../dist/
99-
rmdir ../dist_repaired
86+
# Check macOS version
87+
MACOS_VERSION=$(sw_vers -productVersion | cut -d. -f1-2)
88+
if [[ "$MACOS_VERSION" == "13"* ]]; then
89+
# Check if wheel ends with x86_64.whl
90+
for wheel in ../dist/pyfory-*-macosx*.whl; do
91+
if [[ "$wheel" == *"x86_64.whl" ]]; then
92+
echo "Fixing wheel tags for x86_64 wheel: $wheel"
93+
wheel tags --platform-tag macosx_12_0_x86_64 "$wheel"
94+
else
95+
echo "Skipping wheel tags for non-x86_64 wheel: $wheel"
96+
fi
97+
done
98+
else
99+
# Other macOS versions: skip wheel repair
100+
echo "Skipping wheel repair for macOS $MACOS_VERSION"
101+
fi
100102
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
101-
# Windows: use delvewheel to bundle dependencies
102-
pip install delvewheel
103-
mkdir -p ../dist_repaired
104-
delvewheel repair ../dist/pyfory-*-win*.whl -w ../dist_repaired/
105-
rm ../dist/pyfory-*-win*.whl
106-
mv ../dist_repaired/* ../dist/
107-
rmdir ../dist_repaired
103+
echo "Skip windows wheel repair"
108104
fi
105+
ls -l ../dist
109106
popd
110107
}
111108

0 commit comments

Comments
 (0)