Skip to content

Commit

Permalink
Eliminate Python version check now that the minimum version is Python…
Browse files Browse the repository at this point in the history
…3 and other clean up

Signed-off-by: Dan Bailey <[email protected]>
  • Loading branch information
danrbailey committed Oct 29, 2024
1 parent 60a9314 commit d855b3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 55 deletions.
61 changes: 8 additions & 53 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -453,62 +453,17 @@ endif()

# Locate Python and nanobind if necessary
if(OPENVDB_BUILD_PYTHON_MODULE OR (OPENVDB_BUILD_NANOVDB AND NANOVDB_BUILD_PYTHON_MODULE))
# Small function which mimics basic output (bar components) of
# FindPackageHandleStandardArgs. This is required as we want to ensure
# the minimum python version is MINIMUM_PYTHON_VERSION - however this cannot
# be provided to find_package(Python) with differing major versions. e.g.
# calls to find_package(Python 2.7) fails if python3 is found on the system.
function(OPENVDB_CHECK_PYTHON_VERSION)
set(PY_TARGET ${ARGV0})
set(PY_TARGET_VERSION ${ARGV1})
set(PY_TARGET_INCLUDES ${ARGV2})
set(MIN_VERSION ${ARGV3})
set(FUTURE_MIN_VERSION ${ARGV4})

if(NOT TARGET ${PY_TARGET})
message(FATAL_ERROR "Could NOT find ${PY_TARGET} (Required is at least version "
"\"${MIN_VERSION}\")"
)
endif()

if(PY_TARGET_VERSION AND MIN_VERSION)
if(PY_TARGET_VERSION VERSION_LESS MIN_VERSION)
message(FATAL_ERROR "Could NOT find ${PY_TARGET}: Found unsuitable version "
"\"${PY_TARGET_VERSION}\" but required is at least \"${MIN_VERSION}\" (found ${PY_TARGET_INCLUDES})"
)
endif()
endif()

message(STATUS "Found ${PY_TARGET}: ${PY_TARGET_INCLUDES}) (found suitable "
"version \"${PY_TARGET_VERSION}\", minimum required is \"${MIN_VERSION}\")"
)

if(OPENVDB_FUTURE_DEPRECATION AND PY_TARGET_VERSION AND FUTURE_MIN_VERSION)
if(PY_TARGET_VERSION VERSION_LESS FUTURE_MIN_VERSION)
message(DEPRECATION "Support for ${PY_TARGET} versions < ${FUTURE_MIN_VERSION} "
"is deprecated and will be removed.")
endif()
endif()
endfunction()

# Configure Python and Numpy.
# To ensure consistent versions between components Interpreter, Compiler,
# Development and NumPy, specify all components at the same time when using
# FindPython.

# @note explicitly only search for Development.Module from 3.18 as searching
# Development.Embed can cause issues on linux systems where it doesn't exist
set(OPENVDB_PYTHON_REQUIRED_COMPONENTS Development Interpreter)

# Make sure find_package(Python) is only ever invoked once with all required components
find_package(Python 3.8 REQUIRED COMPONENTS ${OPENVDB_PYTHON_REQUIRED_COMPONENTS})
# Call find_package(Python ...)
find_package(Python 3.8 REQUIRED COMPONENTS Development Interpreter)
find_package(nanobind REQUIRED)

openvdb_check_python_version(Python::Module
"${Python_VERSION}"
"${Python_INCLUDE_DIRS}"
"${MINIMUM_PYTHON_VERSION}"
"${FUTURE_MINIMUM_PYTHON_VERSION}")
if(OPENVDB_FUTURE_DEPRECATION AND FUTURE_MINIMUM_PYTHON_VERSION)
if(Python_VERSION VERSION_LESS ${FUTURE_MINIMUM_PYTHON_VERSION})
message(DEPRECATION "Support for Python versions < ${FUTURE_MINIMUM_GLFW_VERSION} "
"is deprecated and will be removed.")
endif()
endif()

if(NOT DEFINED VDB_PYTHON_INSTALL_DIRECTORY)
get_filename_component(Python_PACKAGES_DIR ${Python_SITELIB} NAME)
Expand Down
2 changes: 0 additions & 2 deletions cmake/FindOpenVDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,8 @@ set(_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})

set(OPENVDB_PYTHON_PATH_SUFFIXES
lib64/python
lib64/python2.7
lib64/python3
lib/python
lib/python2.7
lib/python3
)

Expand Down

0 comments on commit d855b3f

Please sign in to comment.