Skip to content
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
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include msgq *.h *.cc *.pyx *.pxd
17 changes: 6 additions & 11 deletions msgq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# must be built with scons
import os
from typing import Optional, List, Union

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

from typing import Optional, List, Union

assert MultiplePublishersError
assert IpcError
assert toggle_fake_events
assert set_fake_prefix
assert get_fake_prefix
assert delete_fake_prefix
assert wait_for_one_event

NO_TRAVERSAL_LIMIT = 2**64-1

context = Context()
Expand Down
44 changes: 23 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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", "Cython", "numpy"]
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"]
Expand All @@ -47,6 +48,7 @@ exclude = ["site_scons/"]
[tool.ty.rules]
# Cython modules are compiled at build time, not available for static analysis
unresolved-import = "ignore"
possibly-missing-attribute = "ignore"

[tool.pytest.ini_options]
addopts = "--durations=10"
Expand Down
46 changes: 46 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import numpy as np
from setuptools import setup
from Cython.Build import cythonize
from setuptools import Extension

msgq_dir = os.path.dirname(os.path.abspath(__file__))

# Common C++ compile args
cpp_args = ["-std=c++17", "-fPIC", "-O2"]

# msgq core C++ sources
msgq_cc_sources = [
"msgq/ipc.cc",
"msgq/event.cc",
"msgq/impl_msgq.cc",
"msgq/impl_fake.cc",
"msgq/msgq.cc",
]

# visionipc C++ sources
vipc_cc_sources = [
"msgq/visionipc/visionipc.cc",
"msgq/visionipc/visionipc_server.cc",
"msgq/visionipc/visionipc_client.cc",
"msgq/visionipc/visionbuf.cc",
]

extensions = [
Extension(
"msgq.ipc_pyx",
sources=["msgq/ipc_pyx.pyx"] + msgq_cc_sources,
language="c++",
extra_compile_args=cpp_args,
include_dirs=[msgq_dir, np.get_include()],
),
Extension(
"msgq.visionipc.visionipc_pyx",
sources=["msgq/visionipc/visionipc_pyx.pyx"] + vipc_cc_sources + msgq_cc_sources,
language="c++",
extra_compile_args=cpp_args,
include_dirs=[msgq_dir, np.get_include()],
),
]

setup(ext_modules=cythonize(extensions, language_level="3"))
Loading