From c7c2fade03b2e423286554a3c2fcbaec029491d0 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 21 Feb 2026 10:35:13 -0800 Subject: [PATCH] add proper Python packaging with pyproject.toml Add build-system section, move dev deps to optional, add MANIFEST.in for C++/Cython source distribution, and export BASEDIR/INCLUDE_PATH from __init__.py for consumers. Co-Authored-By: Claude Opus 4.6 --- MANIFEST.in | 1 + msgq/__init__.py | 6 +++++- pyproject.toml | 43 ++++++++++++++++++++++--------------------- 3 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..15db22e --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include msgq *.h *.cc *.pyx *.pxd diff --git a/msgq/__init__.py b/msgq/__init__.py index 574e100..e762024 100644 --- a/msgq/__init__.py +++ b/msgq/__init__.py @@ -1,4 +1,8 @@ -# must be built with scons +import os + +BASEDIR = os.path.dirname(os.path.abspath(__file__)) +INCLUDE_PATH = os.path.abspath(os.path.join(BASEDIR, "../")) + from msgq.ipc_pyx import Context, Poller, SubSocket, PubSocket, SocketEventHandle, toggle_fake_events, \ set_fake_prefix, get_fake_prefix, delete_fake_prefix, wait_for_one_event from msgq.ipc_pyx import MultiplePublishersError, IpcError diff --git a/pyproject.toml b/pyproject.toml index efbb89a..05e208f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,33 +1,34 @@ [project] name = "msgq" -version = "0.0.1" -description = "Code powering the comma.ai panda" -readme = "README.md" +version = "0.1.0" +description = "Lock-free IPC message queue and VisionIPC" requires-python = ">=3.11,<3.13" license = {text = "MIT"} authors = [{name = "comma.ai"}] -classifiers = [ - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Topic :: System :: Hardware", -] dependencies = [ - "setuptools", # for distutils - "Cython", - "scons", - "ruff", - "parameterized", - "coverage", "numpy", - "pytest", - "pytest-retry", - "cppcheck", - "cpplint", - "codespell", - "ty", - "lefthook", ] +[project.optional-dependencies] +dev = [ + "setuptools", "Cython", "scons", "ruff", + "parameterized", "coverage", "numpy", + "pytest", "pytest-retry", + "cppcheck", "cpplint", "codespell", "ty", "lefthook", +] + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.package-data] +"msgq" = ["*.h", "*.cc", "*.pyx", "*.pxd"] +"msgq.visionipc" = ["*.h", "*.cc", "*.pyx", "*.pxd"] +"msgq.logger" = ["*.h"] + # https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml [tool.ruff] lint.select = ["E", "F", "W", "PIE", "C4", "ISC", "RUF100", "A"]