From 403f168688252fc4471444390e52721e9e4469e6 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Fri, 8 Sep 2023 21:58:22 +0200 Subject: [PATCH] Move boost stuff to seperate script --- .github/scripts/ci_deps.sh | 24 ++++- .github/workflows/cd.yml | 24 +++-- .github/workflows/test.yml | 11 ++- VERSION | 2 +- install.sh | 143 ++++------------------------- install_boost.sh | 152 +++++++++++++++++++++++++++++++ pyproject.toml | 10 +- src/CMakeLists.txt | 8 +- src/nodejslib/nodejslib.cmake | 1 + src/npmpackage/package-lock.json | 4 +- src/npmpackage/package.json | 2 +- 11 files changed, 228 insertions(+), 153 deletions(-) create mode 100755 install_boost.sh diff --git a/.github/scripts/ci_deps.sh b/.github/scripts/ci_deps.sh index eaf54841..51001463 100755 --- a/.github/scripts/ci_deps.sh +++ b/.github/scripts/ci_deps.sh @@ -1,5 +1,14 @@ #!/usr/bin/env bash +set -e + +primary='\033[1;34m' +secondary='\033[1;35m' +nc='\033[0m' +prettyprint() { + printf "${primary}${1}${nc}${secondary}${2}${nc}\n" +} + command_exists() { command -v "${1}" >/dev/null 2>&1; } @@ -8,6 +17,17 @@ is_root() { [ "${EUID:-$(id -u)}" -eq 0 ]; } +get_os() { + if [[ "${OSTYPE}" =~ ^darwin.* ]]; then + echo "macos" + elif [[ "${OSTYPE}" =~ ^linux.* ]]; then + echo "linux" + else + echo "windows" + fi +} +determined_os=$(get_os) + install_ci_dependencies() { if [ "${determined_os}" = "windows" ]; then if command_exists choco; then @@ -41,4 +61,6 @@ install_ci_dependencies() { export OPENMP_PREFIX_MACOS="${temp_dir}/libomp/libomp/fixed" mv "${libomp_prefix}" "${OPENMP_PREFIX_MACOS}" fi -} \ No newline at end of file +} + +install_ci_dependencies \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1a163753..dfc91c5e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -80,10 +80,10 @@ jobs: export OCL_GENERATOR_PLATFORM="${{ matrix.cmake_generator_platform }}" fi + .github/scripts/ci_deps.sh + ./install_boost.sh ./install.sh \ --build-type release \ - --install-ci-deps \ - --install-boost \ --boost-prefix $(pwd) \ --install \ --install-prefix $(pwd)/dist \ @@ -168,10 +168,11 @@ jobs: export OCL_GENERATOR_PLATFORM="${{ matrix.cmake_generator_platform }}" fi + .github/scripts/ci_deps.sh + ./install_boost.sh + export OPENMP_PREFIX_MACOS="/tmp/libomp/libomp/fixed" ./install.sh \ --build-type release \ - --install-ci-deps \ - --install-boost \ --boost-prefix $(pwd) \ --node-architecture ${{ matrix.node_architecture }} \ --install \ @@ -291,20 +292,23 @@ jobs: OCL_BOOST_ARCHITECTURE="${{ matrix.boost_architecture }}" CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_GENERATOR_PLATFORM="${{ matrix.cmake_generator_platform }}" - CIBW_ENVIRONMENT_PASS_WINDOWS: "BOOST_ROOT OCL_BOOST_ADDRESS_MODEL OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM" + USE_STATIC_BOOST="ON" + CIBW_ENVIRONMENT_PASS_WINDOWS: "BOOST_ROOT OCL_BOOST_ADDRESS_MODEL OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM USE_STATIC_BOOST" CIBW_ARCHS_MACOS: "${{ matrix.architecture }}" CIBW_ENVIRONMENT_MACOS: > BOOST_ROOT="$(pwd)" OCL_MACOS_ARCHITECTURE="${{ matrix.architecture }}" OCL_BOOST_ARCHITECTURE="${{ matrix.boost_architecture }}" OPENMP_PREFIX_MACOS="/tmp/libomp/libomp/fixed" - CIBW_ENVIRONMENT_PASS_MACOS: "BOOST_ROOT OCL_BOOST_ARCHITECTURE OPENMP_PREFIX_MACOS" + USE_STATIC_BOOST="ON" + CIBW_ENVIRONMENT_PASS_MACOS: "BOOST_ROOT OCL_BOOST_ARCHITECTURE OPENMP_PREFIX_MACOS USE_STATIC_BOOST" CIBW_ARCHS_LINUX: "${{ matrix.architecture }}" CIBW_ENVIRONMENT_LINUX: > BOOST_ROOT="$(pwd)" OCL_BOOST_ARCHITECTURE="${{ matrix.boost_architecture }}" CMAKE_GENERATOR="Unix Makefiles" - CIBW_ENVIRONMENT_PASS_LINUX: "BOOST_ROOT OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR" + USE_STATIC_BOOST="ON" + CIBW_ENVIRONMENT_PASS_LINUX: "BOOST_ROOT OCL_BOOST_ARCHITECTURE CMAKE_GENERATOR USE_STATIC_BOOST" # - name: Compress Boost.Python # shell: bash # run: | @@ -329,10 +333,10 @@ jobs: - name: emscripten shell: bash run: | + .github/scripts/ci_deps.sh + ./install_boost.sh ./install.sh \ --build-type release \ - --install-ci-deps \ - --install-boost \ --boost-prefix $(pwd) \ --install \ --install-prefix $(pwd)/dist \ @@ -418,7 +422,7 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ + repository-url: https://test.pypi.org/legacy/ - name: Publish wheels to PyPI if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b67a396..9adf782b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,10 +38,10 @@ jobs: if [ "${{ matrix.os_short }}" == "linux" ]; then export OCL_SUDO_INSTALL="1" fi + .github/scripts/ci_deps.sh + ./install_boost.sh ./install.sh \ - --install-ci-deps \ --build-type release \ - --install-boost \ --boost-prefix $(pwd) \ --install \ --test \ @@ -74,11 +74,12 @@ jobs: if [ "${{ matrix.os_short }}" == "linux" ]; then export OCL_SUDO_INSTALL="1" fi + .github/scripts/ci_deps.sh + ./install_boost.sh + export OPENMP_PREFIX_MACOS="/tmp/libomp/libomp/fixed" ./install.sh \ - --install-ci-deps \ --build-type release \ --node-architecture x64 \ - --install-boost \ --boost-prefix $(pwd) \ --install \ --install-prefix $(pwd)/src/npmpackage/build/Release/${{ matrix.libdir }} \ @@ -118,6 +119,6 @@ jobs: --install-system-deps \ --python-executable python \ --test \ - python || (pip install delvewheel && cd /c/hostedtoolcache/windows/Python/3.10.11/x64/lib/site-packages/opencamlib && ls -lah && && delvewheel show opencamlib || delvewheel show ocl.pyd) + python env: CMAKE_GENERATOR: ${{ matrix.cmake_generator }} diff --git a/VERSION b/VERSION index c9df6993..2cb0f512 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2023.09.6 \ No newline at end of file +2023.9.6 \ No newline at end of file diff --git a/install.sh b/install.sh index 0c3391d3..d8c8eed3 100755 --- a/install.sh +++ b/install.sh @@ -17,18 +17,12 @@ OPTIONS: --build-type Choose the build type (one of: debug, release) --disable-openmp Disable OpenMP in the build. --install-system-deps Install dependencies for compiling libraries (only aware of apt, brew and choco at the moment) - --install-ci-deps Install curl and, when the platform is macos, installs OpenMP for the given architecture (see: --macos-architecture) - --install-boost Install Boost from source --install Install the CMake install targets to the prefix (see: --install-prefix) --sudo-install Install the CMake install targets to the prefix with root privileges (see: --install-prefix) --install-prefix Set the install prefix location for CMake installs (only valid when using --install) --boost-prefix Set a custom path where to look for Boost - --boost-with-python Compile Boost.Python (only valid when using --install-boost) - --boost-address-model Set the address model for Boost (one of: 32, 64) (only valid when using --install-boost and --boost-with-python) - --boost-architecture Set the architecture for Boost (one of: x86, ia64, sparc, power, loongarch, mips, mips1, mips2, mips3, mips4, mips32, mips32r2, mips64, parisc, arm, riscv, s390x, arm+x86) (only valid when using --install-boost and --boost-with-python) - --boost-python-version Set the python version to look for when compiling Boost (only valid when using --install-boost and --boost-with-python) --python-executable Set a custom path (or name of) the Python executable --python-prefix Set the python prefix, this will be passed to CMake as Python3_ROOT_DIR, to make sure CMake is using the correct Python installation. @@ -86,24 +80,17 @@ while [[ "$#" -gt 0 ]]; do --build-type) OCL_BUILD_TYPE="$2"; shift ;; --platform) OCL_PLATFORM="$2"; shift ;; --install-system-deps) OCL_INSTALL_SYSTEM_DEPS="1"; ;; - --install-ci-deps) OCL_INSTALL_CI_DEPS="1"; ;; --disable-openmp) OCL_DISABLE_OPENMP="1"; ;; --install) OCL_INSTALL="1"; ;; --sudo-install) OCL_SUDO_INSTALL="1"; ;; --install-prefix) OCL_INSTALL_PREFIX="$2"; shift ;; - --install-boost) OCL_INSTALL_BOOST="1"; ;; --boost-prefix) OCL_BOOST_PREFIX="$2"; shift ;; - --boost-address-model) OCL_BOOST_ADDRESS_MODEL="$2"; shift ;; - --boost-architecture) OCL_BOOST_ARCHITECTURE="$2"; shift ;; - --boost-with-python) OCL_BOOST_WITH_PYTHON="1"; ;; - --boost-python-version) OCL_BOOST_PYTHON_VERSION="$2"; shift ;; --macos-architecture) OCL_MACOS_ARCHITECTURE="$2"; shift ;; --docker-image) OCL_DOCKER_IMAGE="$2"; shift ;; --docker-before-install) OCL_DOCKER_IMAGE_BEFORE_INSTALL="$2"; shift ;; --cmake-generator) OCL_GENERATOR="$2"; shift ;; --cmake-generator-platform) OCL_GENERATOR_PLATFORM="$2"; shift ;; --python-executable) OCL_PYTHON_EXECUTABLE="$2"; shift ;; - --python-prefix) OCL_PYTHON_PREFIX="$2"; shift ;; --node-architecture) OCL_NODE_ARCH="$2"; shift ;; --test) OCL_TEST="1"; ;; --help|--*) @@ -121,24 +108,13 @@ if [[ ${#positional_args[@]} != 1 ]] && [[ -z "${OCL_BUILD_LIBRARY}" ]]; then exit 0 fi -OCL_BUILD_LIBRARY="${positional_args[0]}" - -verify_args() { - if [ -n "${OCL_INSTALL_PREFIX}" ] && [ -z "${OCL_INSTALL}" ] && [ -z "${OCL_SUDO_INSTALL}" ]; then - echo "WARN: Settings --install-prefix without setting --install or --sudo-install. add --install or --sudo-install option or remove the --install-prefix option" - elif [ -n "${OCL_BOOST_WITH_PYTHON}" ] && [ -z "${OCL_INSTALL_BOOST}" ]; then - echo "WARN: Setting --boost-with-python without setting --install-boost. add --install-boost or remove the --boost-with-python option" - elif [ -n "${OCL_BOOST_WITH_PYTHON}" ] && [ -z "${OCL_BOOST_ARCHITECTURE}" ]; then - echo "WARN: Setting --boost-with-python without setting --boost-architecture. add --boost-architecture or remove the --boost-with-python option" - elif [ -n "${OCL_BOOST_ADDRESS_MODEL}" ] && [ -z "${OCL_INSTALL_BOOST}" ]; then - echo "WARN: Setting --boost-address-model without setting --install-boost. add --install-boost or remove the --boost-address-model option" - elif [ -n "${OCL_BOOST_ARCHITECTURE}" ] && [ -z "${OCL_INSTALL_BOOST}" ]; then - echo "WARN: Setting --boost-architecture without setting --install-boost. add --install-boost or remove the --boost-address-model option" - elif [ -n "${OCL_BOOST_PYTHON_VERSION}" ] && [ -z "${OCL_INSTALL_BOOST}" ]; then - echo "WARN: Setting --boost-python-version without setting --install-boost. add --install-boost or remove the --boost-python-version option" - fi -} -verify_args +if [[ ${#positional_args[@]} == 1 ]]; then + OCL_BUILD_LIBRARY="${positional_args[0]}" +fi + +if [ -n "${OCL_INSTALL_PREFIX}" ] && [ -z "${OCL_INSTALL}" ] && [ -z "${OCL_SUDO_INSTALL}" ]; then + echo "WARN: Settings --install-prefix without setting --install or --sudo-install. add --install or --sudo-install option or remove the --install-prefix option" +fi if [ "${OCL_BUILD_TYPE}" = "debug" ]; then build_type="Debug" @@ -186,92 +162,6 @@ command_exists() { command -v "${1}" >/dev/null 2>&1; } -download_boost() { - if [ ! -f "${TMPDIR:-"/tmp"}/boost.tar.gz" ]; then - prettyprint "Downloading boost.tar.gz" - curl "${boost_url}" --output "${TMPDIR:-"/tmp"}/boost.tar.gz" --silent --location - else - prettyprint "boost.tar.gz found, re-using..." - fi - prettyprint "Extracting boost.tar.gz..." - tar -zxf "${TMPDIR:-"/tmp"}/boost.tar.gz" -C . - - prettyprint "Applying boost-python-3.11.patch" - git apply --ignore-space-change --ignore-whitespace --directory "boost_1_80_0/libs/python" "${project_dir}/.github/patches/boost-python-3.11.patch" -} - -compile_boost_python() { - boost_variant="${build_type_lower}" - cd "${project_dir}/boost_1_80_0" - if [ -n "${OCL_BOOST_WITH_PYTHON}" ]; then - if [ -n "${OCL_PYTHON_EXECUTABLE}" ]; then - python_version=$(${OCL_PYTHON_EXECUTABLE} -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}".format(*version))') - python_include_dir=$(${OCL_PYTHON_EXECUTABLE} -c 'from sysconfig import get_paths as gp; print(gp()["include"])') - if [ "${determined_os}" = "windows" ]; then - python_include_dir=$(cygpath -w "${python_include_dir}") - fi - echo "using python : ${python_version} : ${OCL_PYTHON_EXECUTABLE//\\/\\\\} : ${python_include_dir//\\/\\\\} ;" > user-config.jam - elif [ -n "${OCL_BOOST_PYTHON_VERSION}" ]; then - echo "using python : ${OCL_BOOST_PYTHON_VERSION} ;" > user-config.jam - else - echo "using python ;" > user-config.jam - fi - cat user-config.jam - prettyprint "Bootstrapping boost" - if [ "${determined_os}" = "windows" ]; then - ./bootstrap.bat - else - ./bootstrap.sh - fi - prettyprint "Compiling boost " "${OCL_BOOST_ADDRESS_MODEL:-"64"}-bit ${OCL_BOOST_ARCHITECTURE}" - ./b2 \ - ${OCL_CLEAN:+"-a"} \ - -j2 \ - --layout="system" \ - --with-python \ - --user-config="user-config.jam" \ - threading="multi" \ - variant="${boost_variant}" \ - link="static" \ - cxxflags="-fPIC" \ - address-model="${OCL_BOOST_ADDRESS_MODEL:-"64"}" \ - ${OCL_BOOST_ARCHITECTURE:+"architecture=${OCL_BOOST_ARCHITECTURE}"} \ - stage - fi -} - -install_boost () { - cd "${project_dir}" - if [ -d boost_1_80_0 ]; then - # boost folder already exists, re-unsing - prettyprint "Boost already found, re-using..." - elif [ -f boost-precompiled.tar.gz ]; then - # boost-precompiled.tar.gz found, re-using - prettyprint "Found cached precompiled boost, installing..." - tar -zxf boost-precompiled.tar.gz -C . - elif [ -n "${OCL_BOOST_ARCHITECTURE}" ] && [ -n "${OCL_BOOST_WITH_PYTHON}" ]; then - # got enough information to try and download a pre-compiled boost with python - boost_precompiled_url="https://github.com/vespakoen/boost-python-precompiled/releases/download/1.80.0/boost-python-precompiled-${determined_os}-${OCL_BOOST_ARCHITECTURE}-${OCL_BOOST_ADDRESS_MODEL:-"64"}-bit.tar.gz" - if curl --output /dev/null --silent --head --fail "$boost_precompiled_url"; then - prettyprint "Downloading boost-precompiled.tar.gz for ${OCL_BOOST_ARCHITECTURE} ${OCL_BOOST_ADDRESS_MODEL:-"64"}-bit..." - curl "${boost_precompiled_url}" --output "${TMPDIR:-"/tmp"}/boost-precompiled.tar.gz" --silent --location - prettyprint "Extracting boost-precompiled.tar.gz..." - tar -zxf "${TMPDIR:-"/tmp"}/boost-precompiled.tar.gz" -C . - else - # precompiled boost python not available for given architecture and address model, installing from source - download_boost - if [ -n "${OCL_BOOST_WITH_PYTHON}" ]; then - compile_boost_python - fi - fi - else - download_boost - if [ -n "${OCL_BOOST_WITH_PYTHON}" ]; then - compile_boost_python - fi - fi -} - if [ -n "${OCL_DOCKER_IMAGE}" ]; then prettyprint "Running the docker image with the following environment variables" # collect all the options to check which ones are set and should be forwarded to the container @@ -358,7 +248,7 @@ get_cmake_args() { -D CMAKE_BUILD_TYPE="${build_type}" \ -D USE_STATIC_BOOST="ON" \ -D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \ - -D VERSION_STRING="2023.09.6" + -D VERSION_STRING="$(cat VERSION)" \ ${OCL_DISABLE_OPENMP:+"-D USE_OPENMP=OFF"} \ ${OCL_INSTALL_PREFIX:+"-D CMAKE_INSTALL_PREFIX=${OCL_INSTALL_PREFIX}"} \ ${OCL_BOOST_PREFIX:+"-D BOOST_ROOT=${OCL_BOOST_PREFIX}"}" @@ -372,7 +262,11 @@ build_cxxlib() { set -x cmake $(get_cmake_args) -D BUILD_CXX_LIB="ON" set +x - (cd "${build_dir}" && cmake_build && cmake_install) + (cd "${build_dir}" && cmake_build) + if [ -n "${OCL_INSTALL}" ] || [ -n "${OCL_SUDO_INSTALL}" ]; then + prettyprint "Installing" + (cd "${build_dir}" && cmake_install) + fi } test_cxxlib() { @@ -412,7 +306,9 @@ build_nodejslib() { --CDBUILD_NODEJS_LIB="ON" \ --config "${build_type}" set +x - (cd "${build_dir}" && cmake_install) + if [ -n "${OCL_INSTALL}" ] || [ -n "${OCL_SUDO_INSTALL}" ]; then + (cd "${build_dir}" && cmake_install) + fi } test_nodejslib() { @@ -457,9 +353,9 @@ build_emscriptenlib() { set -x install_prefix_fallback="${project_dir}/src/npmpackage/build" OCL_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" + OCL_DISABLE_OPENMP="1" emcmake cmake $(get_cmake_args) \ -D BUILD_EMSCRIPTEN_LIB="ON" \ - -D USE_OPENMP="OFF" \ -D USE_STATIC_BOOST="ON" cd "${build_dir}" if [ "${determined_os}" = "windows" ]; then @@ -495,11 +391,6 @@ if [ -n "${OCL_INSTALL_SYSTEM_DEPS}" ]; then install_system_dependencies fi -if [ -n "${OCL_INSTALL_BOOST}" ]; then - prettyprint "Installing Boost..." - install_boost -fi - if [ -n "${OCL_CLEAN}" ]; then prettyprint "Cleaning build directory..." build_clean diff --git a/install_boost.sh b/install_boost.sh new file mode 100755 index 00000000..9c751052 --- /dev/null +++ b/install_boost.sh @@ -0,0 +1,152 @@ +#!/usr/bin/env bash + +set -e + +boost_url="https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz" +project_dir=$(pwd) + +print_help() { +cat << EOF +Usage: ./install_boost.sh [OPTIONS] + +OPTIONS: + --platform Set the platform, for when auto-detection doesn't work (one of: windows, macos, linux) + --boost-with-python Compile Boost.Python + --boost-address-model Set the address model for Boost (one of: 32, 64) (only valid when using --boost-with-python) + --boost-architecture Set the architecture for Boost (one of: x86, ia64, sparc, power, loongarch, mips, mips1, mips2, mips3, mips4, mips32, mips32r2, mips64, parisc, arm, riscv, s390x, arm+x86) (only valid when using --boost-with-python) + --boost-python-version Set the python version to look for when compiling Boost (only valid when using --boost-with-python) + --python-executable Set a custom path (or name of) the Python executable + --help Shows this help page +EOF + exit 1 +} + +original_args="$*" +while [[ "$#" -gt 0 ]]; do + case $1 in + --platform) OCL_PLATFORM="$2"; shift ;; + --boost-with-python) OCL_BOOST_WITH_PYTHON="1"; ;; + --boost-address-model) OCL_BOOST_ADDRESS_MODEL="$2"; shift ;; + --boost-architecture) OCL_BOOST_ARCHITECTURE="$2"; shift ;; + --boost-python-version) OCL_BOOST_PYTHON_VERSION="$2"; shift ;; + --python-executable) OCL_PYTHON_EXECUTABLE="$2"; shift ;; + --help|--*) + echo $1 + print_help ;; + esac + shift +done + +if [ -n "${OCL_BOOST_WITH_PYTHON}" ] && [ -z "${OCL_BOOST_ARCHITECTURE}" ]; then + echo "WARN: Setting --boost-with-python without setting --boost-architecture. add --boost-architecture or remove the --boost-with-python option" +fi + +get_os() { + if [ "${OCL_PLATFORM}" ]; then + echo "${OCL_PLATFORM}" + else + if [[ "${OSTYPE}" =~ ^darwin.* ]]; then + echo "macos" + elif [[ "${OSTYPE}" =~ ^linux.* ]]; then + echo "linux" + else + echo "windows" + fi + fi +} +determined_os=$(get_os) + +primary='\033[1;34m' +secondary='\033[1;35m' +nc='\033[0m' +prettyprint() { + printf "${primary}${1}${nc}${secondary}${2}${nc}\n" +} + +download_boost() { + if [ ! -f "${TMPDIR:-"/tmp"}/boost.tar.gz" ]; then + prettyprint "Downloading boost.tar.gz" + curl "${boost_url}" --output "${TMPDIR:-"/tmp"}/boost.tar.gz" --silent --location + else + prettyprint "boost.tar.gz found, re-using..." + fi + prettyprint "Extracting boost.tar.gz..." + tar -zxf "${TMPDIR:-"/tmp"}/boost.tar.gz" -C . + + prettyprint "Applying boost-python-3.11.patch" + git apply --ignore-space-change --ignore-whitespace --directory "boost_1_80_0/libs/python" "${project_dir}/.github/patches/boost-python-3.11.patch" +} + +compile_boost_python() { + boost_variant="${build_type_lower}" + cd "${project_dir}/boost_1_80_0" + if [ -n "${OCL_BOOST_WITH_PYTHON}" ]; then + if [ -n "${OCL_PYTHON_EXECUTABLE}" ]; then + python_version=$(${OCL_PYTHON_EXECUTABLE} -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}".format(*version))') + python_include_dir=$(${OCL_PYTHON_EXECUTABLE} -c 'from sysconfig import get_paths as gp; print(gp()["include"])') + if [ "${determined_os}" = "windows" ]; then + python_include_dir=$(cygpath -w "${python_include_dir}") + fi + echo "using python : ${python_version} : ${OCL_PYTHON_EXECUTABLE//\\/\\\\} : ${python_include_dir//\\/\\\\} ;" > user-config.jam + elif [ -n "${OCL_BOOST_PYTHON_VERSION}" ]; then + echo "using python : ${OCL_BOOST_PYTHON_VERSION} ;" > user-config.jam + else + echo "using python ;" > user-config.jam + fi + cat user-config.jam + prettyprint "Bootstrapping boost" + if [ "${determined_os}" = "windows" ]; then + ./bootstrap.bat + else + ./bootstrap.sh + fi + prettyprint "Compiling boost " "${OCL_BOOST_ADDRESS_MODEL:-"64"}-bit ${OCL_BOOST_ARCHITECTURE}" + ./b2 \ + ${OCL_CLEAN:+"-a"} \ + -j2 \ + --layout="system" \ + --with-python \ + --user-config="user-config.jam" \ + threading="multi" \ + variant="${boost_variant}" \ + link="static" \ + cxxflags="-fPIC" \ + address-model="${OCL_BOOST_ADDRESS_MODEL:-"64"}" \ + ${OCL_BOOST_ARCHITECTURE:+"architecture=${OCL_BOOST_ARCHITECTURE}"} \ + stage + fi +} + +install_boost () { + cd "${project_dir}" + if [ -d boost_1_80_0 ]; then + # boost folder already exists, re-unsing + prettyprint "Boost already found, re-using..." + elif [ -f boost-precompiled.tar.gz ]; then + # boost-precompiled.tar.gz found, re-using + prettyprint "Found cached precompiled boost, installing..." + tar -zxf boost-precompiled.tar.gz -C . + elif [ -n "${OCL_BOOST_ARCHITECTURE}" ] && [ -n "${OCL_BOOST_WITH_PYTHON}" ]; then + # got enough information to try and download a pre-compiled boost with python + boost_precompiled_url="https://github.com/vespakoen/boost-python-precompiled/releases/download/1.80.0/boost-python-precompiled-${determined_os}-${OCL_BOOST_ARCHITECTURE}-${OCL_BOOST_ADDRESS_MODEL:-"64"}-bit.tar.gz" + if curl --output /dev/null --silent --head --fail "$boost_precompiled_url"; then + prettyprint "Downloading boost-precompiled.tar.gz for ${OCL_BOOST_ARCHITECTURE} ${OCL_BOOST_ADDRESS_MODEL:-"64"}-bit..." + curl "${boost_precompiled_url}" --output "${TMPDIR:-"/tmp"}/boost-precompiled.tar.gz" --silent --location + prettyprint "Extracting boost-precompiled.tar.gz..." + tar -zxf "${TMPDIR:-"/tmp"}/boost-precompiled.tar.gz" -C . + else + # precompiled boost python not available for given architecture and address model, installing from source + download_boost + if [ -n "${OCL_BOOST_WITH_PYTHON}" ]; then + compile_boost_python + fi + fi + else + download_boost + if [ -n "${OCL_BOOST_WITH_PYTHON}" ]; then + compile_boost_python + fi + fi +} + +install_boost \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 13d88423..06a2fd9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "opencamlib" -version = "2023.09.6" +version = "2023.9.6" description = "open source computer aided manufacturing algorithms library" readme = "README.rst" authors = [ @@ -44,7 +44,7 @@ wheel.packages = ["src/pythonlib/opencamlib"] BUILD_PY_LIB = "ON" Boost_ADDITIONAL_VERSIONS = "1.80.0;1.79.0;1.78.0;1.77.0;1.76.0;1.75.0;1.74.0;1.73.0;1.72.0;1.71.0;1.70.0" BUILD_DOC = "OFF" -VERSION_STRING="2022.12.18" +VERSION_STRING="2023.9.6" [tool.cibuildwheel] build = ["cp37*", "cp38*", "cp39*", "cp310*", "cp311*"] @@ -53,15 +53,15 @@ skip = ["pp*", "*-musllinux*", "*-manylinux_i686"] [tool.cibuildwheel.windows] archs = ["AMD64", "x86", "ARM64"] before-all = "cd {package} && bash .github/scripts/ci_deps.sh" -before-build = "cd {package} && bash ./install.sh --install-boost --boost-with-python --python-executable python" +before-build = "cd {package} && bash ./install_boost.sh --boost-with-python --python-executable python" [tool.cibuildwheel.linux] archs = ["x86_64", "aarch64"] before-all = "cd {package} && bash .github/scripts/ci_deps.sh" -before-build = "cd {package} && bash ./install.sh --install-boost --boost-with-python --python-executable python && cp --recursive --no-clobber boost_1_80_0 /host/home/runner/work/opencamlib/opencamlib" +before-build = "cd {package} && bash ./install_boost.sh --boost-with-python --python-executable python && cp --recursive --no-clobber boost_1_80_0 /host/home/runner/work/opencamlib/opencamlib" [tool.cibuildwheel.macos] archs = ["x86_64", "arm64"] before-all = "cd {package} && bash .github/scripts/ci_deps.sh" -before-build = "cd {package} && bash ./install.sh --install-boost --boost-with-python --python-executable python" +before-build = "cd {package} && bash ./install_boost.sh --boost-with-python --python-executable python" repair-wheel-command = "python src/pythonlib/delocate-wheel.py --require-archs {delocate_archs} -w {dest_dir} -v {wheel}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 64ea621f..b055a690 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,7 +106,11 @@ endif() include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(Boost_DEBUG ON CACHE BOOL "boost-debug") -if(USE_STATIC_BOOST) + +set(TRUTHY_VALUES "ON;YES;TRUE;1") +if(USE_STATIC_BOOST OR + (DEFINED ENV{USE_STATIC_BOOST} AND + "$ENV{USE_STATIC_BOOST}" IN_LIST TRUTHY_VALUES)) set(Boost_USE_STATIC_LIBS ON CACHE BOOL "boost-use-static-libs") endif() if(DEFINED ENV{BOOST_ROOT} OR DEFINED BOOST_ROOT) @@ -161,11 +165,11 @@ if(USE_OPENMP) list(APPEND CMAKE_PREFIX_PATH "/opt/homebrew/opt/libomp") endif() endif() + find_package(OpenMP REQUIRED) if(MSVC) set(CMAKE_INSTALL_OPENMP_LIBRARIES ON) include(InstallRequiredSystemLibraries) endif() - find_package(OpenMP REQUIRED) if(OPENMP_FOUND) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") message(STATUS "found OpenMP, compiling with flags: " ${OpenMP_CXX_FLAGS} ) diff --git a/src/nodejslib/nodejslib.cmake b/src/nodejslib/nodejslib.cmake index d163baac..862788fd 100644 --- a/src/nodejslib/nodejslib.cmake +++ b/src/nodejslib/nodejslib.cmake @@ -58,6 +58,7 @@ add_definitions(-DNAPI_VERSION=3) if(USE_OPENMP AND APPLE) # copy libomp into install directory + message(STATUS "Installing " ${OpenMP_omp_LIBRARY}}) install( FILES ${OpenMP_omp_LIBRARY} DESTINATION "." diff --git a/src/npmpackage/package-lock.json b/src/npmpackage/package-lock.json index e83de299..6eebab78 100644 --- a/src/npmpackage/package-lock.json +++ b/src/npmpackage/package-lock.json @@ -1,12 +1,12 @@ { "name": "@opencamlib/opencamlib", - "version": "2022.12.18", + "version": "2023.9.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@opencamlib/opencamlib", - "version": "2022.12.18", + "version": "2023.9.6", "license": "LGPL-3.0", "dependencies": { "stl": "^1.1.1" diff --git a/src/npmpackage/package.json b/src/npmpackage/package.json index 47fd255f..8b72a317 100644 --- a/src/npmpackage/package.json +++ b/src/npmpackage/package.json @@ -1,6 +1,6 @@ { "name": "@opencamlib/opencamlib", - "version": "2022.12.18", + "version": "2023.9.6", "description": "opencamlib for the web compiled with emscripten", "main": "./lib/napi/index.js", "browser": "./browser.js",