This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch jenkins-wheel-test-artifacts
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/jenkins-wheel-test-artifacts
by this push:
new 5bb9f9d791 Locate minRPC sources through TVM_HOME for installed wheels
5bb9f9d791 is described below
commit 5bb9f9d7919bc0c5685d3bea25de54cd1f4f3cc5
Author: Tianqi Chen <[email protected]>
AuthorDate: Thu Oct 15 03:18:28 2026 +0000
Locate minRPC sources through TVM_HOME for installed wheels
---
python/tvm/rpc/minrpc.py | 5 ++-
tests/python/runtime/rpc/test_minrpc_source.py | 51 ++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/python/tvm/rpc/minrpc.py b/python/tvm/rpc/minrpc.py
index d46f2a2faf..33671a81df 100644
--- a/python/tvm/rpc/minrpc.py
+++ b/python/tvm/rpc/minrpc.py
@@ -37,8 +37,9 @@ def find_minrpc_server_libpath(server="posix_popen_server"):
path : str
The path to the min server library.
"""
- curr_dir = os.path.dirname(os.path.realpath(os.path.expanduser(__file__)))
- source_dir = os.path.abspath(os.path.join(curr_dir, "..", "..", ".."))
+ # Installed wheels use checkout resources without importing checkout
Python.
+ source_dir = os.environ.get("TVM_HOME") or
os.fspath(libinfo._dev_top_directory())
+ source_dir = os.path.realpath(os.path.expanduser(source_dir))
minrpc_dir = os.path.join(source_dir, "src", "runtime", "rpc", "minrpc")
path = os.path.join(minrpc_dir, server, f"{server}.cc")
diff --git a/tests/python/runtime/rpc/test_minrpc_source.py
b/tests/python/runtime/rpc/test_minrpc_source.py
new file mode 100644
index 0000000000..0512d1cfa5
--- /dev/null
+++ b/tests/python/runtime/rpc/test_minrpc_source.py
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Find checkout-only minrpc sources while importing an installed TVM wheel."""
+
+from pathlib import Path
+
+import pytest
+
+from tvm import libinfo
+from tvm.rpc import minrpc
+
+
[email protected]("layout", ["source", "symlink", "wheel"])
+def test_minrpc_source_location(tmp_path, monkeypatch, layout):
+ checkout = tmp_path / "checkout"
+ minrpc_dir = checkout / "src/runtime/rpc/minrpc"
+ server = minrpc_dir / "posix_popen_server/posix_popen_server.cc"
+ server.parent.mkdir(parents=True)
+ server.write_text("// source fixture\n")
+ # A wheel's package location is unrelated to the source checkout.
+ package = tmp_path / "site-packages/tvm" if layout == "wheel" else
checkout / "python/tvm"
+ if layout == "symlink":
+ package.mkdir(parents=True)
+ alias = tmp_path / "python-alias"
+ alias.symlink_to(checkout / "python", target_is_directory=True)
+ package = alias / "tvm"
+ monkeypatch.setattr(libinfo, "__file__", str(package / "libinfo.py"))
+ monkeypatch.setattr(minrpc, "__file__", str(package / "rpc/minrpc.py"))
+ monkeypatch.delenv("TVM_HOME", raising=False)
+ if layout == "wheel":
+ monkeypatch.setenv("TVM_HOME", str(checkout))
+ directory, path = minrpc.find_minrpc_server_libpath()
+ assert Path(directory) == minrpc_dir
+ assert Path(path) == server
+ server.unlink()
+ with pytest.raises(RuntimeError, match="Cannot find minserver"):
+ minrpc.find_minrpc_server_libpath()