diff --git a/python/cuopt_server/cuopt_server/_grpc_server_wrapper.py b/python/cuopt_server/cuopt_server/_grpc_server_wrapper.py new file mode 100644 index 0000000000..8cb5c0ba0b --- /dev/null +++ b/python/cuopt_server/cuopt_server/_grpc_server_wrapper.py @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +import os +import subprocess +import sys + + +def main(): + """ + Wrapper that launches the cuopt_grpc_server binary from the libcuopt package. + """ + import libcuopt + + server_path = os.path.join( + os.path.dirname(libcuopt.__file__), "bin", "cuopt_grpc_server" + ) + sys.exit(subprocess.call([server_path] + sys.argv[1:])) diff --git a/python/cuopt_server/cuopt_server/tests/test_grpc_server_entry_point.py b/python/cuopt_server/cuopt_server/tests/test_grpc_server_entry_point.py new file mode 100644 index 0000000000..942e05a392 --- /dev/null +++ b/python/cuopt_server/cuopt_server/tests/test_grpc_server_entry_point.py @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +import shutil +import subprocess + + +def test_cuopt_grpc_server_on_path(): + assert shutil.which("cuopt_grpc_server") is not None, ( + "cuopt_grpc_server should be on PATH after installing cuopt-server" + ) + + +def test_cuopt_grpc_server_help(): + result = subprocess.run( + ["cuopt_grpc_server", "--help"], + capture_output=True, + text=True, + timeout=10, + ) + output = f"{result.stdout}\n{result.stderr}" + assert result.returncode == 0, ( + f"cuopt_grpc_server --help failed (rc={result.returncode}): {output}" + ) + assert "cuopt_grpc_server" in output, ( + f"Expected 'cuopt_grpc_server' in --help output, got: {output}" + ) diff --git a/python/libcuopt/libcuopt/_grpc_server_wrapper.py b/python/libcuopt/libcuopt/_grpc_server_wrapper.py new file mode 100644 index 0000000000..dc60b2bbda --- /dev/null +++ b/python/libcuopt/libcuopt/_grpc_server_wrapper.py @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +import os +import subprocess +import sys + + +def main(): + """ + This connects to the gRPC server binary situated under libcuopt/bin folder. + """ + server_path = os.path.join( + os.path.dirname(__file__), "bin", "cuopt_grpc_server" + ) + sys.exit(subprocess.call([server_path] + sys.argv[1:])) diff --git a/python/libcuopt/pyproject.toml b/python/libcuopt/pyproject.toml index 6ba41c60dd..72f0000d04 100644 --- a/python/libcuopt/pyproject.toml +++ b/python/libcuopt/pyproject.toml @@ -47,6 +47,7 @@ libcuopt = "libcuopt" [project.scripts] cuopt_cli = "libcuopt._cli_wrapper:main" +cuopt_grpc_server = "libcuopt._grpc_server_wrapper:main" [tool.pydistcheck] select = [