Skip to content

Commit ccf26c7

Browse files
committed
Updating build script w.r.t. new guidelines
1 parent 48fa330 commit ccf26c7

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

o/onnxruntime/onnxruntime_ubi_9.7.sh

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,27 @@
1818
#
1919
# ----------------------------------------------------------------------------
2020

21-
#variables
21+
# Variables
2222
PACKAGE_NAME=onnxruntime
2323
PACKAGE_VERSION=${1:-v1.22.1}
2424
PACKAGE_URL=https://github.com/microsoft/onnxruntime.git
25+
CURRENT_DIR=${PWD}
2526

2627
# Install dependencies
27-
python -m pip install numpy setuptools wheel build packaging "cmake>=3.28,<4.0" pytest
28+
yum install -y python3.11 python3.11-pip python3.11-devel gcc gcc-c++ git
29+
30+
# Install Python dependencies
31+
python3 -m pip install numpy setuptools wheel build packaging "cmake>=3.28,<4.0" pytest
2832

2933
# Add user's local bin to PATH for user-installed packages
3034
export PATH="$HOME/.local/bin:$PATH"
3135

3236
# Make sure the pip-installed cmake takes precedence over the system one
33-
SITE_PACKAGES=$(python -c 'import site; print(site.getsitepackages()[0])' 2>/dev/null || python -c 'import site; print(site.getusersitepackages())')
37+
SITE_PACKAGES=$(python3 -c 'import site; print(site.getsitepackages()[0])' 2>/dev/null || python3 -c 'import site; print(site.getusersitepackages())')
3438
export PATH="$SITE_PACKAGES/bin:$PATH"
3539

3640
CMAKE_BIN="$(which cmake)"
37-
PYTHON_BIN="$(which python)"
41+
PYTHON_BIN="$(which python3)"
3842

3943
# Verify cmake is found
4044
if [ -z "$CMAKE_BIN" ]; then
@@ -59,7 +63,7 @@ cd $PACKAGE_NAME
5963
export PIP_NO_BUILD_ISOLATION=1
6064
export PIP_NO_DEPS=1
6165

62-
#install
66+
# Build wheel using custom build method (onnxruntime requires this)
6367
if ! (./build.sh --config Release --build_wheel --parallel --skip_tests \
6468
--allow_running_as_root \
6569
--cmake_path "$CMAKE_BIN" \
@@ -72,20 +76,13 @@ if ! (./build.sh --config Release --build_wheel --parallel --skip_tests \
7276
exit 1
7377
fi
7478

75-
# Install the built wheel
76-
if ! (python -m pip install build/Linux/Release/dist/*.whl); then
77-
echo "------------------$PACKAGE_NAME:Install_fails-------------------------------------"
78-
echo "$PACKAGE_URL $PACKAGE_NAME"
79-
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | GitHub | Fail | Install_Fails"
80-
exit 1
81-
fi
82-
83-
echo "------------------$PACKAGE_NAME:Install_success-------------------------"
79+
# Copy generated wheel to CURRENT_DIR (required for alternative build methods per guideline #9)
80+
cp build/Linux/Release/dist/*.whl $CURRENT_DIR/
8481

8582
# Go back to parent directory to avoid import conflicts
8683
cd ..
8784

88-
#test
85+
# Test
8986
# Create test file
9087
cat > test_onnxruntime.py << 'EOF'
9188
def test_onnxruntime_import():
@@ -94,7 +91,7 @@ def test_onnxruntime_import():
9491
print(f"onnxruntime version: {onnxruntime.__version__}")
9592
EOF
9693

97-
if ! (pytest test_onnxruntime.py -v); then
94+
if ! (python3 -m pip install $CURRENT_DIR/*.whl && python3 -m pytest test_onnxruntime.py -v); then
9895
echo "------------------$PACKAGE_NAME:Install_success_but_test_fails---------------------"
9996
echo "$PACKAGE_URL $PACKAGE_NAME"
10097
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | GitHub | Fail | Install_success_but_test_Fails"

0 commit comments

Comments
 (0)