-
Notifications
You must be signed in to change notification settings - Fork 39
Labels
bugSomething isn't workingSomething isn't working
Description
Current path finding for libtvm_ffi.so and libtvm_ffi_testing.so heavily depends on hardcoded paths. More concretely, assuming build/lib as part of the path for editable development.
tvm-ffi/python/tvm_ffi/libinfo.py
Lines 55 to 58 in 53a7fe9
| dll_path: list[Path] = [ffi_dir / "lib"] | |
| dll_path.append(ffi_dir / ".." / ".." / "build" / "lib") | |
| # in source build from parent if needed | |
| dll_path.append(ffi_dir / ".." / ".." / ".." / "build" / "lib") |
However, this is not an optimal strategy for editable builds, because:
- build directory could be different than
build/, e.g.build-release,build/release, etc. - the actual
.sofiles are actually installed into Python'ssite-packagesdirectory byscikit-build-core. The.sofiles can get outdated or mismatch insidebuild/
Let's switch to a more standard practice in this case for both apache-tvm-ffi and the example extension in my_ffi_extension under examples/packaging, by using the snippet below:
import importlib.metadata as im
def find_files(
package: str, # pass in `__package__`
stem: str # pass in `tvm_ffi`, so that it finds `lib{stem}.so`, `lib{stem}.so`, `{stem}.dll`
):
owners: list[str] = im.packages_distributions().get(package)
pkg = owners[0] if owners else package.replace("_", "-")
for pth in im.files(pkg):
print("File: ", pth.locate())
...Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working