Skip to content

Commit 8ef6453

Browse files
LuLu
authored andcommitted
set rpath for libdeepmd_op_cuda.so
1 parent 7c34c58 commit 8ef6453

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "scikit-build", "cmake", "ninja", "m2r"]
2+
requires = ["setuptools", "setuptools_scm", "wheel", "scikit-build", "cmake", "ninja", "m2r"]
33

setup.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
from skbuild import setup
22
from skbuild.exceptions import SKBuildError
33
from skbuild.cmaker import get_cmake_version
4+
from setuptools_scm import get_version
45
from packaging.version import LegacyVersion
56
from os import path, makedirs
6-
import imp
7+
import imp, sys, platform
8+
9+
def get_dp_install_path() :
10+
site_packages_path = path.join(path.dirname(path.__file__), 'site-packages')
11+
dp_scm_version = get_version(root="./", relative_to=__file__)
12+
python_version = 'py' + str(sys.version_info.major + sys.version_info.minor * 0.1)
13+
os_info = sys.platform
14+
machine_info = platform.machine()
15+
dp_install_path = site_packages_path + '/deepmd_kit-' + dp_scm_version + '-' + python_version + '-' + os_info + '-' + machine_info + '.egg/deepmd'
16+
17+
return dp_install_path
718

819
readme_file = path.join(path.dirname(path.abspath(__file__)), 'README.md')
920
try:
@@ -34,6 +45,8 @@
3445
except OSError:
3546
pass
3647

48+
dp_install_path = get_dp_install_path()
49+
3750
setup(
3851
name="deepmd-kit",
3952
setup_requires=setup_requires,
@@ -56,6 +69,7 @@
5669
'-DBUILD_PY_IF:BOOL=TRUE',
5770
'-DBUILD_CPP_IF:BOOL=FALSE',
5871
'-DFLOAT_PREC:STRING=high',
72+
'-DDP_INSTALL_PATH=%s' % dp_install_path,
5973
],
6074
cmake_source_dir='source',
6175
cmake_minimum_required_version='3.0',

source/op/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif (BUILD_CPP_IF)
2525

2626
if (BUILD_PY_IF)
2727
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
28-
set(CMAKE_INSTALL_RPATH DESTINATION ${CMAKE_BINARY_DIR}/op/cuda)
28+
set(CMAKE_INSTALL_RPATH DESTINATION ${DP_INSTALL_PATH})
2929
if (USE_CUDA_TOOLKIT)
3030
add_library(op_abi SHARED ${OP_PY_CUDA_SRC} ${OP_LIB})
3131
add_library(op_grads SHARED ${OP_GRADS_SRC})

0 commit comments

Comments
 (0)