Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion t/tiktoken/build_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"validate_build_script": true,
"use_non_root_user": false,
"0.13.0":{
"build_script": "tiktoken_v0.13.0_ubi_9.6.sh"
"build_script": "tiktoken_v0.13.0_ubi_10.2.sh"
},
"v0.9.0" :{
"build_script": "tiktoken_v0.9.0_ubi_9.6.sh"
Expand Down
124 changes: 124 additions & 0 deletions t/tiktoken/tiktoken_v0.13.0_ubi_10.2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/bin/bash -e
# -----------------------------------------------------------------------------
#
# Package : tiktoken
# Version : v0.13.0
# Source repo : https://github.com/openai/tiktoken
# Tested on : UBI:10.2
# Language : Python
# Ci-Check : True
# Script License: Apache License, Version 2 or later
# Maintainer : Varsha Kumar <varsha.kumar@ibm.com>
#
# Disclaimer: This script has been tested in root mode on given
# ========== platform using the mentioned version of the package.
# It may not work as expected with newer versions of the
# package and/or distribution. In such case, please
# contact "Maintainer" of this script.
#
# ----------------------------------------------------------------------------

# Variables
PACKAGE_NAME=tiktoken
PACKAGE_VERSION=${1:-0.13.0}
PACKAGE_URL=https://github.com/openai/tiktoken.git
PACKAGE_DIR=tiktoken

# Install dependencies
dnf install -y git python3.12 python3.12-devel python3.12-pip gcc-toolset-15 make wget sudo cmake
python3.12 -m pip install --upgrade pip
python3.12 -m pip install pytest tox nox hypothesis

# Install Rust
echo "Installing Rust"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
rustup update
echo "Installed Rust"


export PATH=$PATH:/usr/local/bin/
export PATH=/opt/rh/gcc-toolset-15/root/usr/bin:$PATH
export LD_LIBRARY_PATH=/opt/rh/gcc-toolset-15/root/usr/lib64:$LD_LIBRARY_PATH

OS_NAME=$(grep ^PRETTY_NAME /etc/os-release | cut -d= -f2)
SOURCE=Github

# Clone or extract the package
if [[ "$PACKAGE_URL" == *github.com* ]]; then
if [ -d "$PACKAGE_DIR" ]; then
cd "$PACKAGE_DIR" || exit
else
if ! git clone "$PACKAGE_URL" "$PACKAGE_DIR"; then
echo "------------------$PACKAGE_NAME:clone_fails---------------------------------------"
echo "$PACKAGE_URL $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | $SOURCE | Fail | Clone_Fails"
exit 1
fi
cd "$PACKAGE_DIR" || exit
git checkout "$PACKAGE_VERSION" || exit
fi
else
if [ -d "$PACKAGE_DIR" ]; then
cd "$PACKAGE_DIR" || exit
else
if ! curl -L "$PACKAGE_URL" -o "$PACKAGE_DIR.tar.gz"; then
echo "------------------$PACKAGE_NAME:download_fails---------------------------------------"
echo "$PACKAGE_URL $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | $SOURCE | Fail | Download_Fails"
exit 1
fi
mkdir "$PACKAGE_DIR"
if ! tar -xzf "$PACKAGE_DIR.tar.gz" -C "$PACKAGE_DIR" --strip-components=1; then
echo "------------------$PACKAGE_NAME:untar_fails---------------------------------------"
echo "$PACKAGE_URL $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | $SOURCE | Fail | Untar_Fails"
exit 1
fi
cd "$PACKAGE_DIR" || exit
fi
fi

# Install the package
if ! python3.12 -m pip install ./; then
echo "------------------$PACKAGE_NAME:install_fails------------------------"
echo "$PACKAGE_URL $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | $SOURCE | Fail | Install_Failed"
exit 1
fi

# ------------------ Unified Test Execution Block ------------------

test_status=1 # 0 = success, non-zero = failure

# Run pytest if any matching test files found
if ls */test_*.py > /dev/null 2>&1 && [ $test_status -ne 0 ]; then
echo "Running pytest..."
# Creating temporary directory because of circular import error
(cp -r tests /tmp/tiktoken_tests && cd /tmp && python3.12 -m pytest tiktoken_tests/) && test_status=0 || test_status=$?
fi

# Run tox if tox.ini is present and previous tests failed
if [ -f "tox.ini" ] && [ $test_status -ne 0 ]; then
echo "Running tox..."
(python3.12 -m tox -e py39) && test_status=0 || test_status=$?
fi

# Run nox if noxfile.py is present and previous tests failed
if [ -f "noxfile.py" ] && [ $test_status -ne 0 ]; then
echo "Running nox..."
(python3.12 -m nox) && test_status=0 || test_status=$?
fi

# Final test result output
if [ $test_status -eq 0 ]; then
echo "------------------$PACKAGE_NAME:install_and_test_both_success-------------------------"
echo "$PACKAGE_URL $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | $SOURCE | Pass | Both_Install_and_Test_Success"
exit 0
else
echo "------------------$PACKAGE_NAME:install_success_but_test_fails---------------------"
echo "$PACKAGE_URL $PACKAGE_NAME"
echo "$PACKAGE_NAME | $PACKAGE_URL | $PACKAGE_VERSION | $OS_NAME | $SOURCE | Fail | Install_success_but_test_Fails"
exit 2
fi