mirror of
https://github.com/pybind/pybind11_abseil.git
synced 2026-06-04 13:54:22 +08:00
# Fix * Fix `absl::monostate` support against C++14 * Fix `MSVC C2466` compilation error ref: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2466 * Fix `bazel test -c opt` run # CMake * Bump CMake minimal version to 3.18 to align with pybind11_protobuf and needed to work with pypa/manylinux image (ed need `Development.Module` option in `FindPython3`) * rename `status` as `status_py_extension_stub` target to avoid conflict with abseil-cpp when fetched (ed cmake target are NOT scoped)<br> note: still provide the `pybind11_abseil::status` target alias. * Disable C++ gnu extension. * Rework third party management * disable test for dependencies BUT still allow to enable them for pybind11_abseil * Bump abseil-cpp from `20230802.0` to `20240722.0` * Bump pybind11 from master(floating) to `v2.13.6` * Fix XCode build using `MODULE` in `pybind_extension` * Fix Python support by not linking against the python library as manylinux images and PEP-513 require<br> ref: https://peps.python.org/pep-0513/#libpythonx-y-so-1 # Bazel * Update dependencies in `MODULE.bazel` and `WORKSPACE` * Bump Protobuf to `v29.2` * Add a `.bazelignore` to avoid to parse cmake's usual `build` directory * Add a `.bazelrc` with default options (similar to the one in `pybind11_protobuf`) # Update CI workflows * Split CMake and Bazel workflows to get independent badges * Split MacOS (amd64 and M1) and Windows (amd64) and Linux (amd64) jobs * import ubuntu-build.yml from pybind11_protobuf ## Bazel * Add C++14, c++17 and c++20 flavours * Add `-c opt` and `-c dbg` variants * only test against the default python3.11 ## CMake * Test Python 3.9, 3.10. 3.11, 3.12 * cmake(linux): Test Unix Makefile and Ninja Build generators * cmake(macOS): Test XCode and Makefile generators * cmake(windows): Test MSVC (VC 2022) generator PiperOrigin-RevId: 721778070
106 lines
2.7 KiB
Bash
Executable File
106 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# The following scripts:
|
|
# - creates a virtualenv
|
|
# - installs the pip package dependencies
|
|
# - builds and runs tests
|
|
|
|
set -e # exit when any command fails
|
|
set -x # Prints all executed commands
|
|
|
|
MYDIR="$(dirname "$(realpath "$0")")"
|
|
|
|
CMAKE=$(which cmake || true)
|
|
if [[ -z $CMAKE || ! -x $CMAKE ]]
|
|
then
|
|
echo -e -n '\e[1m\e[93m'
|
|
echo -n 'CMake not found (cmake is needed to '
|
|
echo -n 'compile & test). '
|
|
echo -e 'Exiting...\e[0m'
|
|
exit 1
|
|
fi
|
|
|
|
VIRTUAL_ENV_BINARY=$(which virtualenv || true)
|
|
if [[ -z $VIRTUAL_ENV_BINARY || ! -x $VIRTUAL_ENV_BINARY ]]
|
|
then
|
|
echo -e -n '\e[1m\e[93m'
|
|
echo -n 'virtualenv command not found '
|
|
echo -n '(try `python3 -m pip install virtualenv`, possibly as root). '
|
|
echo -e 'Exiting...\e[0m'
|
|
exit 1
|
|
fi
|
|
|
|
is_in_virtual_env="false"
|
|
# if we are in a virtual_env, we will not create a new one inside.
|
|
if [[ "$VIRTUAL_ENV" != "" ]]
|
|
then
|
|
echo -e "\e[1m\e[93mVirtualenv already detected. We do not create a new one.\e[0m"
|
|
is_in_virtual_env="true"
|
|
fi
|
|
|
|
echo -e "\e[33mRunning ${0} from $PWD\e[0m"
|
|
PYBIN=$(which python3 || true)
|
|
if [[ -z $PYBIN || ! -x $PYBIN ]]
|
|
then
|
|
echo -e '\e[1m\e[93mpython3 not found! Skip build and test.\e[0m'
|
|
exit 1
|
|
fi
|
|
|
|
PYVERSION=$($PYBIN -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')
|
|
|
|
VENV_DIR="./venv"
|
|
|
|
if [[ $is_in_virtual_env == "false" ]]; then
|
|
if ! [ -d "$VENV_DIR" ]; then
|
|
echo "Installing..."
|
|
echo -e "\e[33mInstalling a virtualenv to $VENV_DIR. The setup is long the first time, please wait.\e[0m"
|
|
virtualenv -p "$PYBIN" "$VENV_DIR"
|
|
else
|
|
echo -e "\e[33mReusing virtualenv from $VENV_DIR.\e[0m"
|
|
fi
|
|
source "${VENV_DIR}/bin/activate"
|
|
fi
|
|
|
|
# We only exit the virtualenv if we created one.
|
|
function cleanup {
|
|
if [[ $is_in_virtual_env == "true" ]]; then
|
|
echo "Exiting virtualenv"
|
|
deactivate
|
|
fi
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
echo -e "\e[33mInstalling the requirements (use --noinstall to skip).\e[0m"
|
|
pip3 install --upgrade -r $(python3 -c 'import sys; print("./pybind11_abseil/requirements/requirements_lock_%d_%d.txt" % (sys.version_info[:2]))')
|
|
|
|
echo "Building and testing in $PWD using 'python' (version $PYVERSION)."
|
|
|
|
PYTHON_BIN_PATH="$(which python3)"
|
|
export PYTHON_BIN_PATH
|
|
PYTHON_LIB_PATH=$(python3 -c "import sysconfig; print(sysconfig.get_path('include'))")
|
|
export PYTHON_LIB_PATH
|
|
echo "Using PYTHON_BIN_PATH: $PYTHON_BIN_PATH"
|
|
echo "Using PYTHON_LIB_PATH: $PYTHON_LIB_PATH"
|
|
|
|
if [ -e tmp_build ]; then
|
|
rm -r tmp_build
|
|
fi
|
|
|
|
mkdir tmp_build
|
|
cd tmp_build
|
|
|
|
# C++17
|
|
cmake ../ -DCMAKE_CXX_STANDARD=17 -DCMAKE_VERBOSE_MAKEFILE=ON
|
|
make "$@"
|
|
ctest --output-on-failure --extra-verbose
|
|
|
|
rm -r ./*
|
|
|
|
# C++20
|
|
cmake ../ -DCMAKE_CXX_STANDARD=20 -DCMAKE_VERBOSE_MAKEFILE=ON
|
|
make "$@"
|
|
ctest --output-on-failure --extra-verbose
|
|
|
|
cd ../
|
|
rm -r tmp_build
|