| 1 | From 7501e5f980854996a9f411642f619fda806e6420 Mon Sep 17 00:00:00 2001
|
| 2 | From: Jean-Baptiste Note <[email protected]>
|
| 3 | Date: Tue, 23 Sep 2025 09:33:13 +0200
|
| 4 | Subject: [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
|
| 9 | patched 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 |
|
| 18 | diff --git a/py-interface/CMakeLists.txt b/py-interface/CMakeLists.txt
|
| 19 | index 6aaa5056..4bc0150e 100644
|
| 20 | |
| 21 | |
| 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
|
| 43 | diff --git a/py-interface/amdsmi_wrapper.py b/py-interface/amdsmi_wrapper.py
|
| 44 | index b52d7fa3..f19fbc73 100644
|
| 45 | |
| 46 | |
| 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.
|
| 56 | diff --git a/py-interface/pyproject.toml.in b/py-interface/pyproject.toml.in
|
| 57 | index 38dc13f1..c80a76df 100644
|
| 58 | |
| 59 | |
| 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"
|
| 71 | diff --git a/py-interface/setup.py.in b/py-interface/setup.py.in
|
| 72 | index dbd98e2b..8d5f283d 100644
|
| 73 | |
| 74 | |
| 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 | )
|
| 86 | diff --git a/tools/generator.py b/tools/generator.py
|
| 87 | index 2882f494..24454bca 100644
|
| 88 | |
| 89 | |
| 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 | --
|
| 100 | 2.51.0
|
| 101 |
|