From b56adcaac7159701ba6414df9f9a1dd7953fda1b Mon Sep 17 00:00:00 2001 From: ferres Date: Thu, 25 Jul 2024 19:59:57 +0300 Subject: [PATCH] python311Packages.dm-tree: fix darwin build --- .../dm-tree/0003-don-t-configure-apple.patch | 21 +++ .../python-modules/dm-tree/cmake.patch | 141 ------------------ .../python-modules/dm-tree/default.nix | 20 ++- 3 files changed, 38 insertions(+), 144 deletions(-) create mode 100644 pkgs/development/python-modules/dm-tree/0003-don-t-configure-apple.patch delete mode 100644 pkgs/development/python-modules/dm-tree/cmake.patch diff --git a/pkgs/development/python-modules/dm-tree/0003-don-t-configure-apple.patch b/pkgs/development/python-modules/dm-tree/0003-don-t-configure-apple.patch new file mode 100644 index 000000000000..ac51e3bd50d1 --- /dev/null +++ b/pkgs/development/python-modules/dm-tree/0003-don-t-configure-apple.patch @@ -0,0 +1,21 @@ +diff --git a/tree/CMakeLists.txt b/tree/CMakeLists.txt +index 4fd1b1a..2d1d9d3 100644 +--- a/tree/CMakeLists.txt ++++ b/tree/CMakeLists.txt +@@ -40,16 +40,6 @@ if (NOT (WIN32 OR MSVC)) + endif() + endif() + +-if(APPLE) +- # On MacOS: +- # -undefined dynamic_lookup is necessary for pybind11 linking +- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-everything -w -undefined dynamic_lookup") +- +- # On MacOS, we need this so that CMake will use the right Python if the user +- # has a virtual environment active +- set (CMAKE_FIND_FRAMEWORK LAST) +-endif() +- + # Fetch pybind to be able to use pybind11_add_module symbol. + set(PYBIND_VER v2.10.1) + include(FetchContent) diff --git a/pkgs/development/python-modules/dm-tree/cmake.patch b/pkgs/development/python-modules/dm-tree/cmake.patch deleted file mode 100644 index 28f201a30f71..000000000000 --- a/pkgs/development/python-modules/dm-tree/cmake.patch +++ /dev/null @@ -1,141 +0,0 @@ -diff --git a/tree/CMakeLists.txt b/tree/CMakeLists.txt -index 4fd1b1a..f0d072b 100644 ---- a/tree/CMakeLists.txt -+++ b/tree/CMakeLists.txt -@@ -50,70 +50,79 @@ if(APPLE) - set (CMAKE_FIND_FRAMEWORK LAST) - endif() - --# Fetch pybind to be able to use pybind11_add_module symbol. --set(PYBIND_VER v2.10.1) --include(FetchContent) --FetchContent_Declare( -- pybind11 -- GIT_REPOSITORY https://github.com/pybind/pybind11 -- GIT_TAG ${PYBIND_VER} --) --if(NOT pybind11_POPULATED) -- FetchContent_Populate(pybind11) -- add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR}) -- include_directories(${pybind11_INCLUDE_DIR}) --endif() -- --# Needed to disable Abseil tests. --set (BUILD_TESTING OFF) -- --# Include abseil-cpp. --set(ABSEIL_VER 20210324.2) --include(ExternalProject) --set(ABSEIL_CMAKE_ARGS -- "-DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/abseil-cpp" -- "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" -- "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" -- "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" -- "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" -- "-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}" -- "-DLIBRARY_OUTPUT_PATH=${CMAKE_SOURCE_DIR}/abseil-cpp/lib") --if(DEFINED CMAKE_OSX_ARCHITECTURES) -- set(ABSEIL_CMAKE_ARGS -- ${ABSEIL_CMAKE_ARGS} -- "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}") -+find_package(pybind11 CONFIG) -+ -+if (NOT pybind11_FOUND) -+ # Fetch pybind to be able to use pybind11_add_module symbol. -+ set(PYBIND_VER v2.10.1) -+ include(FetchContent) -+ FetchContent_Declare( -+ pybind11 -+ GIT_REPOSITORY https://github.com/pybind/pybind11 -+ GIT_TAG ${PYBIND_VER} -+ ) -+ if(NOT pybind11_POPULATED) -+ FetchContent_Populate(pybind11) -+ add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR}) -+ include_directories(${pybind11_INCLUDE_DIR}) -+ endif() - endif() --ExternalProject_Add(abseil-cpp -- GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git -- GIT_TAG ${ABSEIL_VER} -- PREFIX ${CMAKE_SOURCE_DIR}/abseil-cpp -- CMAKE_ARGS ${ABSEIL_CMAKE_ARGS} --) --ExternalProject_Get_Property(abseil-cpp install_dir) --set(abseil_install_dir ${install_dir}) --include_directories (${abseil_install_dir}/include) -- - - # Define pybind11 tree module. - pybind11_add_module(_tree tree.h tree.cc) --add_dependencies(_tree abseil-cpp) -- -+find_package(absl) -+ -+if (NOT absl_FOUND) -+ # Needed to disable Abseil tests. -+ set (BUILD_TESTING OFF) -+ -+ # Include abseil-cpp. -+ set(ABSEIL_VER 20210324.2) -+ include(ExternalProject) -+ set(ABSEIL_CMAKE_ARGS -+ "-DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/abseil-cpp" -+ "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" -+ "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" -+ "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" -+ "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" -+ "-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}" -+ "-DLIBRARY_OUTPUT_PATH=${CMAKE_SOURCE_DIR}/abseil-cpp/lib") -+ if(DEFINED CMAKE_OSX_ARCHITECTURES) -+ set(ABSEIL_CMAKE_ARGS -+ ${ABSEIL_CMAKE_ARGS} -+ "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}") -+ endif() -+ ExternalProject_Add(abseil-cpp -+ GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git -+ GIT_TAG ${ABSEIL_VER} -+ PREFIX ${CMAKE_SOURCE_DIR}/abseil-cpp -+ CMAKE_ARGS ${ABSEIL_CMAKE_ARGS} -+ ) -+ ExternalProject_Get_Property(abseil-cpp install_dir) -+ set(abseil_install_dir ${install_dir}) -+ include_directories (${abseil_install_dir}/include) -+ -+ add_dependencies(_tree abseil-cpp) -+ -+ if (WIN32 OR MSVC) -+ set(ABSEIL_LIB_PREF "absl") -+ set(LIB_SUFF "lib") -+ else() -+ set(ABSEIL_LIB_PREF "libabsl") -+ set(LIB_SUFF "a") -+ endif() -+ --if (WIN32 OR MSVC) -- set(ABSEIL_LIB_PREF "absl") -- set(LIB_SUFF "lib") -+ # Link abseil static libs. -+ # We don't use find_library here to force cmake to build abseil before linking. -+ set(ABSEIL_LIBS int128 raw_hash_set raw_logging_internal strings throw_delegate) -+ foreach(ABSEIL_LIB IN LISTS ABSEIL_LIBS) -+ target_link_libraries(_tree PRIVATE -+ "${abseil_install_dir}/lib/${ABSEIL_LIB_PREF}_${ABSEIL_LIB}.${LIB_SUFF}") -+ endforeach() - else() -- set(ABSEIL_LIB_PREF "libabsl") -- set(LIB_SUFF "a") -+ target_link_libraries(_tree PRIVATE absl::int128 absl::raw_hash_set absl::raw_logging_internal absl::strings absl::throw_delegate) - endif() - --# Link abseil static libs. --# We don't use find_library here to force cmake to build abseil before linking. --set(ABSEIL_LIBS int128 raw_hash_set raw_logging_internal strings throw_delegate) --foreach(ABSEIL_LIB IN LISTS ABSEIL_LIBS) -- target_link_libraries(_tree PRIVATE -- "${abseil_install_dir}/lib/${ABSEIL_LIB_PREF}_${ABSEIL_LIB}.${LIB_SUFF}") --endforeach() -- - # Make the module private to tree package. - set_target_properties(_tree PROPERTIES OUTPUT_NAME tree/_tree) - diff --git a/pkgs/development/python-modules/dm-tree/default.nix b/pkgs/development/python-modules/dm-tree/default.nix index 0cf64bc5da02..b7e1a7c3660a 100644 --- a/pkgs/development/python-modules/dm-tree/default.nix +++ b/pkgs/development/python-modules/dm-tree/default.nix @@ -5,13 +5,25 @@ attrs, buildPythonPackage, cmake, + fetchpatch, fetchFromGitHub, lib, numpy, pybind11, wrapt, }: - +let + patchCMakeAbseil = fetchpatch { + name = "0001-don-t-rebuild-abseil.patch"; + url = "https://raw.githubusercontent.com/conda-forge/dm-tree-feedstock/93a91aa2c13240cecf88133e2885ade9121b464a/recipe/patches/0001-don-t-rebuild-abseil.patch"; + hash = "sha256-mCnyAaHBCZJBogGfl0Hx+hocmtFg13RAIUbEy93z2CE="; + }; + patchCMakePybind = fetchpatch { + name = "0002-don-t-fetch-pybind11.patch"; + url = "https://raw.githubusercontent.com/conda-forge/dm-tree-feedstock/93a91aa2c13240cecf88133e2885ade9121b464a/recipe/patches/0002-don-t-fetch-pybind11.patch"; + hash = "sha256-zGgeAhIMHA238vESWb+44s9p0QjQxnpgMAGv88uYGMU="; + }; +in buildPythonPackage rec { pname = "dm-tree"; version = "0.1.8"; @@ -24,7 +36,10 @@ buildPythonPackage rec { hash = "sha256-VvSJTuEYjIz/4TTibSLkbg65YmcYqHImTHOomeorMJc="; }; - patches = [ ./cmake.patch ]; + patches = [ + patchCMakeAbseil + patchCMakePybind + ] ++ (lib.optional stdenv.isDarwin ./0003-don-t-configure-apple.patch); dontUseCmakeConfigure = true; @@ -48,7 +63,6 @@ buildPythonPackage rec { pythonImportsCheck = [ "tree" ]; meta = with lib; { - broken = stdenv.isDarwin; description = "Tree is a library for working with nested data structures"; homepage = "https://github.com/deepmind/tree"; license = licenses.asl20;