Merge pull request #320888 from SomeoneSerge/fix/triton-ldconfig

python311Packages.openai-triton: prevent from running ldconfig (one more way)
This commit is contained in:
Someone 2024-06-26 23:08:19 +00:00 committed by GitHub
commit 2130a88478
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,10 +1,10 @@
{
lib,
config,
addDriverRunpath,
buildPythonPackage,
fetchFromGitHub,
fetchpatch,
addOpenGLRunpath,
setuptools,
pytestCheckHook,
pythonRelaxDepsHook,
@ -57,6 +57,52 @@ buildPythonPackage rec {
./0001-ptxas-disable-version-key-for-non-cuda-targets.patch
];
postPatch =
let
quote = x: ''"${x}"'';
subs.ldFlags =
let
# Bash was getting weird without linting,
# but basically upstream contains [cc, ..., "-lcuda", ...]
# and we replace it with [..., "-lcuda", "-L/run/opengl-driver/lib", "-L$stubs", ...]
old = [ "-lcuda" ];
new = [
"-lcuda"
"-L${addDriverRunpath.driverLink}"
"-L${cudaPackages.cuda_cudart}/lib/stubs/"
];
in
{
oldStr = lib.concatMapStringsSep ", " quote old;
newStr = lib.concatMapStringsSep ", " quote new;
};
in
''
# Use our `cmakeFlags` instead and avoid downloading dependencies
substituteInPlace python/setup.py \
--replace "= get_thirdparty_packages(triton_cache_path)" "= os.environ[\"cmakeFlags\"].split()"
# Already defined in llvm, when built with -DLLVM_INSTALL_UTILS
substituteInPlace bin/CMakeLists.txt \
--replace "add_subdirectory(FileCheck)" ""
# Don't fetch googletest
substituteInPlace unittest/CMakeLists.txt \
--replace "include (\''${CMAKE_CURRENT_SOURCE_DIR}/googletest.cmake)" ""\
--replace "include(GoogleTest)" "find_package(GTest REQUIRED)"
cat << \EOF > python/triton/common/build.py
def libcuda_dirs():
return [ "${addDriverRunpath.driverLink}/lib" ]
EOF
''
+ lib.optionalString cudaSupport ''
# Use our linker flags
substituteInPlace python/triton/common/build.py \
--replace '${subs.ldFlags.oldStr}' '${subs.ldFlags.newStr}'
'';
nativeBuildInputs = [
setuptools
pythonRelaxDepsHook
@ -87,42 +133,6 @@ buildPythonPackage rec {
setuptools
];
postPatch =
let
# Bash was getting weird without linting,
# but basically upstream contains [cc, ..., "-lcuda", ...]
# and we replace it with [..., "-lcuda", "-L/run/opengl-driver/lib", "-L$stubs", ...]
old = [ "-lcuda" ];
new = [
"-lcuda"
"-L${addOpenGLRunpath.driverLink}"
"-L${cudaPackages.cuda_cudart}/lib/stubs/"
];
quote = x: ''"${x}"'';
oldStr = lib.concatMapStringsSep ", " quote old;
newStr = lib.concatMapStringsSep ", " quote new;
in
''
# Use our `cmakeFlags` instead and avoid downloading dependencies
substituteInPlace python/setup.py \
--replace "= get_thirdparty_packages(triton_cache_path)" "= os.environ[\"cmakeFlags\"].split()"
# Already defined in llvm, when built with -DLLVM_INSTALL_UTILS
substituteInPlace bin/CMakeLists.txt \
--replace "add_subdirectory(FileCheck)" ""
# Don't fetch googletest
substituteInPlace unittest/CMakeLists.txt \
--replace "include (\''${CMAKE_CURRENT_SOURCE_DIR}/googletest.cmake)" ""\
--replace "include(GoogleTest)" "find_package(GTest REQUIRED)"
''
+ lib.optionalString cudaSupport ''
# Use our linker flags
substituteInPlace python/triton/common/build.py \
--replace '${oldStr}' '${newStr}'
'';
# Avoid GLIBCXX mismatch with other cuda-enabled python packages
preConfigure =
''