diff --git a/CMakeLists.txt b/CMakeLists.txt index a22596b1b..c189e1c4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0.2) +cmake_minimum_required(VERSION 3.16) set(catkin_EXTRAS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake) diff --git a/cmake/all.cmake b/cmake/all.cmake index 7768f968d..8e94d1fe1 100644 --- a/cmake/all.cmake +++ b/cmake/all.cmake @@ -34,7 +34,7 @@ if(EXISTS ${_catkin_marker_file}) endif() else() # create a new develspace marker file - # NOTE: extra care must be taken when running multiple catkin jobs in parallel + # NOTE: extra care must be taken when running multiple catkin jobs in parallel # so that this does not overwrite the result of a similar call in another package file(WRITE ${_catkin_marker_file} "${CMAKE_SOURCE_DIR}") endif() @@ -120,7 +120,7 @@ endif() include(CMakeParseArguments) # functions/macros: list_append_unique, safe_execute_process -# python-integration: catkin_python_setup.cmake, interrogate_setup_dot_py.py, templates/__init__.py.in, templates/script.py.in, templates/python_distutils_install.bat.in, templates/python_distutils_install.sh.in, templates/safe_execute_install.cmake.in +# python-integration: catkin_python_setup.cmake, interrogate_setup_dot_py.py, templates/__init__.py.in, templates/script.py.in, templates/python_install.bat.in, templates/python_install.sh.in, templates/safe_execute_install.cmake.in foreach(filename assert atomic_configure_file diff --git a/cmake/catkin_python_setup.cmake b/cmake/catkin_python_setup.cmake index e360706f3..307ca7f12 100644 --- a/cmake/catkin_python_setup.cmake +++ b/cmake/catkin_python_setup.cmake @@ -148,19 +148,20 @@ function(catkin_python_setup) set(SETUPTOOLS_EGG_INFO "") endif() + cmake_path(CONVERT "${CMAKE_BINARY_DIR}/setuptools_build" TO_NATIVE_PATH_LIST SETUPTOOLS_BUILD_DIR NORMALIZE) set(INSTALL_CMD_WORKING_DIRECTORY ${${PROJECT_NAME}_SOURCE_DIR}) if(NOT WIN32) set(INSTALL_SCRIPT - ${CMAKE_CURRENT_BINARY_DIR}/catkin_generated/python_distutils_install.sh) - configure_file(${catkin_EXTRAS_DIR}/templates/python_distutils_install.sh.in + ${CMAKE_CURRENT_BINARY_DIR}/catkin_generated/python_install.sh) + configure_file(${catkin_EXTRAS_DIR}/templates/python_install.sh.in ${INSTALL_SCRIPT} @ONLY) else() # need to convert install prefix to native path for python setuptools --prefix (its fussy about \'s) file(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX} PYTHON_INSTALL_PREFIX) set(INSTALL_SCRIPT - ${CMAKE_CURRENT_BINARY_DIR}/catkin_generated/python_distutils_install.bat) - configure_file(${catkin_EXTRAS_DIR}/templates/python_distutils_install.bat.in + ${CMAKE_CURRENT_BINARY_DIR}/catkin_generated/python_install.bat) + configure_file(${catkin_EXTRAS_DIR}/templates/python_install.bat.in ${INSTALL_SCRIPT} @ONLY) endif() diff --git a/cmake/python.cmake b/cmake/python.cmake index c72b85999..f141102b4 100644 --- a/cmake/python.cmake +++ b/cmake/python.cmake @@ -1,11 +1,16 @@ # the CMake variable PYTHON_INSTALL_DIR has the same value as the Python function catkin.builder.get_python_install_dir() set(PYTHON_VERSION "$ENV{ROS_PYTHON_VERSION}" CACHE STRING "Specify specific Python version to use ('major.minor' or 'major')") -find_package(PythonInterp ${PYTHON_VERSION} REQUIRED) +find_package(Python ${PYTHON_VERSION} COMPONENTS Interpreter REQUIRED) -message(STATUS "Using PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}") +# Set variables for compatibility with old find_package(PythonInterp) +set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) +set(PYTHON_VERSION_STRING ${Python_VERSION}) +set(PYTHON_VERSION_MAJOR ${Python_VERSION_MAJOR}) +set(PYTHON_VERSION_MINOR ${Python_VERSION_MINOR}) +message(STATUS "Using Python_EXECUTABLE: ${Python_EXECUTABLE}") -set(_PYTHON_PATH_VERSION_SUFFIX "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") +set(_PYTHON_PATH_VERSION_SUFFIX "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") set(enable_setuptools_deb_layout OFF) if(EXISTS "/etc/debian_version") @@ -16,10 +21,10 @@ option(SETUPTOOLS_DEB_LAYOUT "Enable debian style python package layout" ${enabl if(SETUPTOOLS_DEB_LAYOUT) message(STATUS "Using Debian Python package layout") set(PYTHON_PACKAGES_DIR dist-packages) - set(SETUPTOOLS_ARG_EXTRA "--install-layout=deb") + set(PIP_EXTRA_ENV "DEB_PYTHON_INSTALL_LAYOUT=deb") # use major version only when installing 3.x with debian layout - if("${PYTHON_VERSION_MAJOR}" STREQUAL "3") - set(_PYTHON_PATH_VERSION_SUFFIX "${PYTHON_VERSION_MAJOR}") + if("${Python_VERSION_MAJOR}" STREQUAL "3") + set(_PYTHON_PATH_VERSION_SUFFIX "${Python_VERSION_MAJOR}") endif() else() message(STATUS "Using default Python package layout") diff --git a/cmake/templates/python_distutils_install.sh.in b/cmake/templates/python_distutils_install.sh.in deleted file mode 100755 index dd35f732b..000000000 --- a/cmake/templates/python_distutils_install.sh.in +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -if [ -n "$DESTDIR" ] ; then - case $DESTDIR in - /*) # ok - ;; - *) - /bin/echo "DESTDIR argument must be absolute... " - /bin/echo "otherwise python's distutils will bork things." - exit 1 - esac -fi - -echo_and_run() { echo "+ $@" ; "$@" ; } - -echo_and_run cd "@INSTALL_CMD_WORKING_DIRECTORY@" - -# ensure that Python install destination exists -echo_and_run mkdir -p "$DESTDIR@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_DIR@" - -# Note that PYTHONPATH is pulled from the environment to support installing -# into one location when some dependencies were installed in another -# location, #123. -echo_and_run /usr/bin/env \ - PYTHONPATH="@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_DIR@:@CMAKE_BINARY_DIR@/@PYTHON_INSTALL_DIR@:$PYTHONPATH" \ - CATKIN_BINARY_DIR="@CMAKE_BINARY_DIR@" \ - "@PYTHON_EXECUTABLE@" \ - "@CMAKE_CURRENT_SOURCE_DIR@/setup.py" \ - @SETUPTOOLS_EGG_INFO@ \ - build --build-base "@CMAKE_CURRENT_BINARY_DIR@" \ - install \ - --root="${DESTDIR-/}" \ - @SETUPTOOLS_ARG_EXTRA@ --prefix="@CMAKE_INSTALL_PREFIX@" --install-scripts="@CMAKE_INSTALL_PREFIX@/@CATKIN_GLOBAL_BIN_DESTINATION@" diff --git a/cmake/templates/python_distutils_install.bat.in b/cmake/templates/python_install.bat.in similarity index 58% rename from cmake/templates/python_distutils_install.bat.in rename to cmake/templates/python_install.bat.in index a6b1f6f28..f2168394d 100644 --- a/cmake/templates/python_distutils_install.bat.in +++ b/cmake/templates/python_install.bat.in @@ -12,16 +12,14 @@ if NOT EXIST "@SETUPTOOLS_INSTALL_PREFIX@\@PYTHON_INSTALL_DIR@\" ( ) set "PYTHONPATH=@SETUPTOOLS_INSTALL_PREFIX@\@PYTHON_INSTALL_DIR@;@CMAKE_BINARY_DIR@\@PYTHON_INSTALL_DIR@" -set "CATKIN_BINARY_DIR=@CMAKE_BINARY_DIR@" for /f "usebackq tokens=*" %%a in ('@SETUPTOOLS_INSTALL_PREFIX@') do ( set _SETUPTOOLS_INSTALL_PATH=%%~pna set _SETUPTOOLS_INSTALL_ROOT=%%~da ) -"@PYTHON_EXECUTABLE@" ^ - "@CMAKE_CURRENT_SOURCE_DIR@\setup.py" ^ - build --build-base "@CMAKE_CURRENT_BINARY_DIR@" ^ - install %DESTDIR_ARG% @SETUPTOOLS_ARG_EXTRA@ ^ - --prefix="%_SETUPTOOLS_INSTALL_PATH%" ^ - --install-scripts="%_SETUPTOOLS_INSTALL_PATH%\@CATKIN_GLOBAL_BIN_DESTINATION@" ^ - --root=%_SETUPTOOLS_INSTALL_ROOT%\ +"@PYTHON_EXECUTABLE@" -m build --wheel --outdir "@SETUPTOOLS_BUILD_DIR@" --no-isolation ^ + @SETUPTOOLS_OVERRIDE_BUILD_BASE@ ^ + "@CMAKE_CURRENT_SOURCE_DIR@" && + +"@PYTHON_EXECUTABLE@" -m pip install --prefix "%_SETUPTOOLS_INSTALL_PATH%" --ignore-installed --no-deps ^ + "@SETUPTOOLS_BUILD_DIR@"\*.whl diff --git a/cmake/templates/python_install.sh.in b/cmake/templates/python_install.sh.in new file mode 100755 index 000000000..d49824807 --- /dev/null +++ b/cmake/templates/python_install.sh.in @@ -0,0 +1,46 @@ +#!/bin/sh + +if [ -n "$DESTDIR" ] ; then + case $DESTDIR in + /*) # ok + ;; + *) + /bin/echo "DESTDIR argument must be absolute... " + /bin/echo "otherwise python's distutils will bork things." + exit 1 + esac +fi + +echo_and_run() { echo "+ $@" ; "$@" ; } + +echo_and_run cd "@INSTALL_CMD_WORKING_DIRECTORY@" + +# ensure that Python install destination exists +echo_and_run mkdir -p "$DESTDIR@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_DIR@" + +# Note that PYTHONPATH is pulled from the environment to support installing +# into one location when some dependencies were installed in another +# location, #123. +echo_and_run /usr/bin/env \ + @PIP_EXTRA_ENV@ \ + PYTHONPATH="@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_DIR@:@CMAKE_BINARY_DIR@/@PYTHON_INSTALL_DIR@:$PYTHONPATH" \ + "@PYTHON_EXECUTABLE@" -m build \ + --wheel \ + --outdir @SETUPTOOLS_BUILD_DIR@ \ + --no-isolation \ + --config-setting=--build-option=build --config-setting=--build-option=--build-base=@SETUPTOOLS_BUILD_DIR@ \ + "@CMAKE_CURRENT_SOURCE_DIR@" && + +# Remove temporary *.egg-info directories created by setuptools during build +echo_and_run find -L "@CMAKE_CURRENT_SOURCE_DIR@" -name "*.egg-info" -print -exec rm -r {} + && + +echo_and_run /usr/bin/env \ + @PIP_EXTRA_ENV@ \ + PIP_BREAK_SYSTEM_PACKAGES=1 \ + PYTHONPATH="@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_DIR@:@CMAKE_BINARY_DIR@/@PYTHON_INSTALL_DIR@:$PYTHONPATH" \ + "@PYTHON_EXECUTABLE@" -m pip install \ + --prefix "@CMAKE_INSTALL_PREFIX@" \ + ${DESTDIR:+--root "$DESTDIR"} \ + --ignore-installed \ + --no-deps \ + "@SETUPTOOLS_BUILD_DIR@"/*.whl diff --git a/cmake/toplevel.cmake b/cmake/toplevel.cmake index 744c4b249..3bfc96722 100644 --- a/cmake/toplevel.cmake +++ b/cmake/toplevel.cmake @@ -1,7 +1,7 @@ # toplevel CMakeLists.txt for a catkin workspace # catkin/cmake/toplevel.cmake -cmake_minimum_required(VERSION 3.0.2) +cmake_minimum_required(VERSION 3.16) project(Project) diff --git a/doc/adv_user_guide/catkin_migration.rst b/doc/adv_user_guide/catkin_migration.rst index 6cd3a8a53..862fa8f28 100644 --- a/doc/adv_user_guide/catkin_migration.rst +++ b/doc/adv_user_guide/catkin_migration.rst @@ -75,7 +75,7 @@ The contents of the /stick/stick/package.xml must look like this:: The contents of the /stick/stick/CMakeLists.txt looks like this:: - cmake_minimum_required(VERSION 3.0.2) + cmake_minimum_required(VERSION 3.16) project(stick) find_package(catkin REQUIRED) catkin_metapackage() diff --git a/doc/howto/format1/catkin_overview.rst b/doc/howto/format1/catkin_overview.rst index da858168e..147b8921a 100644 --- a/doc/howto/format1/catkin_overview.rst +++ b/doc/howto/format1/catkin_overview.rst @@ -84,7 +84,7 @@ CMakeLists.txt Catkin ``CMakeLists.txt`` files mostly contain ordinary CMake commands, plus a few catkin-specific ones. They begin like this:: - cmake_minimum_required(VERSION 3.0.2) + cmake_minimum_required(VERSION 3.16) project(your_package) Substitute the actual name of your package in the ``project()`` diff --git a/doc/howto/format2/catkin_overview.rst b/doc/howto/format2/catkin_overview.rst index b6f2a8625..cf46757a0 100644 --- a/doc/howto/format2/catkin_overview.rst +++ b/doc/howto/format2/catkin_overview.rst @@ -85,7 +85,7 @@ CMakeLists.txt Catkin ``CMakeLists.txt`` files mostly contain ordinary CMake commands, plus a few catkin-specific ones. They begin like this:: - cmake_minimum_required(VERSION 3.0.2) + cmake_minimum_required(VERSION 3.16) project(your_package) Substitute the actual name of your package in the ``project()`` diff --git a/doc/user_guide/standards.rst b/doc/user_guide/standards.rst index d4ea9dfbe..2663977e2 100644 --- a/doc/user_guide/standards.rst +++ b/doc/user_guide/standards.rst @@ -13,7 +13,7 @@ For inspiration, look at the guideline examples here: The following lines must always appear the CMakeLists.txt in this order:: - cmake_minimum_required(VERSION 3.0.2) + cmake_minimum_required(VERSION 3.16) project(myproject) find_package(catkin REQUIRED ) catkin_package(<...>) diff --git a/package.xml b/package.xml index 4ad37eb69..42d699fa7 100644 --- a/package.xml +++ b/package.xml @@ -30,9 +30,15 @@ cmake python-setuptools python3-setuptools + python-pip + python3-pip + python3-build cmake python3-setuptools + python-pip + python3-pip + python3-build google-mock gtest diff --git a/test/mock_resources/src-fail/badly_specified_changelog/CMakeLists.txt b/test/mock_resources/src-fail/badly_specified_changelog/CMakeLists.txt index 5e4c06765..5e6ff8646 100644 --- a/test/mock_resources/src-fail/badly_specified_changelog/CMakeLists.txt +++ b/test/mock_resources/src-fail/badly_specified_changelog/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0.2) +cmake_minimum_required(VERSION 3.16) project(badly_specified_changelog) find_package(catkin) diff --git a/test/mock_resources/src-fail/noproject/CMakeLists.txt b/test/mock_resources/src-fail/noproject/CMakeLists.txt index 4f112c75f..da13c4ca4 100644 --- a/test/mock_resources/src-fail/noproject/CMakeLists.txt +++ b/test/mock_resources/src-fail/noproject/CMakeLists.txt @@ -1,7 +1,6 @@ -cmake_minimum_required(VERSION 3.0.2) +cmake_minimum_required(VERSION 3.16) # commented to cause failure # project(noproject) find_package(catkin) catkin_package() -