Commit 13943887 authored by Guillaume Pasero's avatar Guillaume Pasero

Merge branch '1523-gdal-python-bindings' into 'release-6.6'

Fix installation of GDAL bindings in standalone packages

See merge request !78
parents 471a694d 50ccf35f
......@@ -32,4 +32,19 @@ function(install_python_bindings)
PATTERN "__pycache__" EXCLUDE
)
endif()
# Handle GDAL python bindings
file(GLOB gdal_python_scripts "${SUPERBUILD_INSTALL_DIR}/bin/gdal*.py")
foreach(_script ${gdal_python_scripts})
install(PROGRAMS ${_script}
DESTINATION ${PKG_STAGE_DIR}/bin)
endforeach()
file(GLOB gdal_python_wrappings "${SUPERBUILD_INSTALL_DIR}/lib/python[2|3]*")
foreach(_wrap ${gdal_python_wrappings})
if (IS_DIRECTORY "${_wrap}")
install(DIRECTORY ${_wrap}
DESTINATION ${PKG_STAGE_DIR}/lib
PATTERN "*.pyc" EXCLUDE
PATTERN "__pycache__" EXCLUDE)
endif()
endforeach()
endfunction()
......@@ -82,8 +82,12 @@ function(prepare_file_list file_list_result)
"${OTB_BINARY_DIR}/bin/otbgui_TestApplication")
foreach(otb_test_exe ${otb_test_exe_list})
get_filename_component(otb_test_exe_name ${otb_test_exe} NAME)
list(APPEND file_list ${otb_test_exe_name})
# filter .py files
get_filename_component(otb_test_exe_ext ${otb_test_exe} EXT)
if (NOT otb_test_exe_ext STREQUAL ".py")
get_filename_component(otb_test_exe_name ${otb_test_exe} NAME)
list(APPEND file_list ${otb_test_exe_name})
endif()
endforeach()
# special case for msvc: ucrtbase.dll must be explicitly vetted.
......
......@@ -43,12 +43,12 @@ set(GDAL_CONFIGURE_COMMAND)
set(GDAL_BUILD_COMMAND)
set(GDAL_INSTALL_COMMAND)
set(GDAL_SB_EXTRA_OPTIONS "" CACHE STRING "Extra options to be passed to GDAL configure script")
mark_as_advanced(GDAL_SB_EXTRA_OPTIONS)
#Convert GDAL_SB_EXTRA_OPTIONS to a list to allow to add multiple instructions to the CONFIGURE_COMMAND
separate_arguments(GDAL_SB_EXTRA_OPTIONS)
if(UNIX)
set(GDAL_SB_EXTRA_OPTIONS "" CACHE STRING "Extra options to be passed to GDAL configure script")
mark_as_advanced(GDAL_SB_EXTRA_OPTIONS)
#Convert GDAL_SB_EXTRA_OPTIONS to a list to allow to add multiple instructions to the CONFIGURE_COMMAND
separate_arguments(GDAL_SB_EXTRA_OPTIONS)
#we don't do any framework build on osx. So let's be sure on case of gdal
if(APPLE)
list(APPEND GDAL_SB_CONFIG "--with-macosx-framework=no")
......@@ -111,9 +111,13 @@ else(MSVC)
configure_file(
${CMAKE_SOURCE_DIR}/patches/GDAL/nmake_gdal_extra.opt.in
${CMAKE_BINARY_DIR}/nmake_gdal_extra.opt)
foreach(opt_line ${GDAL_SB_EXTRA_OPTIONS})
file(APPEND "${CMAKE_BINARY_DIR}/nmake_gdal_extra.opt" "${opt_line}\r\n")
endforeach()
if(OTB_TARGET_SYSTEM_ARCH_IS_X64)
file(APPEND "${CMAKE_BINARY_DIR}/nmake_gdal_extra.opt" "WIN64=YES")
file(APPEND "${CMAKE_BINARY_DIR}/nmake_gdal_extra.opt" "WIN64=YES\r\n")
endif()
set(GDAL_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/configure)
......
--- gdal-2.2.1-orig/swig/python/GNUmakefile 2017-06-23 14:18:44.000000000 +0200
+++ gdal-2.2.1/swig/python/GNUmakefile 2018-03-13 17:20:34.951592209 +0100
@@ -81,18 +81,7 @@
endif
ifdef prefix
- ifeq ($(shell uname),Darwin)
- STD_UNIX_LAYOUT=$(shell $(PYTHON) -c "from __future__ import print_function;import sys;print(\"FALSE\" if \"framework\" in sys.prefix.lower() else \"TRUE\")")
- ifeq ($(STD_UNIX_LAYOUT),"TRUE")
- setup_opts+=--prefix=$(prefix)
- else
- ifdef PYTHON_INSTALL_LIB
- setup_opts+=--install-lib=$(PYTHON_INSTALL_LIB)
- endif
- endif
- else
- setup_opts+=--prefix=$(prefix)
- endif
+ setup_opts+=--install-lib=$(site_package_dir)
endif
ifdef INSTALL_LAYOUT
--- gdal-2.2.1-orig/swig/python/setup.py 2017-06-23 14:18:44.000000000 +0200
+++ gdal-2.2.1/swig/python/setup.py 2018-03-14 15:42:14.058663110 +0100
@@ -27,6 +27,11 @@
print('WARNING: "CXX=%s" was defined in the environment and contains more than one word. Unsetting it since that is incompatible of distutils' % os.environ['CXX'])
del os.environ['CXX']
+# do the same for CC for consistent results
+if 'CC' in os.environ and os.environ['CC'].strip().find(' ') >= 0:
+ print('WARNING: "CC=%s" was defined in the environment and contains more than one word. Unsetting it since that is incompatible of distutils' % os.environ['CC'])
+ del os.environ['CC']
+
# ---------------------------------------------------------------------------
# Switches
# ---------------------------------------------------------------------------
--- gdal-2.2.1-orig/makefile.vc 2017-06-23 14:18:38.000000000 +0200
+++ gdal-2.2.1/makefile.vc 2018-03-14 19:05:43.372712378 +0100
@@ -49,6 +49,12 @@
DISTDIR = gdal_$(VERSION)
+WRAP_TARGETS =
+
+!IFDEF WRAP_PYTHON
+WRAP_TARGETS = $(WRAP_TARGETS) swig_py
+!ENDIF
+
!IFDEF DLLBUILD
TARGET_LIB = dll
PLUGIN_TARGET = plugin_dir
@@ -58,7 +64,7 @@
DEFAULT_TARGETS =
-default: $(TARGET_LIB) $(PLUGIN_TARGET) apps_dir
+default: $(TARGET_LIB) $(PLUGIN_TARGET) apps_dir $(WRAP_TARGETS)
staticlib: $(LIB_DEPENDS)
if exist gdal.lib del gdal.lib
@@ -166,6 +172,11 @@
dll: $(GDAL_DLL)
+swig_py: $(TARGET_LIB)
+ cd swig
+ $(MAKE) /f makefile.vc python
+ cd ..
+
install: default
-mkdir $(BINDIR)
-mkdir $(DATADIR)
@@ -191,6 +202,11 @@
!ENDIF
cd ..\..
!ENDIF
+!IFDEF WRAP_PYTHON
+ cd swig
+ $(MAKE) /f makefile.vc python-install
+ cd ..
+!ENDIF
libinstall: $(GDALLIB)
-mkdir $(LIBDIR)
--- gdal-2.2.1-orig/swig/makefile.vc 2017-06-23 14:18:45.000000000 +0200
+++ gdal-2.2.1/swig/makefile.vc 2018-03-14 19:04:05.851776139 +0100
@@ -22,6 +22,11 @@
$(SWIG) -c++ -python -modern -new_repr -I../include/python -I../include/python/docs -o extensions/gdal_array_wrap.cpp -outdir osgeo ..\include\gdal_array.i
$(PYDIR)\python.exe setup.py build
+python-install: python
+ cd python
+ $(PYDIR)\python.exe setup.py install --prefix=$(GDAL_HOME)
+ # TODO: install python scripts
+
#d:\Python\debug\Python-2.4\PCbuild\python_d.exe setup.py build --debug
csharp: gdalvars
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment