From 141febec1f6f95cd9d3a40d75b1dc5dce4e0b4b2 Mon Sep 17 00:00:00 2001 From: "Pingchuan Ma (Henry)" <58333343+HensonMa@users.noreply.github.com> Date: Thu, 1 Jun 2023 11:55:26 +0800 Subject: [PATCH] Add dev wheel building script for LLM package on Windows (#8238) * Add dev wheel building script for LLM package on Windows * delete conda * delete python version check * minor adjust * wheel name fixed * test check * test fix * change wheel name --- .../llm_unit_tests_basic_windows.yml | 48 ++++++++++ python/llm/dev/release.sh | 92 +++++++++++++++++++ python/llm/dev/release_default_windows.sh | 37 ++++++++ 3 files changed, 177 insertions(+) create mode 100644 .github/workflows/llm_unit_tests_basic_windows.yml create mode 100644 python/llm/dev/release.sh create mode 100644 python/llm/dev/release_default_windows.sh diff --git a/.github/workflows/llm_unit_tests_basic_windows.yml b/.github/workflows/llm_unit_tests_basic_windows.yml new file mode 100644 index 00000000..f8f6abc9 --- /dev/null +++ b/.github/workflows/llm_unit_tests_basic_windows.yml @@ -0,0 +1,48 @@ +name: LLM Unit Tests Basic on Windows + +# Cancel previous runs in the PR when you push new commits +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + paths: + - 'python/llm/**' + - '.github/workflows/llm_unit_tests_basic_windows.yml' + pull_request: + branches: [ main ] + paths: + - 'python/llm/**' + - '.github/workflows/llm_unit_tests_basic_windows.yml' + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + llm-unit-test-basic-windows: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ["windows-latest"] + python-version: ["3.8"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade setuptools==58.0.4 + python -m pip install --upgrade wheel + - name: Run LLM-init test + shell: bash + run: | + bash python/llm/dev/release_default_windows.sh default false + pip install -i https://pypi.python.org/simple python/llm/dist/bigdl_llm*.whl + env: + ANALYTICS_ZOO_ROOT: ${{ github.workspace }} diff --git a/python/llm/dev/release.sh b/python/llm/dev/release.sh new file mode 100644 index 00000000..1e664a51 --- /dev/null +++ b/python/llm/dev/release.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +# +# Copyright 2016 The BigDL Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -e +RUN_SCRIPT_DIR=$(cd $(dirname $0) ; pwd) +echo $RUN_SCRIPT_DIR +BIGDL_DIR="$(cd ${RUN_SCRIPT_DIR}/../../..; pwd)" +echo $BIGDL_DIR +BIGDL_PYTHON_DIR="$(cd ${BIGDL_DIR}/python/llm; pwd)" +echo $BIGDL_PYTHON_DIR + +if (( $# < 3)); then + echo "Usage: release.sh platform version upload" + echo "Usage example: bash release.sh linux default true" + exit -1 +fi + +platform=$1 +version=$2 +upload=$3 # Whether to upload the whl to pypi + +if [ "${version}" != "default" ]; then + echo "User specified version: ${version}" + echo $version > $BIGDL_DIR/python/version.txt +fi + +bigdl_version=$(cat $BIGDL_DIR/python/version.txt | head -1) +echo "The effective version is: ${bigdl_version}" + +if [ "$platform" == "linux" ]; then + verbose_pname="manylinux2010_x86_64" + setup_file="setup-linux.py" +elif [ "$platform" == "windows" ]; then + verbose_pname="win_amd64" + setup_file="setup.py" +else + echo "Unsupported platform" +fi + +if [ -d "${BIGDL_DIR}/python/llm/dist" ]; then + rm -r ${BIGDL_DIR}/python/llm/dist +fi + +if [ -d "${BIGDL_DIR}/python/llm/_skbuild" ]; then + rm -r ${BIGDL_DIR}/python/llm/_skbuild +fi + +if [ -d "${BIGDL_DIR}/python/llm/build" ]; then + rm -r ${BIGDL_DIR}/python/llm/build +fi + +if [ -d "${BIGDL_DIR}/python/llm/bigdl_llm.egg-info" ]; then + rm -r ${BIGDL_DIR}/python/llm/bigdl_llm.egg-info +fi + +cd $BIGDL_PYTHON_DIR + +wheel_command="python ${setup_file} bdist_wheel --plat-name ${verbose_pname} --python-tag py3" +echo "Packing python distribution: $wheel_command" +${wheel_command} + +if [ -d "${BIGDL_DIR}/python/llm/_skbuild" ]; then + rm -r ${BIGDL_DIR}/python/llm/_skbuild +fi + +if [ -d "${BIGDL_DIR}/python/llm/build" ]; then + rm -r ${BIGDL_DIR}/python/llm/build +fi + +if [ -d "${BIGDL_DIR}/python/llm/bigdl_llm.egg-info" ]; then + rm -r ${BIGDL_DIR}/python/llm/bigdl_llm.egg-info +fi + +if [ ${upload} == true ]; then + upload_command="twine upload dist/bigdl_llm-${bigdl_version}-*-${verbose_pname}.whl" + echo "Please manually upload with this command: $upload_command" + $upload_command +fi diff --git a/python/llm/dev/release_default_windows.sh b/python/llm/dev/release_default_windows.sh new file mode 100644 index 00000000..878bf35c --- /dev/null +++ b/python/llm/dev/release_default_windows.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# +# Copyright 2016 The BigDL Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This is the default script with maven parameters to release bigdl-math for linux. +# Note that if the maven parameters to build bigdl-math need to be changed, +# make sure to change this file accordingly. +# If you want to customize the release, please use release.sh and specify maven parameters instead. + +set -e +RUN_SCRIPT_DIR=$(cd $(dirname $0) ; pwd) +echo $RUN_SCRIPT_DIR + +if (( $# < 2)); then + echo "Usage: release_default_windows.sh version upload" + echo "Usage example: bash release_default_windows.sh default true" + exit -1 +fi + +version=$1 +upload=$2 + +bash ${RUN_SCRIPT_DIR}/release.sh windows ${version} ${upload} \ No newline at end of file