Repository navigation
Add ctl_py, the build support for a Python management CLI - #2
ChuangZiyan wants to merge 1 commit into
Conversation
|
Thanks for your contribution! |
|
Maybe you have this already in mind and then the changes here would naturally transition from this, but I was expecting we could adopt the modern way of organizing python projects with a |
Yes, that works and it's cleaner. I'll move everything Python into ctl_py/ with a pyproject.toml (deps, ruff/pytest config, console_scripts entry point instead of the launcher), keep CMake only for generating the _pb2 modules, hooking pytest into CTest and installing the package, and rework PR 1 and 2 on that layout : ) |
Prepare a python3 rewrite of storage-lender-ctl without changing what is built or installed today. Everything Python-specific lives under ctl_py/ with a pyproject.toml that declares the package, its runtime dependency on protobuf, the pytest extra, and the ruff configuration. - BUILD_PYTHON_CTL (default OFF) selects the Python interpreter and verifies that the google.protobuf runtime is at least 3.20, which is what protoc 3.21 output requires. - ctl_py/CMakeLists.txt generates wire_pb2.py and ctl_pb2.py and stages the package into the build tree; a smoke test fails when the runtime and the generated code disagree. The package version is declared in _version.py and checked against the CMake project version. - add_lender_python_test() registers a pytest run as one CTest entry with the same label conventions as add_lender_test(). - The SPDX check covers *.py, and pre-commit runs ruff on Python sources. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Ziyan Zhuang <ziyan.zhuang@h3platform.com>
350c434 to
1994f6c
Compare
|
Reworked per your comments:
|
Summary
First step of the python3 rewrite of
storage-lender-ctl. This PR only prepares the build system; nothing that is built or installed changes today.ctl_py/with apyproject.tomlthat declares the package, its runtime dependency onprotobuf>=3.20, thepytestextra, theconsole_scriptsentry point, and the ruff/pytest configuration. The directory is renamed toctl/once the C++ tool is removed.BUILD_PYTHON_CTLoption (default OFF). When ON, CMake selects the Python 3.10+ interpreter and verifies that thegoogle.protobufruntime is at least 3.20, which is what protoc 3.21 output requires (cmake/FindPython3Protobuf.cmake).ctl_py/CMakeLists.txtgenerateswire_pb2.pyandctl_pb2.pyand stages the package into the build tree; an import smoke test fails if the runtime and the generated code disagree. The package version is declared once in_version.pyand checked against the CMake project version at configure time (no templates).add_lender_python_test()registers a pytest run as one CTest entry with the same label conventions asadd_lender_test().ci/check-spdx.shcovers*.py; pre-commit runsruff(lint + format) using the configuration inpyproject.toml.Follow-up PRs, in order: tool skeleton +
latency,quota+ install, removal of the C++ ctl (with thectl_py/→ctl/rename), docs.Operational note: the self-hosted CI runner needs
python3-protobufandpython3-pytestinstalled for theBUILD_PYTHON_CTL=ONpath, and pre-commit will fetch the ruff hook on first run.Verification
Ubuntu 24.04, python3 3.12.3, python3-protobuf 4.21.12, protoc 3.21.12, python3-pytest 7.4.4.
Also configured with
BUILD_PYTHON_CTL=OFF(the default) to confirm no Python dependency is required and the build is unchanged. Not run:pre-commit run --all-filesend to end (ruff was run directly with the pinned version).Checklist
CONTRIBUTING.mdand the Code of Conduct.git commit --signoff).🤖 Generated with Claude Code