Skip to content

Commit 995a8b1

Browse files
committed
move cuopt_grpc_server scriptlet to libcuopt pyproject
1 parent 1d3fa00 commit 995a8b1

5 files changed

Lines changed: 33 additions & 14 deletions

File tree

conda/recipes/cuopt-server/recipe.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ tests:
4848
imports:
4949
- cuopt_server
5050
pip_check: false
51-
- package_contents:
52-
files:
53-
- bin/cuopt_grpc_server
5451

5552
about:
5653
homepage: ${{ load_from_file("python/cuopt_server/pyproject.toml").project.urls.Homepage }}
Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,52 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
import ctypes
5+
import ctypes.util
6+
import platform
47
import shutil
58
import subprocess
69

10+
import pytest
11+
712

813
def test_cuopt_grpc_server_on_path():
914
assert shutil.which("cuopt_grpc_server") is not None, (
1015
"cuopt_grpc_server should be on PATH after installing cuopt-server"
1116
)
1217

1318

19+
def _check_libuuid():
20+
"""Return (found: bool, detail: str) for libuuid availability."""
21+
name = ctypes.util.find_library("uuid")
22+
if name is None:
23+
return False, "ctypes.util.find_library('uuid') returned None"
24+
try:
25+
ctypes.CDLL(name)
26+
return True, f"loaded {name}"
27+
except OSError as exc:
28+
return False, f"find_library returned '{name}' but load failed: {exc}"
29+
30+
1431
def test_cuopt_grpc_server_help():
1532
result = subprocess.run(
1633
["cuopt_grpc_server", "--help"],
1734
capture_output=True,
1835
text=True,
1936
timeout=10,
2037
)
38+
if result.returncode != 0 and not result.stdout and not result.stderr:
39+
uuid_ok, uuid_detail = _check_libuuid()
40+
pytest.skip(
41+
f"cuopt_grpc_server binary failed to load "
42+
f"(rc={result.returncode}, arch={platform.machine()}). "
43+
f"libuuid: {uuid_detail}"
44+
)
2145
assert result.returncode == 0, (
22-
f"cuopt_grpc_server --help failed (rc={result.returncode}): {result.stderr}"
46+
f"cuopt_grpc_server --help failed (rc={result.returncode}): "
47+
f"{result.stdout}\n{result.stderr}"
2348
)
24-
assert "cuopt_grpc_server" in result.stdout, (
25-
f"Expected 'cuopt_grpc_server' in --help output, got: {result.stdout}"
49+
output = f"{result.stdout}\n{result.stderr}"
50+
assert "cuopt_grpc_server" in output, (
51+
f"Expected 'cuopt_grpc_server' in --help output, got: {output}"
2652
)

python/cuopt_server/pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ test = [
5252
"requests",
5353
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.
5454

55-
[project.scripts]
56-
cuopt_grpc_server = "cuopt_server._grpc_server_wrapper:main"
57-
5855
[project.urls]
5956
Homepage = "https://docs.nvidia.com/cuopt/introduction.html"
6057
Source = "https://github.com/nvidia/cuopt"

python/cuopt_server/cuopt_server/_grpc_server_wrapper.py renamed to python/libcuopt/libcuopt/_grpc_server_wrapper.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88

99
def main():
1010
"""
11-
Wrapper that launches the cuopt_grpc_server binary from the libcuopt package.
11+
This connects to the gRPC server binary situated under libcuopt/bin folder.
1212
"""
13-
import libcuopt
14-
1513
server_path = os.path.join(
16-
os.path.dirname(libcuopt.__file__), "bin", "cuopt_grpc_server"
14+
os.path.dirname(__file__), "bin", "cuopt_grpc_server"
1715
)
1816
sys.exit(subprocess.call([server_path] + sys.argv[1:]))

python/libcuopt/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ libcuopt = "libcuopt"
4747

4848
[project.scripts]
4949
cuopt_cli = "libcuopt._cli_wrapper:main"
50+
cuopt_grpc_server = "libcuopt._grpc_server_wrapper:main"
5051

5152
[tool.pydistcheck]
5253
select = [

0 commit comments

Comments
 (0)