Skip to content

expose public regulated data types as a python package #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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=[
cur_path / "uavcan",
cur_path / "reg",
],
output_directory=output_dir,
)


class CustomBuild(build):
sub_commands = [("build_custom", None)] + build.sub_commands


setup(cmdclass={"build": CustomBuild, "build_custom": CustomCommand})