Looks like my propositions regarding the shebang did not go down well; nevertheless I find that upstream seems to have taken in my last patch. It may be ugly, but I think it works. I accept that a proper shebang would be nice, and so I did some work towards moving to python3:

I tried to build hugin with hsi/hpi and python3 support. I worked on a ubuntu 19.04 system (to have a recent cmake). I had to install the usual suspects and provide a hand-compiled vigra, because the one provided by the package management missed openEXR. Compiling with hsi/hpi support (cmake with -DBUILD_HSI:BOOL=ON) for python2 worked as expected. Next I modified the cmake code to use python3 and swig3, and managed to get the build all the way up to hugin_stitch_project, where it terminated due to linker errors.

That the build proceeded so far means that I was able to build the hugin python module (I checked, it imports into python3), but there is a problem when linking with the hugin python interface (which embeds python3 into hugin): a lot of python-specific symbols are not found. I tried to explicitly add the python3 libs to the set of dependencies in the cmake code (and tried all other tricks I could think of...), but to no avail. So I'm stuck.

Would anyone care to pick up my attempts so far and look into the linker errors? Prefereably someone who's good at cmake (which I'm not)?

I attach a patch against a pull from today noon-ish, which has the modifications to the cmake code.

Kay

--
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
--- You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/93a68e80-36dd-0ad7-1132-1a48daff1bc3%40yahoo.com.
diff -r 74b0d520e1a7 CMakeLists.txt
--- a/CMakeLists.txt	Sun Aug 25 17:20:36 2019 -0300
+++ b/CMakeLists.txt	Thu Aug 29 12:32:12 2019 +0200
@@ -454,26 +454,27 @@
     FIND_PACKAGE(PythonLibs REQUIRED)
   else()
     #  Linux/MacOS
-    find_package(PythonInterp REQUIRED)
-    find_package(PythonLibs ${PYTHON_VERSION_STRING} REQUIRED)
+    # find_package(PythonInterp REQUIRED)
+    # find_package(PythonLibs ${PYTHON_VERSION_STRING} REQUIRED)
+    find_package (Python3 COMPONENTS Interpreter Development)
   endif()
-  INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
+  INCLUDE_DIRECTORIES(${Python3_INCLUDE_DIRS})
   ADD_DEFINITIONS(-DHUGIN_HSI)
