Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use CMake 3.12+ FindPython to get Python components #1906

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=/usr \
-DPYTHON_EXECUTABLE=$(command -v python3) \
-DPython_EXECUTABLE=$(command -v python3) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these could actually be removed, as CMake will find /usr/bin/python3 just fine, but I can do this later.

-DFORCE_ENABLED=ON \
-DENABLE_TESTS=ON \
-DENABLE_XRDEC=ON \
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=/usr \
-DPYTHON_EXECUTABLE=$(command -v python3) \
-DPython_EXECUTABLE=$(command -v python3) \
-DFORCE_ENABLED=ON \
-DENABLE_TESTS=ON \
-DENABLE_XRDEC=ON \
Expand Down Expand Up @@ -245,7 +245,7 @@ jobs:
cd ..
cmake3 \
-DCMAKE_INSTALL_PREFIX=/usr/local/ \
-DPYTHON_EXECUTABLE=$(command -v python3) \
-DPython_EXECUTABLE=$(command -v python3) \
-DENABLE_TESTS=ON \
-DPIP_OPTIONS="--verbose" \
-S xrootd \
Expand Down Expand Up @@ -322,7 +322,7 @@ jobs:
cd ..
cmake3 \
-DCMAKE_INSTALL_PREFIX=/usr/local/ \
-DPYTHON_EXECUTABLE=$(command -v python3) \
-DPython_EXECUTABLE=$(command -v python3) \
-DENABLE_TESTS=ON \
-DPIP_OPTIONS="--verbose --force-reinstall --prefix /usr/local/" \
-S xrootd \
Expand Down Expand Up @@ -391,7 +391,7 @@ jobs:
cd ..
cmake3 \
-DCMAKE_INSTALL_PREFIX=/usr/ \
-DPYTHON_EXECUTABLE=$(command -v python2) \
-DPython_EXECUTABLE=$(command -v python2) \
-DENABLE_TESTS=ON \
-DPIP_OPTIONS="--verbose" \
-DXRD_PYTHON_REQ_VERSION="2.7" \
Expand Down Expand Up @@ -453,7 +453,7 @@ jobs:
cd ..
cmake \
-DCMAKE_INSTALL_PREFIX=/usr \
-DPYTHON_EXECUTABLE=$(command -v python3) \
-DPython_EXECUTABLE=$(command -v python3) \
-DENABLE_TESTS=ON \
-DPIP_OPTIONS="--verbose" \
-S xrootd \
Expand Down Expand Up @@ -517,7 +517,7 @@ jobs:
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX=/usr/local/ \
-DCMAKE_PREFIX_PATH=/usr/local/opt/openssl@3 \
-DPYTHON_EXECUTABLE=$(command -v python3) \
-DPython_EXECUTABLE=$(command -v python3) \
-DENABLE_TESTS=ON \
-DPIP_OPTIONS="--verbose" \
-S xrootd \
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#-------------------------------------------------------------------------------
# Project description
#-------------------------------------------------------------------------------
cmake_minimum_required( VERSION 3.1 )
cmake_minimum_required(VERSION 3.16...3.25)

project( XRootD )

Expand Down
12 changes: 6 additions & 6 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,26 @@ endif()

# Check it the Python interpreter has a valid version of pip
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -m pip --version
COMMAND ${Python_EXECUTABLE} -m pip --version
RESULT_VARIABLE VALID_PIP_EXIT_CODE
OUTPUT_QUIET
)

if ( NOT ${VALID_PIP_EXIT_CODE} EQUAL 0 )
# Attempt to still install with deprecated invocation of setup.py
message(WARNING
" ${PYTHON_EXECUTABLE} does not have a valid pip associated with it."
" ${Python_EXECUTABLE} does not have a valid pip associated with it."
" It is recommended that you install a version of pip to install Python"
" packages and bindings. If you are unable to install a version of pip"
" through a package manager or with your Python build try using the PyPA's"
" get-pip.py bootstrapping script ( https://github.com/pypa/get-pip ).\n"
" The installation of the Python bindings will attempt to continue using"
" the deprecated method of `${PYTHON_EXECUTABLE} setup.py install`."
" the deprecated method of `${Python_EXECUTABLE} setup.py install`."
)

# https://docs.python.org/3/install/#splitting-the-job-up
add_custom_command(OUTPUT ${OUTPUT}
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} --verbose build
COMMAND ${Python_EXECUTABLE} ${SETUP_PY} --verbose build
DEPENDS ${DEPS})

