2
0

Improve python wrapper generation

- Add "BUILD_PACKAGE" option that is OFF by default (CI issues)

- Optionally package wrapper if python3.7 or above is present (hack for CI)
- Optionally build wrapper if clang is present (hack for CI)
- Improve dependency resolution for wrapper
- Use python venv
- Use pyproject.toml instead of setup.py
- Use CMake install path to search for libamd_smi.so
- Move python-specific CMakeLists into py-interface
- Search for libamd_smi.so more aggressively

Change-Id: Ie7dad676b0d4a5f58ad2b887db7fecf5b1297e3b
Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
Este cometimento está contido em:
Galantsev, Dmitrii
2023-03-10 13:45:51 -06:00
ascendente 3af2687f17
cometimento 74479187d0
7 ficheiros modificados com 252 adições e 82 eliminações
+11 -2
Ver ficheiro
@@ -106,8 +106,17 @@ def main():
arguments = [input_file, "-o", output_file, "-l", library]
library_path = os.path.join(os.path.dirname(__file__), library)
line_to_replace = "_libraries['{}'] = ctypes.CDLL('{}')".format(library_name, library_path)
new_line = "_libraries['{}'] = ctypes.CDLL(os.path.join(os.path.dirname(__file__), '{}'))" \
.format(library_name, library_name)
new_line = """
if os.path.isfile('@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/{0}'):
# try to find library in install directory provided by CMake
_libraries['{0}'] = ctypes.CDLL(os.path.join('@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@', '{0}'))
elif os.path.isfile('/opt/rocm/lib/{0}'):
# try /opt/rocm/lib as a fallback
_libraries['{0}'] = ctypes.CDLL(os.path.join('/opt/rocm/lib', '{0}'))
else:
# lastly - search in current directory
_libraries['{0}'] = ctypes.CDLL(os.path.join(os.path.dirname(__file__), '{0}'))
""".format(library_name)
else:
print("Unknown operating system. It is only supporing Linux and Windows.")
return