Skip to content

Commit 0a1ded4

Browse files
add pre-script for arm64 logic
1 parent 5979b5d commit 0a1ded4

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.github/workflows/build_wheel_windows_x64_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
include:
3636
- repository: pytorch/vision
3737
smoke-test-script: test/smoke_test.py
38+
pre-script: packaging/pre_build_script_arm64.sh
3839
package-name: torchvision
3940
architecture: "arm64"
4041
name: ${{ matrix.repository }}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
3+
echo "Building vision dependencies and wheel started."
4+
5+
# Set environment variables
6+
export SRC_PATH="$GITHUB_WORKSPACE/$SRC_DIR"
7+
export CMAKE_BUILD_TYPE="$BUILD_TYPE"
8+
export VCVARSALL_PATH="$DEPENDENCIES_DIR/VSBuildTools/VC/Auxiliary/Build/vcvarsall.bat"
9+
export CONDA_PREFIX="$DEPENDENCIES_DIR"
10+
export PATH="$PATH:$CONDA_PREFIX/Library/bin"
11+
export DISTUTILS_USE_SDK=1
12+
export TRIPLET_FILE="triplets/x64-windows.cmake"
13+
export PYTORCH_VERSION="$PYTORCH_VERSION"
14+
export CHANNEL="$CHANNEL"
15+
16+
echo "channel: $CHANNEL"
17+
18+
# Dependencies
19+
mkdir -p "$DOWNLOADS_DIR"
20+
mkdir -p "$DEPENDENCIES_DIR"
21+
echo "*" > "$DOWNLOADS_DIR/.gitignore"
22+
echo "*" > "$DEPENDENCIES_DIR/.gitignore"
23+
24+
# Install vcpkg
25+
cd "$DOWNLOADS_DIR" || exit
26+
git clone https://github.com/microsoft/vcpkg.git
27+
cd vcpkg || exit
28+
./bootstrap-vcpkg.sh
29+
30+
# # Set vcpkg to only build release packages
31+
echo "set(VCPKG_BUILD_TYPE release)" >> "$TRIPLET_FILE"
32+
33+
# Install dependencies using vcpkg
34+
./vcpkg install libjpeg-turbo:x64-windows --x-install-root="$DEPENDENCIES_DIR"
35+
./vcpkg install libwebp:x64-windows --x-install-root="$DEPENDENCIES_DIR"
36+
./vcpkg install libpng[tools]:x64-windows --x-install-root="$DEPENDENCIES_DIR"
37+
38+
# Copy files using cp (replace robocopy)
39+
cp "$DEPENDENCIES_DIR/x64-windows/lib/libpng16.lib" "$DEPENDENCIES_DIR/x64-windows/lib/libpng.lib"
40+
cp "$DEPENDENCIES_DIR/x64-windows/bin/libpng16.dll" "$DEPENDENCIES_DIR/x64-windows/bin/libpng.dll"
41+
cp "$DEPENDENCIES_DIR/x64-windows/bin/libpng16.pdb" "$DEPENDENCIES_DIR/x64-windows/bin/libpng.pdb"
42+
mkdir -p "$DEPENDENCIES_DIR/Library/"
43+
cp -r "$DEPENDENCIES_DIR/x64-windows/"* "$DEPENDENCIES_DIR/Library/"
44+
cp -r "$DEPENDENCIES_DIR/Library/tools/libpng/"* "$DEPENDENCIES_DIR/Library/bin/"
45+
cp -r "$DEPENDENCIES_DIR/Library/bin/"* "$SRC_PATH/torchvision"
46+
47+
# Source directory
48+
cd "$SRC_PATH" || exit
49+
50+
# Create virtual environment
51+
python -m pip install --upgrade pip
52+
python -m venv .venv
53+
echo "*" > .venv/.gitignore
54+
source .venv/Scripts/activate
55+
56+
# Install dependencies
57+
pip install numpy==2.2.3
58+
59+
if [ "$CHANNEL" = "release" ]; then
60+
echo "Installing latest stable version of PyTorch."
61+
pip3 install torch
62+
elif [ "$CHANNEL" = "test" ]; then
63+
echo "Installing PyTorch version $PYTORCH_VERSION."
64+
pip3 install torch=="$PYTORCH_VERSION"
65+
else
66+
echo "CHANNEL is not set, installing PyTorch from nightly."
67+
pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
68+
fi
69+
70+
# # Create wheel under dist folder
71+
# python setup.py bdist_wheel
72+
73+
# # Check if build was successful
74+
# if [[ $? -ne 0 ]]; then
75+
# echo "Failed on build_vision. (exit code = $?)"
76+
# exit 1
77+
# fi
78+
79+
echo "Dependencies install finished successfully."

0 commit comments

Comments
 (0)