Skip to content

Commit 58a3c82

Browse files
committed
refactor: build from src/ and run tests from tests/
Point packaging, ruff, pytest, and coverage at the new layout and write generated bindings to src/openshell/_proto. Exclude the bindings from ty explicitly, since they are about to be committed. Drop pyelftools, which only core's packaging tooling uses. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
1 parent dd0bf72 commit 58a3c82

4 files changed

Lines changed: 19 additions & 16 deletions

File tree

‎pyproject.toml‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ classifiers = [
3939
keywords = ["agent", "sandbox", "nvidia"]
4040

4141
[project.urls]
42-
source = "https://github.com/NVIDIA/OpenShell"
42+
source = "https://github.com/ai-openshell/sdk-python"
4343
documentation = "https://docs.nvidia.com/openshell/latest/"
4444

4545
[dependency-groups]
@@ -51,7 +51,6 @@ dev = [
5151
"ruff>=0.4",
5252
"ty>=0.0.94",
5353
"grpcio-tools>=1.60",
54-
"pyelftools>=0.30",
5554
"pyyaml==6.0.2",
5655
"types-pyyaml>=6.0.12.20260518",
5756
"mypy-protobuf>=5.1",
@@ -60,25 +59,29 @@ dev = [
6059
]
6160

6261
[tool.setuptools]
63-
package-dir = { "" = "python" }
62+
package-dir = { "" = "src" }
6463
include-package-data = false
6564

6665
[tool.setuptools.packages.find]
67-
where = ["python"]
66+
where = ["src"]
6867
include = ["openshell*"]
6968
namespaces = false
7069

7170
[tool.setuptools.package-data]
7271
openshell = ["py.typed", "_proto/*.py", "_proto/*.pyi"]
7372

74-
# Ignore non-release tags such as sdk/go/vX.Y.Z, which share the release commit.
7573
[tool.setuptools_scm]
7674
git_describe_command = ["git", "describe", "--dirty", "--tags", "--long", "--match", "v[0-9]*"]
7775

7876
[tool.ruff]
7977
target-version = "py311"
8078
line-length = 88
81-
exclude = ["python/openshell/_proto"]
79+
exclude = ["src/openshell/_proto"]
80+
81+
# The generated bindings are committed, so the tools no longer skip them as
82+
# gitignored files.
83+
[tool.ty.src]
84+
exclude = ["src/openshell/_proto"]
8285

8386
[tool.ruff.lint]
8487
select = [
@@ -109,7 +112,7 @@ skip-magic-trailing-comma = false
109112
line-ending = "auto"
110113

111114
[tool.pytest.ini_options]
112-
testpaths = ["python"]
115+
testpaths = ["tests"]
113116
python_files = ["*_test.py"]
114117
python_functions = ["test_*"]
115118
addopts = "-v --tb=short"
@@ -119,7 +122,7 @@ markers = [
119122
]
120123

121124
[tool.coverage.run]
122-
source = ["python"]
125+
source = ["src"]
123126
branch = true
124127

125128
[tool.coverage.report]

‎scripts/generate_python_proto.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ def main() -> None:
3030
),
3131
)
3232
args = parser.parse_args()
33-
output_dir = Path("python/openshell/_proto")
33+
output_dir = Path("src/openshell/_proto")
3434

3535
subprocess.run(
3636
[
3737
sys.executable,
3838
"-m",
3939
"grpc_tools.protoc",
4040
"-Iproto",
41-
"--python_out=python/openshell/_proto",
41+
"--python_out=src/openshell/_proto",
4242
*(
4343
[]
4444
if args.no_pyi
4545
else [
46-
"--pyi_out=python/openshell/_proto",
47-
"--mypy_grpc_out=generate_concrete_servicer_stubs:python/openshell/_proto",
46+
"--pyi_out=src/openshell/_proto",
47+
"--mypy_grpc_out=generate_concrete_servicer_stubs:src/openshell/_proto",
4848
]
4949
),
50-
"--grpc_python_out=python/openshell/_proto",
50+
"--grpc_python_out=src/openshell/_proto",
5151
*PROTO_FILES,
5252
],
5353
check=True,

‎tests/generate_python_proto_test.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
def test_generate_package_relative_bindings(tmp_path: Path, no_pyi: bool) -> None:
1717
root = Path(__file__).resolve().parents[1]
1818
shutil.copytree(root / "proto", tmp_path / "proto")
19-
output = tmp_path / "python/openshell/_proto"
19+
output = tmp_path / "src/openshell/_proto"
2020
output.mkdir(parents=True)
2121
command = [
2222
sys.executable,
23-
str(root / "tasks/scripts/generate_python_proto.py"),
23+
str(root / "scripts/generate_python_proto.py"),
2424
*(["--no-pyi"] if no_pyi else []),
2525
]
2626
subprocess.run(command, cwd=tmp_path, check=True, capture_output=True, text=True)

‎tests/wheel_verifier_test.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
def _load_verifier_module():
15-
path = Path(__file__).resolve().parents[1] / "tasks/scripts/verify-python-wheel.py"
15+
path = Path(__file__).resolve().parents[1] / "scripts/verify-python-wheel.py"
1616
spec = importlib.util.spec_from_file_location("openshell_wheel_verifier", path)
1717
assert spec is not None
1818
assert spec.loader is not None

0 commit comments

Comments
 (0)