From b73c21f41bcd55d2d843d20da09cf567b41f61af Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 20 Jun 2024 18:15:04 +0200 Subject: [PATCH] libtorrent-rasterbar: fix build with python3.12 --- .../libtorrent-rasterbar/default.nix | 7 +++++-- .../libtorrent-rasterbar/distutils.patch | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/libraries/libtorrent-rasterbar/distutils.patch diff --git a/pkgs/development/libraries/libtorrent-rasterbar/default.nix b/pkgs/development/libraries/libtorrent-rasterbar/default.nix index 118d143e2cd5..55c284987a9b 100644 --- a/pkgs/development/libraries/libtorrent-rasterbar/default.nix +++ b/pkgs/development/libraries/libtorrent-rasterbar/default.nix @@ -25,10 +25,13 @@ in stdenv.mkDerivation { buildInputs = [ boostPython openssl zlib python ncurses ] ++ lib.optionals stdenv.isDarwin [ SystemConfiguration ]; + patches = [ + # provide distutils alternative for python 3.12 + ./distutils.patch + ]; + # https://github.com/arvidn/libtorrent/issues/6865 postPatch = '' - substituteInPlace cmake/Modules/GeneratePkgConfig.cmake \ - --replace @CMAKE_INSTALL_PREFIX@/'$<'1: '$<'1: substituteInPlace cmake/Modules/GeneratePkgConfig/target-compile-settings.cmake.in \ --replace 'set(_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@")' \ 'set(_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@") diff --git a/pkgs/development/libraries/libtorrent-rasterbar/distutils.patch b/pkgs/development/libraries/libtorrent-rasterbar/distutils.patch new file mode 100644 index 000000000000..57c90b69808c --- /dev/null +++ b/pkgs/development/libraries/libtorrent-rasterbar/distutils.patch @@ -0,0 +1,20 @@ +diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt +index 2f4de4854..a68d547e6 100644 +--- a/bindings/python/CMakeLists.txt ++++ b/bindings/python/CMakeLists.txt +@@ -95,8 +95,13 @@ if (python-install-system-dir) + else() + execute_process( + COMMAND "${Python3_EXECUTABLE}" -c [=[ +-import distutils.sysconfig +-print(distutils.sysconfig.get_python_lib(prefix='', plat_specific=True)) ++try: ++ import distutils.sysconfig ++ print(distutils.sysconfig.get_python_lib(prefix='', plat_specific=True)) ++except ModuleNotFoundError: ++ import os, sys ++ version = f"{sys.version_info.major}.{sys.version_info.minor}" ++ print(os.sep.join(["lib", f"python{version}", "site-packages"])) + ]=] + OUTPUT_VARIABLE _PYTHON3_SITE_ARCH + OUTPUT_STRIP_TRAILING_WHITESPACE