Skip to content

Commit 374e622

Browse files
nsmith-anigamova
authored andcommitted
Improve CMakeList for use with conda packaging
Basically allow to manually specify Python_SITELIB and don't mess with the path discovery for ROOT
1 parent 77caed0 commit 374e622

File tree

3 files changed

+15
-28
lines changed

3 files changed

+15
-28
lines changed

CMakeLists.txt

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ option( INSTALL_PYTHON "Install the Python library and scripts" TRUE )
1212
# cmake path/to/source # change this path to where-ever you cloned Combine repo to
1313
# make -j4
1414

15-
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
1615
find_package(ROOT REQUIRED COMPONENTS MathMore RooFitCore RooFit RooStats HistFactory)
1716
find_package(Eigen3 REQUIRED)
1817
find_package(Vdt)
@@ -47,11 +46,6 @@ target_link_libraries (${LIBNAME} Eigen3::Eigen ${ROOT_LIBRARIES} ${Boost_LIBRAR
4746
add_executable(combine bin/combine.cpp)
4847
target_link_libraries(combine PUBLIC ${LIBNAME})
4948

50-
51-
# Create empty __init__.py file in the build directory that will be installed
52-
# in the Python library directories.
53-
set(empty_init_py "${CMAKE_CURRENT_BINARY_DIR}/__init__.py")
54-
5549
if(MODIFY_ROOTMAP)
5650
# edit the generated rootmap in-situ before installation
5751

@@ -104,36 +98,29 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/HiggsAnalysis/CombinedLimit/src/classe
10498
# Install the "combine" executable in the bin directory.
10599
install(TARGETS combine DESTINATION bin)
106100

107-
# This block is commented out for now, while using the less sophisticated location below
108-
# Check if the Python library installation directory is outside the install
109-
# prefix. If it is, we error out because CMake should not install files outside
110-
# the prefix. In the future, one can imagine to let the user choose where the
111-
# Python libraries get installed in the prefix with a CMake configuration flag.
112-
#find_package(Python COMPONENTS Interpreter Development) # To get the Python library install directory into Python_SITELIB
113-
#cmake_path(IS_PREFIX CMAKE_INSTALL_PREFIX "${Python_SITELIB}" sitelib_in_prefix)
114-
#if(NOT ${sitelib_in_prefix})
115-
# message( FATAL_ERROR "Your Python library installation directory ${Python_SITELIB} "
116-
# "is outside the install prefix ${CMAKE_INSTALL_PREFIX}! "
117-
# "This is not supported for now. Consider changing the install prefix "
118-
# "with the -DCMAKE_INSTALL_PREFIX:PATH=<path> cmake configuration option.")
119-
#endif()
120-
#
121-
## The the Python library installation directory relative to the install prefix.
122-
#file(RELATIVE_PATH Python_SITELIB_IN_PREFIX ${CMAKE_INSTALL_PREFIX} ${Python_SITELIB})
123101

124102
if(INSTALL_PYTHON)
125-
# Install the scripts like "text2workspace" to the bin directory.
126-
install(DIRECTORY scripts/ DESTINATION bin)
103+
# In conda-forge cross-compiling builds we hardcode Python_SITELIB because
104+
# find_package does not ever find the right version, unfortunately.
105+
# In any other environment, find_package should work fine
106+
if(NOT DEFINED Python_SITELIB)
107+
find_package(Python REQUIRED COMPONENTS Interpreter)
108+
endif()
109+
110+
# The the Python library installation directory relative to the install prefix.
111+
file(RELATIVE_PATH Python_SITELIB_IN_PREFIX ${CMAKE_INSTALL_PREFIX} ${Python_SITELIB})
112+
message (STATUS "Using Python install location:" ${Python_SITELIB_IN_PREFIX})
127113

128-
set(Python_SITELIB_IN_PREFIX "python")
114+
# Install the scripts like "text2workspace.py" to the bin directory.
115+
install(DIRECTORY scripts/ DESTINATION bin USE_SOURCE_PERMISSIONS)
129116

130-
message (STATUS "Using Python install location:" ${Python_SITELIB_IN_PREFIX})
131117
# The python package will be installed in such a way that the original
132118
# CMSSW-style directory structure is kept, for maximal compatibility.
133119
install(DIRECTORY python/ DESTINATION ${Python_SITELIB_IN_PREFIX}/HiggsAnalysis/CombinedLimit)
134120

135-
# Create empty __init__.py files in the Python package subdirectories such that
136-
# the Python imports work.
121+
# Create empty __init__.py file in the build directory that will be installed
122+
# in the Python library directories.
123+
set(empty_init_py "${CMAKE_CURRENT_BINARY_DIR}/__init__.py")
137124
file(TOUCH ${empty_init_py})
138125
INSTALL(FILES ${empty_init_py} DESTINATION ${Python_SITELIB_IN_PREFIX}/HiggsAnalysis)
139126
INSTALL(FILES ${empty_init_py} DESTINATION ${Python_SITELIB_IN_PREFIX}/HiggsAnalysis/CombinedLimit)

scripts/plotBSMxsBRLimit.py

100644100755
File mode changed.

scripts/pruneUncerts.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)