From d3efbab81b9ace1777846aef99a19f44abcd775f Mon Sep 17 00:00:00 2001 From: Vladislav Zavjalov Date: Tue, 18 Jan 2022 15:02:32 +0000 Subject: [PATCH 1/4] use PYTHON_SITE_PATH in c++ code instead of re-building it --- CMakeLists.txt | 3 --- client_server/Server.cc | 2 +- core/cadabra2-cli.cc | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9956095853..875c2c87a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -279,9 +279,6 @@ message(STATUS "Python version is ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR set(OLD_PYTHON_SITE_PATH ${CMAKE_INSTALL_FULL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages) # The PYTHON_SITE_PATH variable is used throughout for installation purposes. -# Note that some of the code (e.g. cadabra2-cli.cc) looks up this path based on the -# location of the binary; make sure to change the search logic there too to keep it -# compatible with what is done here. if(PACKAGING_MODE AND IS_DEBIAN_PACKAGE) # Debian packages install all their Python things in 'dist-packages', not 'site-packages'. set(PYTHON_SITE_PATH ${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages) diff --git a/client_server/Server.cc b/client_server/Server.cc index f572385a6c..5de3eee41d 100644 --- a/client_server/Server.cc +++ b/client_server/Server.cc @@ -145,7 +145,7 @@ void Server::init() // Make the C++ CatchOutput class visible on the Python side. - auto python_path = std::string(cadabra::install_prefix() + "/lib/python" + std::to_string(PY_MAJOR_VERSION) + "." + std::to_string(PY_MINOR_VERSION) + "/" + std::string(PYTHON_SITE_DIST)); + auto python_path = std::string(PYTHON_SITE_PATH); std::string stdOutErr = "import sys\n" diff --git a/core/cadabra2-cli.cc b/core/cadabra2-cli.cc index bbe8bf13b8..a7d865dd63 100644 --- a/core/cadabra2-cli.cc +++ b/core/cadabra2-cli.cc @@ -66,7 +66,7 @@ namespace py = pybind11; } Shell::Shell(Flags flags) - : site_path(cadabra::install_prefix() + "/lib/python" + std::to_string(PY_MAJOR_VERSION) + "." + std::to_string(PY_MINOR_VERSION) + "/" + std::string(PYTHON_SITE_DIST)) + : site_path(PYTHON_SITE_PATH) // , globals(py::handle(nullptr), false) // yuck, but prevents pybind from trying to create a new dict object before the interpreter is initialized , globals(py::reinterpret_steal(nullptr)) , flags(flags) -- 2.33.0