-  FIND_FILE(PYTHON_PATCHLEVEL_H patchlevel.h
-      PATHS ${PYTHON_INCLUDE_DIRS}
+  FIND_FILE(PYTHON3_PATCHLEVEL_H patchlevel.h
+      PATHS ${Python3_INCLUDE_DIRS}
   )
-  IF(${PYTHON_PATCHLEVEL_H} MATCHES "-NOTFOUND")
-      MESSAGE(FATAL_ERROR "Python patchlevel.h not found")
+  IF(${PYTHON_PATCHLEVEL3_H} MATCHES "-NOTFOUND")
+      MESSAGE(FATAL_ERROR "Python3 patchlevel.h not found")
   ENDIF()
   # get version of Python libs
-  FILE(STRINGS "${PYTHON_PATCHLEVEL_H}"
+  FILE(STRINGS "${PYTHON3_PATCHLEVEL_H}"
       PY_DEF_MAJOR
       REGEX "#define[ \t]+PY_MAJOR_VERSION.*$")
-  FILE(STRINGS "${PYTHON_PATCHLEVEL_H}"
+  FILE(STRINGS "${PYTHON3_PATCHLEVEL_H}"
       PY_DEF_MINOR
       REGEX "#define[ \t]+PY_MINOR_VERSION.*$")
 
-  FILE(STRINGS "${PYTHON_PATCHLEVEL_H}"
+  FILE(STRINGS "${PYTHON3_PATCHLEVEL_H}"
       PY_DEF_MICRO
       REGEX "#define[ \t]+PY_MICRO_VERSION.*$")
   STRING(REGEX
@@ -489,16 +490,19 @@
         PYTHON_VERSION_PATCH
         "${PY_DEF_MICRO}")
   # now we can find the right SWIG version
-  find_program(SWIG_EXECUTABLE NAMES swig2.0 swig)
+  find_program(SWIG_EXECUTABLE NAMES swig3.0 swig2.0 swig)
   # unclean to test for Python 3, but the assumption is that by the
   # time we have Python 4 this issue is long gone
   IF(${PYTHON_VERSION_MAJOR} EQUAL 3 AND 
       ${PYTHON_VERSION_MINOR} GREATER 1)
-    FIND_PACKAGE(SWIG 2.0.4 REQUIRED)
+    FIND_PACKAGE(SWIG 3.0 REQUIRED)
   ELSE()
-    FIND_PACKAGE(SWIG 2.0 REQUIRED)
+    FIND_PACKAGE(SWIG 3.0 REQUIRED)
   ENDIF()
-  INCLUDE(${SWIG_USE_FILE})
+  IF(SWIG_FOUND)
+    MESSAGE(STATUS "Found SWIG")
+  ENDIF()
+  # cmake chokes on: INCLUDE(${SWIG_USE_FILE})
 ENDIF()
 
 ##
diff -r 74b0d520e1a7 src/hugin1/stitch_project/CMakeLists.txt
--- a/src/hugin1/stitch_project/CMakeLists.txt	Sun Aug 25 17:20:36 2019 -0300
+++ b/src/hugin1/stitch_project/CMakeLists.txt	Thu Aug 29 12:32:12 2019 +0200
@@ -94,7 +94,13 @@
 ENDIF (WIN32)
 
 
-target_link_libraries(${PROGNAME} huginbasewx ${common_libs} ${image_libs} ${wxWidgets_LIBRARIES})
+# KFJ: tried to add Python3_LIBRARIES to get rid of ld errors
+# (namely, lots of undefined symbols), so:
+target_link_libraries(${PROGNAME} huginbasewx ${Python3_LIBRARIES} ${common_libs} ${image_libs} ${wxWidgets_LIBRARIES}) 
+# but the problem persists
+
+# was:
+# target_link_libraries(${PROGNAME} huginbasewx ${common_libs} ${image_libs} ${wxWidgets_LIBRARIES})
 
 IF (APPLE)
   IF (NOT MAC_SELF_CONTAINED_BUNDLE)
diff -r 74b0d520e1a7 src/hugin_script_interface/CMakeLists.txt
--- a/src/hugin_script_interface/CMakeLists.txt	Sun Aug 25 17:20:36 2019 -0300
+++ b/src/hugin_script_interface/CMakeLists.txt	Thu Aug 29 12:32:12 2019 +0200
@@ -187,8 +187,12 @@
 # finally, we specify the hsi module itself
 
 SET_SOURCE_FILES_PROPERTIES(hsi.i PROPERTIES CPLUSPLUS ON)
-SWIG_ADD_MODULE(hsi python hsi.i)
-SWIG_LINK_LIBRARIES(hsi ${PYTHON_LIBRARIES} ${common_libs})
+FIND_PACKAGE(SWIG 3.0 REQUIRED)
+include(UseSWIG)
+# SWIG_ADD_LIBRARY(hsi python hsi.i)
+swig_add_library(hsi LANGUAGE python SOURCES hsi.i)
+set_property(SOURCE hsi.i PROPERTY COMPILE_OPTIONS -py3)
+SWIG_LINK_LIBRARIES(hsi ${Python3_LIBRARIES} ${common_libs})
 
 # The remainder defines where the files are installed.
 # TODO this section is incomplete - non-windows install is missing
@@ -201,7 +205,7 @@
     # Linux/MacOS
     # install Python related files into folder depending on used Python version
 
-    EXECUTE_PROCESS( COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))"
+    EXECUTE_PROCESS( COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))"
                      OUTPUT_VARIABLE pyinstalldir
                      OUTPUT_STRIP_TRAILING_WHITESPACE)
 
diff -r 74b0d520e1a7 src/hugin_script_interface/hpi.cpp
--- a/src/hugin_script_interface/hpi.cpp	Sun Aug 25 17:20:36 2019 -0300
+++ b/src/hugin_script_interface/hpi.cpp	Thu Aug 29 12:32:12 2019 +0200
@@ -1,4 +1,4 @@
-/** @file hpi.h
+/** @file hpi.cpp
  *
  *  @brief C++ call interface to hpi
  *
diff -r 74b0d520e1a7 src/hugin_script_interface/hpi_classes.h
--- a/src/hugin_script_interface/hpi_classes.h	Sun Aug 25 17:20:36 2019 -0300
+++ b/src/hugin_script_interface/hpi_classes.h	Thu Aug 29 12:32:12 2019 +0200
@@ -131,4 +131,4 @@
     PyObject* yield();
 };
 
-}; //namespace
\ No newline at end of file
+}; //namespace

Reply via email to