diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml index f5129cbf93..ace943dd10 100644 --- a/sdk/python/pyproject.toml +++ b/sdk/python/pyproject.toml @@ -30,7 +30,12 @@ Repository = "https://github.com/openai/codex" Issues = "https://github.com/openai/codex/issues" [project.optional-dependencies] -dev = ["pytest>=8.0", "datamodel-code-generator==0.31.2", "ruff>=0.11"] +dev = [ + "pytest>=8.0", + "datamodel-code-generator==0.31.2", + "ruff>=0.11", + "tomli>=2.0; python_version < '3.11'", +] [tool.hatch.build] exclude = [ diff --git a/sdk/python/tests/test_artifact_workflow_and_binaries.py b/sdk/python/tests/test_artifact_workflow_and_binaries.py index 2cebd3a272..5d950a4718 100644 --- a/sdk/python/tests/test_artifact_workflow_and_binaries.py +++ b/sdk/python/tests/test_artifact_workflow_and_binaries.py @@ -10,6 +10,11 @@ from pathlib import Path import pytest +try: + import tomllib +except ModuleNotFoundError: # pragma: no cover - Python 3.10 fallback. + import tomli as tomllib + ROOT = Path(__file__).resolve().parents[1] @@ -223,7 +228,7 @@ def test_release_metadata_retries_without_invalid_auth(monkeypatch: pytest.Monke def test_runtime_package_is_wheel_only_and_builds_platform_specific_wheels() -> None: - pyproject_text = (ROOT.parent / "python-runtime" / "pyproject.toml").read_text() + pyproject = tomllib.loads((ROOT.parent / "python-runtime" / "pyproject.toml").read_text()) hook_source = (ROOT.parent / "python-runtime" / "hatch_build.py").read_text() hook_tree = ast.parse(hook_source) initialize_fn = next( @@ -263,12 +268,14 @@ def test_runtime_package_is_wheel_only_and_builds_platform_specific_wheels() -> and isinstance(node.value, ast.Constant) } - assert "[tool.hatch.build.targets.wheel]" in pyproject_text - assert 'packages = ["src/codex_cli_bin"]' in pyproject_text - assert 'include = ["src/codex_cli_bin/bin/**"]' in pyproject_text - assert "[tool.hatch.build.targets.wheel.hooks.custom]" in pyproject_text - assert "[tool.hatch.build.targets.sdist]" in pyproject_text - assert "[tool.hatch.build.targets.sdist.hooks.custom]" in pyproject_text + assert pyproject["tool"]["hatch"]["build"]["targets"]["wheel"] == { + "packages": ["src/codex_cli_bin"], + "include": ["src/codex_cli_bin/bin/**"], + "hooks": {"custom": {}}, + } + assert pyproject["tool"]["hatch"]["build"]["targets"]["sdist"] == { + "hooks": {"custom": {}}, + } assert sdist_guard is not None assert build_data_assignments == {"pure_python": False, "infer_tag": True}