commit:     72df8ef8dc56f868d4feaf7b558e93562b7627f3
Author:     Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 11 13:41:24 2020 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Tue Aug 11 13:44:16 2020 +0000
URL:        https://gitweb.gentoo.org/proj/sci.git/commit/?id=72df8ef8

sci-libs/pytorch: donot hardcode the library path.

Closes: https://bugs.gentoo.org/736643
Package-Manager: Portage-2.3.88, Repoman-2.3.18
Signed-off-by: Benda Xu <heroxbd <AT> gentoo.org>

 sci-libs/pytorch/files/pytorch-1.6.0-global-dlopen.patch | 15 +++++++++++++++
 sci-libs/pytorch/pytorch-1.6.0.ebuild                    |  3 ++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/sci-libs/pytorch/files/pytorch-1.6.0-global-dlopen.patch 
b/sci-libs/pytorch/files/pytorch-1.6.0-global-dlopen.patch
new file mode 100644
index 000000000..1e9388ff1
--- /dev/null
+++ b/sci-libs/pytorch/files/pytorch-1.6.0-global-dlopen.patch
@@ -0,0 +1,15 @@
+Don't hardcode the library path. Leave it to the dynamic loader.
+
+Index: pytorch-1.6.0/torch/__init__.py
+===================================================================
+--- pytorch-1.6.0.orig/torch/__init__.py
++++ pytorch-1.6.0/torch/__init__.py
+@@ -138,7 +138,7 @@ def _load_global_deps():
+     here = os.path.abspath(__file__)
+     lib_path = os.path.join(os.path.dirname(here), 'lib', lib_name)
+ 
+-    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
++    ctypes.CDLL(lib_name, mode=ctypes.RTLD_GLOBAL)
+ 
+ 
+ if (USE_RTLD_GLOBAL_WITH_LIBTORCH or os.getenv('TORCH_USE_RTLD_GLOBAL')) and \

diff --git a/sci-libs/pytorch/pytorch-1.6.0.ebuild 
b/sci-libs/pytorch/pytorch-1.6.0.ebuild
index 1394bdbe3..8c3236244 100644
--- a/sci-libs/pytorch/pytorch-1.6.0.ebuild
+++ b/sci-libs/pytorch/pytorch-1.6.0.ebuild
@@ -110,6 +110,7 @@ DEPEND="${RDEPEND}
 PATCHES=(
        "${FILESDIR}"/${PN}-1.6.0-setup.patch
        "${FILESDIR}"/${PN}-1.6.0-skip-tests.patch
+       "${FILESDIR}"/${PN}-pytorch-1.6.0-global-dlopen.patch
        "${FILESDIR}"/0002-Don-t-build-libtorch-again-for-PyTorch-1.4.0.patch
        
"${FILESDIR}"/0003-Change-path-to-caffe2-build-dir-made-by-libtorch.patch
        
"${FILESDIR}"/0005-Change-library-directory-according-to-CMake-build.patch
@@ -272,7 +273,7 @@ src_install() {
                python_foreach_impl python_optimize
        fi
 
-       find "${ED}/usr/lib64" -name "*.a" -exec rm -fv {} \;
+       find "${ED}/usr/${LIB}" -name "*.a" -exec rm -fv {} \;
 
        use test && rm -rfv "${ED}/usr/test" "${ED}"/usr/bin/test_{api,jit}
 

Reply via email to