build_wheel.sh.in 1.95 KB
Newer Older
1 2
#!/usr/bin/env bash
# ******************************************************************************
3
# Copyright 2017-2019 Intel Corporation
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#
# 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

export PYBIND_HEADERS_PATH=@CMAKE_BINARY_DIR@/pybind11
export NGRAPH_CPP_BUILD_PATH=@CMAKE_BINARY_DIR@/python/_install/@CMAKE_INSTALL_PREFIX@/
export NGRAPH_ONNX_IMPORT_ENABLE=@NGRAPH_ONNX_IMPORT_ENABLE@
23
export NGRAPH_VERSION=@NGRAPH_WHEEL_VERSION@
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

SOURCE_DIR=@CMAKE_SOURCE_DIR@/python
BUILD_DIR=@CMAKE_BINARY_DIR@/python

! PYTHON2_DETECTED=$(($(python -c 'import sys; print(sys.version_info.major)' 2> /dev/null) == 2))
! PYTHON3_DETECTED=$(($(python3 -c 'import sys; print(sys.version_info.major)' 2> /dev/null) == 3))

mkdir -p build

if [ "${PYTHON2_DETECTED}" == 1 ]; then
    echo "Building wheel for Python 2"
    python --version
    cd ${BUILD_DIR}
    virtualenv -p "$(command -v python)" build/venv2
    source build/venv2/bin/activate
    pip install --upgrade setuptools pip wheel
    python ${SOURCE_DIR}/setup.py bdist_wheel
    deactivate
fi

if [ "${PYTHON3_DETECTED}" == 1  ]; then
    echo "Building wheel for Python 3"
    python3 --version
    cd ${BUILD_DIR}
    virtualenv -p "$(command -v python3)" build/venv3
    source build/venv3/bin/activate
    pip install --upgrade setuptools pip wheel
    python ${SOURCE_DIR}/setup.py bdist_wheel
52
    python ${SOURCE_DIR}/setup.py sdist
53 54
    deactivate
fi