From 45bf6c8f548473dece52f780f60bd8e20c32bd65 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 17 May 2025 18:52:21 -0700 Subject: [PATCH] Add safety headers to package (#2258) * Add safety headers to package * include path * it's for the whole project * update * guard --- .gitignore | 1 + MANIFEST.in | 1 + opendbc/__init__.py | 3 +++ opendbc/safety/board/can.h | 6 ++++++ pyproject.toml | 6 ++++++ 5 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index cb96f087..e85e494f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ *.gcno uv.lock +/dist/ opendbc/can/build/ opendbc/can/obj/ diff --git a/MANIFEST.in b/MANIFEST.in index 288657b9..a8583dc9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ include opendbc/car/car.capnp include opendbc/car/include/c++.capnp +recursive-include opendbc/safety *.h diff --git a/opendbc/__init__.py b/opendbc/__init__.py index a40e5dbf..9f4ee658 100644 --- a/opendbc/__init__.py +++ b/opendbc/__init__.py @@ -1,3 +1,6 @@ import os DBC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'dbc') + +# -I include path for e.g. "#include " +INCLUDE_PATH = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")) diff --git a/opendbc/safety/board/can.h b/opendbc/safety/board/can.h index 21df062b..c2b8dfd1 100644 --- a/opendbc/safety/board/can.h +++ b/opendbc/safety/board/can.h @@ -1,4 +1,10 @@ #pragma once + +// TODO: clean this up. it's for interop with the panda version +#ifndef CANPACKET_HEAD_SIZE + #include "opendbc/safety/board/can_declarations.h" static const unsigned char dlc_to_len[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U}; + +#endif diff --git a/pyproject.toml b/pyproject.toml index 839ff01e..dd01ceeb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,3 +120,9 @@ flake8-implicit-str-concat.allow-multiline=false "pytest.main".msg = "pytest.main requires special handling that is easy to mess up!" # TODO: re-enable when all tests are converted to pytest #"unittest".msg = "Use pytest" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.package-data] +"opendbc.safety" = ["*.h", "board/*.h", "board/drivers/*.h", "safety/*.h"]