projects/guix·blob ruby-team · refs

101 lines · 3.6 KiB

1From 7501e5f980854996a9f411642f619fda806e6420 Mon Sep 17 00:00:00 2001
2From: Jean-Baptiste Note <[email protected]>
3Date: Tue, 23 Sep 2025 09:33:13 +0200
4Subject: [PATCH] [python] Guix support patch.
5
6* Remove bundled library in python wrapper.
7
8* Make library lookup consistent with something that can easily be
9patched for guix.
10---
11 py-interface/CMakeLists.txt | 7 +------
12 py-interface/amdsmi_wrapper.py | 2 ++
13 py-interface/pyproject.toml.in | 4 ----
14 py-interface/setup.py.in | 4 ----
15 tools/generator.py | 2 ++
16 5 files changed, 5 insertions(+), 14 deletions(-)
17
18diff --git a/py-interface/CMakeLists.txt b/py-interface/CMakeLists.txt
19index 6aaa5056..4bc0150e 100644
20--- a/py-interface/CMakeLists.txt
21+++ b/py-interface/CMakeLists.txt
22@@ -80,10 +80,6 @@ add_custom_command(
23 COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${PY_PACKAGE_DIR}/
24 COMMAND ln -Pf ${PROJECT_SOURCE_DIR}/LICENSE ${PY_PACKAGE_DIR}/)
25
26-# copy libamd_smi.so to allow for a self-contained python package
27-add_custom_command(OUTPUT ${PY_PACKAGE_DIR}/libamd_smi.so DEPENDS ${PROJECT_BINARY_DIR}/src/libamd_smi.so
28- COMMAND cp "${PROJECT_BINARY_DIR}/src/libamd_smi.so" ${PY_PACKAGE_DIR}/)
29-
30 add_custom_target(
31 python_package ALL
32 DEPENDS ${PY_BUILD_DIR}/pyproject.toml
33@@ -93,8 +89,7 @@ add_custom_target(
34 ${PY_PACKAGE_DIR}/amdsmi_exception.py
35 ${PY_PACKAGE_DIR}/amdsmi_interface.py
36 ${PY_PACKAGE_DIR}/README.md
37- ${PY_PACKAGE_DIR}/LICENSE
38- ${PY_PACKAGE_DIR}/libamd_smi.so)
39+ ${PY_PACKAGE_DIR}/LICENSE)
40
41 install(
42 FILES ${CMAKE_CURRENT_BINARY_DIR}/${PY_BUILD_DIR}/pyproject.toml
43diff --git a/py-interface/amdsmi_wrapper.py b/py-interface/amdsmi_wrapper.py
44index b52d7fa3..f19fbc73 100644
45--- a/py-interface/amdsmi_wrapper.py
46+++ b/py-interface/amdsmi_wrapper.py
47@@ -183,6 +183,8 @@ def find_smi_library():
48 rocm_path = os.getenv("ROCM_HOME", os.getenv("ROCM_PATH"))
49 if rocm_path:
50 possible_locations.append(os.path.join(rocm_path, "lib/libamd_smi.so"))
51+ if os.path.exists("/opt/rocm/lib/libamd_smi.so"):
52+ possible_locations.append("/opt/rocm/lib/libamd_smi.so")
53 # 2.
54 possible_locations.append("libamd_smi.so")
55 # 3.
56diff --git a/py-interface/pyproject.toml.in b/py-interface/pyproject.toml.in
57index 38dc13f1..c80a76df 100644
58--- a/py-interface/pyproject.toml.in
59+++ b/py-interface/pyproject.toml.in
60@@ -24,10 +24,6 @@ classifiers = [
61 [tool.setuptools]
62 packages = ["amdsmi"]
63 zip-safe = false
64-include-package-data = true
65-
66-[tool.setuptools.package-data]
67-amdsmi = ["*.so"]
68
69 [tool.pytest.ini_options]
70 pythonpath = "/opt/rocm/share/amd_smi"
71diff --git a/py-interface/setup.py.in b/py-interface/setup.py.in
72index dbd98e2b..8d5f283d 100644
73--- a/py-interface/setup.py.in
74+++ b/py-interface/setup.py.in
75@@ -13,10 +13,6 @@ setup(
76 "Programming Language :: Python :: 3",
77 ],
78 python_requires=">=3.6",
79- include_package_data=True,
80- package_data={
81- '': ['*.so'],
82- },
83 zip_safe=False,
84 license='amdsmi/LICENSE',
85 )
86diff --git a/tools/generator.py b/tools/generator.py
87index 2882f494..24454bca 100644
88--- a/tools/generator.py
89+++ b/tools/generator.py
90@@ -198,6 +198,8 @@ def find_smi_library():
91 rocm_path = os.getenv("ROCM_HOME", os.getenv("ROCM_PATH"))
92 if rocm_path:
93 possible_locations.append(os.path.join(rocm_path, "lib/{library_name}"))
94+ if os.path.exists("/opt/rocm/lib/{library_name}"):
95+ possible_locations.append("/opt/rocm/lib/{library_name}")
96 # 2.
97 possible_locations.append("{library_name}")
98 # 3.
99--
1002.51.0
101