From e3621e835fb5a184d4647e48f1d15a332da1f7d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=B6gele?= Date: Wed, 30 Oct 2024 17:13:33 +0100 Subject: [PATCH 1/3] expose python package --- pyproject.toml | 13 +++++++++++++ setup.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 pyproject.toml create mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..24d92e9b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,13 @@ +[build-system] +requires = ['setuptools', 'pycyphal>=1.20.0'] +build-backend = 'setuptools.build_meta' + +[project] +name = 'public-regulated-data-types' +version = '0.0.1' + +[tool.setuptools] +packages = [] +exclude-package-data = { public_regulated_data_types = [ + "*.dsdl", +] } # don't include dsdl files in wheel diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..fe390a5b --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +import pycyphal +from contextlib import suppress +from pathlib import Path +from setuptools import Command, setup +from setuptools.command.build import build +import pathlib + + +class CustomCommand(Command): + def initialize_options(self) -> None: + self.bdist_dir = None + self.proto_msgs_path = None + self.pkg_name = None + + def finalize_options(self) -> None: + self.pkg_name = self.distribution.get_name().replace("-", "_") + self.proto_msgs_path = Path(self.pkg_name) + with suppress(Exception): + self.bdist_dir = Path(self.get_finalized_command("bdist_wheel").bdist_dir) + + def run(self) -> None: + if self.bdist_dir: + # Create package structure + output_dir = self.bdist_dir + cur_path = pathlib.Path(__file__).parent + uavcan_path = cur_path / "uavcan" + pycyphal.dsdl.compile_all( + root_namespace_directories=[uavcan_path.resolve()], + output_directory=output_dir, + ) + + +class CustomBuild(build): + sub_commands = [("build_custom", None)] + build.sub_commands + + +setup(cmdclass={"build": CustomBuild, "build_custom": CustomCommand}) From af3424ec82418694241ba8860e933b0cf0e26d48 Mon Sep 17 00:00:00 2001 From: ot-goegelem Date: Wed, 23 Apr 2025 15:14:26 +0200 Subject: [PATCH 2/3] Update pyproject.toml Co-authored-by: Pavel Kirienko --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 24d92e9b..398639eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ['setuptools', 'pycyphal>=1.20.0'] +requires = ['setuptools', 'pycyphal~=1.20.0'] build-backend = 'setuptools.build_meta' [project] From ed1dec87c46f9b8bb9b10eef41a2358af47486eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=B6gele?= Date: Wed, 23 Apr 2025 15:19:31 +0200 Subject: [PATCH 3/3] add `reg` dsdls to compilation --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fe390a5b..3638d795 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,10 @@ def run(self) -> None: cur_path = pathlib.Path(__file__).parent uavcan_path = cur_path / "uavcan" pycyphal.dsdl.compile_all( - root_namespace_directories=[uavcan_path.resolve()], + root_namespace_directories=[ + cur_path / "uavcan", + cur_path / "reg", + ], output_directory=output_dir, )