Skip to content

Commit 8c9ff8e

Browse files
rouaultsebastic
andcommitted
Python bindings: use 'pip install' instead of 'python setup.py install'
Fixes #9965 Co-authored-by: Bas Couwenberg <sebastic@xs4all.nl>
1 parent fb0fafb commit 8c9ff8e

3 files changed

Lines changed: 3 additions & 36 deletions

File tree

doc/source/development/building_from_source.rst

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,12 +2453,6 @@ the ``install`` CMake target.
24532453
``deb`` when it is detected that the Python installation looks for
24542454
the ``site-packages`` subdirectory. Otherwise it is unspecified.
24552455

2456-
.. option:: GDAL_PYTHON_INSTALL_LIB
2457-
2458-
This option can be specified to set the value of the ``--install-lib``
2459-
option of ``python3 setup.py install``. It is only taken into account on
2460-
MacOS systems, when the Python installation is a framework.
2461-
24622456
.. note::
24632457

24642458
The Python bindings are made of several modules (osgeo.gdal, osgeo.ogr, etc.)
@@ -2535,7 +2529,7 @@ For more details on how to build and use the C# bindings read the dedicated sect
25352529

25362530
.. option:: CSHARP_APPLICATION_VERSION
25372531

2538-
Sets the .NET target Framework (in TFM format) to be used when compiling the C# sample applications. `List of acceptable contents for .NET <https://docs.microsoft.com/en-us/dotnet/standard/frameworks#supported-target-frameworks>`_.
2532+
Sets the .NET target Framework (in TFM format) to be used when compiling the C# sample applications. `List of acceptable contents for .NET <https://docs.microsoft.com/en-us/dotnet/standard/frameworks#supported-target-frameworks>`_.
25392533
Defaults to the highest version installed on the build system, i.e. `latest`.
25402534

25412535
.. option:: GDAL_CSHARP_ONLY=OFF/ON

swig/python/CMakeLists.txt

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ if __name__ == '__main__':
448448
OUTPUT_VARIABLE SITE_PACKAGE_DIR
449449
OUTPUT_STRIP_TRAILING_WHITESPACE)
450450

451-
set(INSTALL_ARGS "--single-version-externally-managed --record=record.txt")
452451
set(CAN_USE_CMAKE_INSTALL_PREFIX_FROM_CMAKE_INSTALL FALSE)
453452
set(IGNORE_CMAKE_INSTALL_PREFIX_CONFIGURE_TIME_DIFFERENT_FROM_RUNTIME FALSE)
454453
if (DEFINED GDAL_PYTHON_INSTALL_PREFIX)
@@ -473,8 +472,6 @@ if __name__ == '__main__':
473472
OUTPUT_STRIP_TRAILING_WHITESPACE)
474473
if ("${STD_UNIX_LAYOUT}" STREQUAL "TRUE")
475474
set(CAN_USE_CMAKE_INSTALL_PREFIX_FROM_CMAKE_INSTALL TRUE)
476-
elseif (DEFINED GDAL_PYTHON_INSTALL_LIB)
477-
set(INSTALL_ARGS "${INSTALL_ARGS} \"--install-lib=${GDAL_PYTHON_INSTALL_LIB}\"")
478475
endif ()
479476
else ()
480477
set(CAN_USE_CMAKE_INSTALL_PREFIX_FROM_CMAKE_INSTALL TRUE)
@@ -484,32 +481,8 @@ if __name__ == '__main__':
484481
# setuptools 60.0 defaults to SETUPTOOLS_USE_DISTUTILS=local, and thus Debian's specific --install-layout distutils
485482
# option cannot be used
486483
if (DEFINED GDAL_PYTHON_INSTALL_LAYOUT)
487-
set(INSTALL_ARGS "${INSTALL_ARGS} --install-layout=${GDAL_PYTHON_INSTALL_LAYOUT}")
488484
set(SETUPTOOLS_USE_DISTUTILS stdlib)
489485
elseif ("${SITE_PACKAGE_DIR}" MATCHES "dist-packages")
490-
491-
# We are running on Debian, but test if our setuptools version supports
492-
# Debian --install-layout
493-
# This might not be the case if using a regular (non-Debian patched) Python
494-
# installation or setuptools (cf https://github.com/OSGeo/gdal/issues/11636)
495-
execute_process(
496-
COMMAND env GDAL_PYTHON_CHECK_SOURCE_FILES=no GDAL_PYTHON_BINDINGS_WITHOUT_NUMPY=yes ${Python_EXECUTABLE_CMAKE} setup.py install --help
497-
OUTPUT_VARIABLE SETUP_INSTALL_HELP
498-
OUTPUT_STRIP_TRAILING_WHITESPACE
499-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
500-
)
501-
# If so, uses it.
502-
if ("${SETUP_INSTALL_HELP}" MATCHES "install-layout")
503-
set(INSTALL_ARGS "${INSTALL_ARGS} --install-layout=deb")
504-
endif()
505-
506-
if (NOT DEFINED GDAL_PYTHON_INSTALL_LIB AND "${PREFIX_FOR_TRIMMEDSYSCONFIG}" STREQUAL "/usr/local")
507-
# Scenario of https://github.com/OSGeo/gdal/issues/10242
508-
# For some reason patched setuptools of Debian fails to install by default
509-
# in /usr/local/lib/python{version}/dist-packages even when passing
510-
# --prefix=/usr/local and --install-layout=deb
511-
set(INSTALL_ARGS "${INSTALL_ARGS} \"--install-lib=${SITE_PACKAGE_DIR}\"")
512-
endif()
513486
if(Python_VERSION VERSION_LESS 3.12)
514487
# It no longer seems needed to mess with SETUPTOOLS_USE_DISTUTILS
515488
# with Debian Python 3.12 (or maybe its setuptools 68.1.2 version...),

swig/python/install_python.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ else()
2323
set(PATH_SEP ":")
2424
endif()
2525
if(DEFINED INSTALL_PREFIX)
26-
execute_process(COMMAND ${CMAKE_COMMAND} -E env "PATH=@PROJECT_BINARY_DIR@/apps${PATH_SEP}$ENV{PATH}" "@Python_EXECUTABLE_CMAKE@" "@SETUP_PY_FILENAME@" install ${ROOT_DIR_ARG} @INSTALL_ARGS@ "${INSTALL_PREFIX}"
26+
execute_process(COMMAND ${CMAKE_COMMAND} -E env "PATH=@PROJECT_BINARY_DIR@/apps${PATH_SEP}$ENV{PATH}" "@Python_EXECUTABLE_CMAKE@" -m pip install --no-build-isolation ${ROOT_DIR_ARG} @INSTALL_ARGS@ "${INSTALL_PREFIX}" .
2727
WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@" RESULT_VARIABLE res)
2828
else()
29-
execute_process(COMMAND ${CMAKE_COMMAND} -E env "PATH=@PROJECT_BINARY_DIR@/apps${PATH_SEP}$ENV{PATH}" "@Python_EXECUTABLE_CMAKE@" "@SETUP_PY_FILENAME@" install ${ROOT_DIR_ARG} @INSTALL_ARGS@
29+
execute_process(COMMAND ${CMAKE_COMMAND} -E env "PATH=@PROJECT_BINARY_DIR@/apps${PATH_SEP}$ENV{PATH}" "@Python_EXECUTABLE_CMAKE@" -m pip install --no-build-isolation ${ROOT_DIR_ARG} @INSTALL_ARGS@ .
3030
WORKING_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@" RESULT_VARIABLE res)
3131
endif()
3232
if(NOT res EQUAL 0)

0 commit comments

Comments
 (0)