cadabra2/cadabra2-python-modules-location.patch
Dirk Stoecker 81e95ea501 Accepting request 824547 from home:badshah400:branches:science
- Update to version 2.3.0.
- Drop cadabra2-add-pthread-to-cxxflags.patch: No longer required for building.
- Add cadabra2-python-modules-location.patch to fix location of python libs and modules (gh#kpeeters/cadabra2#203).
- Rebase Fix-linking-of-cadabra-module.patch for update; only partially fixed by upstream (gh#kpeeters/cadabra2#202).
- Remove a hashbang from a non-executable script.
- Use %{name}-%{version} naming format for source.

OBS-URL: https://build.opensuse.org/request/show/824547
OBS-URL: https://build.opensuse.org/package/show/science/cadabra2?expand=0&rev=33
2020-08-24 15:59:13 +00:00

104 lines
5.5 KiB
Diff

Index: cadabra2-2.3.0/CMakeLists.txt
===================================================================
--- cadabra2-2.3.0.orig/CMakeLists.txt
+++ cadabra2-2.3.0/CMakeLists.txt
@@ -231,6 +231,9 @@ endif()
print_header("Configuring Python")
+# NEEDED TO USE CMAKE_INSTALL_FULL<dir>
+include(GNUInstallDirs)
+
if(USE_PYTHON_3)
set(PYTHON_POSTFIX "3")
message(STATUS "Building for use with Python 3 (good!)")
@@ -243,9 +246,17 @@ add_subdirectory(libs/pybind11)
message(STATUS "Found python ${PYTHON_LIBRARIES}")
-# We install the python module in our 'share' path, not in
-# the site-wide path as we used to.
-set(PYTHON_SITE_PATH share/cadabra2/python)
+if(${CMAKE_VERSION} VERSION_LESS 3.12.0)
+ find_package(PythonInterp)
+ set(PYTHON_SITE_PATH ${CMAKE_INSTALL_FULL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
+else()
+ find_package (Python COMPONENTS Interpreter)
+ set(PYTHON_SITE_PATH ${CMAKE_INSTALL_FULL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages)
+endif()
+
+string(REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "" PYTHON_SITE_PATH_REL ${PYTHON_SITE_PATH})
+set(PYTHON_SITE_PATH_REL ${PYTHON_SITE_PATH_REL})
+
if(NOT WIN32)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import site; print (site.getsitepackages()[0]);"
Index: cadabra2-2.3.0/core/cadabra2.in
===================================================================
--- cadabra2-2.3.0.orig/core/cadabra2.in
+++ cadabra2-2.3.0/core/cadabra2.in
@@ -19,10 +19,9 @@ import rlcompleter
import os
# Make sure we can find the cadabra2 python module; is always
-# installed in ../share/cadabra2/python relative to the location
-# of the 'cadabra2' script.
+# installed in PYTHON_SITE_PATH
install_prefix=os.path.realpath(sys.argv[0])
-install_prefix=install_prefix.replace(os.sep+'bin'+os.sep+'cadabra2', os.sep+'share'+os.sep+'cadabra2'+os.sep+'python')
+install_prefix=install_prefix.replace(os.sep+'bin'+os.sep+'cadabra2', '${PYTHON_SITE_PATH_REL}')
# print("Module path ", install_prefix)
sys.path.append(install_prefix)
@@ -256,5 +255,5 @@ if __name__ == '__main__':
# pulling in the right locals/globals
# sh.interact(banner='Info at http://cadabra.phi-sci.com/\nAvailable under the terms of the GNU General Public License v3\n', locals(), globals())
else:
- sh.runsource("import os; import sys; install_prefix=os.path.realpath(sys.argv[0]); install_prefix=install_prefix.replace('/bin/cadabra2','/share/cadabra2/python'); sys.path.append(install_prefix); print('Cadabra @CADABRA_VERSION_MAJOR@.@CADABRA_VERSION_MINOR@.@CADABRA_VERSION_PATCH@ (build @CADABRA_VERSION_BUILD@ dated @CADABRA_VERSION_DATE@)'); print ('Copyright (C) @COPYRIGHT_YEARS@ Kasper Peeters <kasper.peeters@phi-sci.com>'); f=open('${CMAKE_INSTALL_PREFIX}/${PYTHON_SITE_PATH}/cadabra2_defaults.py'); code=compile(f.read(), 'cadabra2_defaults.py', 'exec'); exec(code); f.close(); print('Using SymPy version '+sympy.__version__);")
+ sh.runsource("import os; import sys; install_prefix=os.path.realpath(sys.argv[0]); install_prefix=install_prefix.replace('/bin/cadabra2','${PYTHON_SITE_PATH_REL}'); sys.path.append(install_prefix); print('Cadabra @CADABRA_VERSION_MAJOR@.@CADABRA_VERSION_MINOR@.@CADABRA_VERSION_PATCH@ (build @CADABRA_VERSION_BUILD@ dated @CADABRA_VERSION_DATE@)'); print ('Copyright (C) @COPYRIGHT_YEARS@ Kasper Peeters <kasper.peeters@phi-sci.com>'); f=open('${PYTHON_SITE_PATH}/cadabra2_defaults.py'); code=compile(f.read(), 'cadabra2_defaults.py', 'exec'); exec(code); f.close(); print('Using SymPy version '+sympy.__version__);")
sh.interact(banner='Info at http://cadabra.science/\nAvailable under the terms of the GNU General Public License v3\n')
Index: cadabra2-2.3.0/core/cadabra2-cli.cc
===================================================================
--- cadabra2-2.3.0.orig/core/cadabra2-cli.cc
+++ cadabra2-2.3.0/core/cadabra2-cli.cc
@@ -113,7 +113,7 @@ void Shell::restart()
}
sys = PyImport_ImportModule("sys");
- std::string module_path = cadabra::install_prefix() + "/share/cadabra2/python";
+ std::string module_path = PYTHON_SITE_PATH;
PyObject* module_path_str = PyUnicode_FromString(module_path.c_str());
PyList_Append(PyObject_GetAttrString(sys, "path"), module_path_str);
Py_XDECREF(module_path_str);
@@ -122,7 +122,7 @@ void Shell::restart()
void Shell::interact()
{
// Run cadabra2_defaults.py
- if (!execute_file(cadabra::install_prefix() + "/share/cadabra2/python/cadabra2_defaults.py", false)) {
+ if (!execute_file(std::string(PYTHON_SITE_PATH) + "/cadabra2_defaults.py", false)) {
handle_error();
throw ExitRequest("Error encountered while initializing the interpreter");
}
Index: cadabra2-2.3.0/core/Config.hh.in
===================================================================
--- cadabra2-2.3.0.orig/core/Config.hh.in
+++ cadabra2-2.3.0/core/Config.hh.in
@@ -21,3 +21,4 @@
#define Mathematica_KERNEL_EXECUTABLE "@Mathematica_KERNEL_EXECUTABLE@"
#define PYTHON_SITE_PATH "@PYTHON_SITE_PATH@"
+#define PYTHON_SITE_PATH_REL "@PYTHON_SITE_PATH_REL@"
Index: cadabra2-2.3.0/client_server/Server.cc
===================================================================
--- cadabra2-2.3.0.orig/client_server/Server.cc
+++ cadabra2-2.3.0/client_server/Server.cc
@@ -106,7 +106,7 @@ void Server::init()
// Make the C++ CatchOutput class visible on the Python side.
- auto python_path = cadabra::install_prefix()+"/share/cadabra2/python";
+ auto python_path = std::string(PYTHON_SITE_PATH);
std::string stdOutErr =
"import sys\n"