add_custom_target(python_target ALL DEPENDS ${OUTPUT} XrdCl)
Expand All @@ -84,7 +84,7 @@ if ( NOT ${VALID_PIP_EXIT_CODE} EQUAL 0 )
CODE
"EXECUTE_PROCESS(
RESULT_VARIABLE INSTALL_STATUS
COMMAND /usr/bin/env ${XROOTD_PYBUILD_ENV} ${PYTHON_EXECUTABLE} ${SETUP_PY} install \
COMMAND /usr/bin/env ${XROOTD_PYBUILD_ENV} ${Python_EXECUTABLE} ${SETUP_PY} install \
--verbose \
--prefix \$ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX} \
${DEB_INSTALL_ARGS}
Expand All @@ -98,7 +98,7 @@ else()
CODE
"EXECUTE_PROCESS(
RESULT_VARIABLE INSTALL_STATUS
COMMAND /usr/bin/env ${XROOTD_PYBUILD_ENV} ${PYTHON_EXECUTABLE} -m pip install \
COMMAND /usr/bin/env ${XROOTD_PYBUILD_ENV} ${Python_EXECUTABLE} -m pip install \
${PIP_OPTIONS} \
${CMAKE_CURRENT_BINARY_DIR}
)
Expand Down
9 changes: 3 additions & 6 deletions cmake/XRootDFindLibs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,12 @@ endif()

if( ENABLE_PYTHON AND (LINUX OR KFREEBSD OR Hurd OR MacOSX) )
if( FORCE_ENABLED )
find_package( PythonInterp ${XRD_PYTHON_REQ_VERSION} REQUIRED )
find_package( PythonLibs ${XRD_PYTHON_REQ_VERSION} REQUIRED )
find_package( Python ${XRD_PYTHON_REQ_VERSION} COMPONENTS Interpreter Development REQUIRED )
else()
find_package( PythonInterp ${XRD_PYTHON_REQ_VERSION} )
find_package( PythonLibs ${XRD_PYTHON_REQ_VERSION} )
find_package( Python ${XRD_PYTHON_REQ_VERSION} COMPONENTS Interpreter Development )
endif()
if( PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND )
if( Python_Interpreter_FOUND AND Python_Development_FOUND )
set( BUILD_PYTHON TRUE )
set( PYTHON_FOUND TRUE )
else()
set( BUILD_PYTHON FALSE )
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/XRootDSummary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ component_status( TESTS BUILD_TESTS CPPUNIT_FOUND )
component_status( HTTP BUILD_HTTP OPENSSL_FOUND )
component_status( TPC BUILD_TPC CURL_FOUND )
component_status( MACAROONS BUILD_MACAROONS MACAROONS_FOUND )
component_status( PYTHON BUILD_PYTHON PYTHON_FOUND )
component_status( PYTHON BUILD_PYTHON Python_Interpreter_FOUND AND Python_Development_FOUND )
component_status( VOMSXRD BUILD_VOMS VOMS_FOUND )
component_status( XRDEC ENABLE_XRDEC TRUE_VAR )
component_status( MACAROONS BUILD_MACAROONS MACAROONS_FOUND AND JSON_FOUND AND UUID_FOUND )
Expand Down
2 changes: 1 addition & 1 deletion packaging/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export PYBUILD_NAME=xrootd
dh $@ --builddirectory=build --destdir=deb_packages --with python3

override_dh_auto_configure:
dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_LIBDIR=lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH) -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_SKIP_INSTALL_RPATH=ON -DENABLE_XRDCLHTTP=TRUE
dh_auto_configure -- -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_LIBDIR=lib/$(shell dpkg-architecture -qDEB_HOST_MULTIARCH) -DPython_EXECUTABLE=/usr/bin/python3 -DCMAKE_SKIP_INSTALL_RPATH=ON -DENABLE_XRDCLHTTP=TRUE

override_dh_install:
install -D -m 644 packaging/common/client.conf deb_packages/etc/xrootd/client.conf
Expand Down
2 changes: 1 addition & 1 deletion packaging/wheel/TestCXX14.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Test with cmake if the compiler supports all features of C++14
###############################################################################

cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
cmake_minimum_required(VERSION 3.16...3.25 FATAL_ERROR)
project(TestCXX14 CXX)

message("Your C++ compiler supports these C++14 features:")
Expand Down