mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 01:48:35 +00:00
* widen bitfields whose declared width exceeds their base type clang2py can emit a bitfield typed as a smaller ctype than its own declared width (e.g. a 15-bit field typed ctypes.c_ubyte, which only has 8 bits) - ctypes rejects these with 'ValueError: number of bits invalid for bit field'. Surfaced by struct_vmbus_channel_offer_channel on a kernel with Hyper-V support enabled (not present locally, but present on GitHub Actions' Azure-hosted runners). Generalizes the existing c_bool-specific workaround to all integer ctypes, widening to the smallest standard type that fits. * fix ruff-format violation in vmlinux-gen.py * Add CI workflow to run the test suite (#96) * add CI workflow to run the test suite Runs make test on every push/PR. Kernel verifier tests need passwordless sudo and a kernel with BTF/BPF enabled, which isn't guaranteed on every runner, so the workflow probes for working sudo first and only attempts them if it's available. Also add ctypeslib2 to the test extra: make test now regenerates vmlinux.py via tools/vmlinux-gen.py, which needs clang2py. * fix CI: bpftool is a virtual package on Ubuntu, install linux-tools instead * fix CI: locate bpftool binary and add it to PATH manually linux-tools-generic's update-alternatives symlink for bpftool doesn't fire on GitHub-hosted runners, since their kernel version has no matching linux-tools-<version> package. * pin clang bindings to 16.0.6 to match Ubuntu's default libclang pip installs the latest 'clang' release by default, whose libclang API surface is newer than Ubuntu 24.04's apt libclang-16, causing a LibclangError about an undefined symbol. Older bindings against a newer libclang stay compatible, so pin the bindings low rather than the system library. * DEBUG: dump struct_vmbus_channel_offer_channel on test failure * remove debug step now that the bitfield issue is fixed * fix CI: install LLVM 19 from apt.llvm.org, Ubuntu's default is too old llvmlite>=0.49's ArgumentAttributes only recognizes the LLVM 19+ 'captures(none)' spelling of the renamed 'nocapture' attribute. Ubuntu noble's default llvm/clang packages are LLVM 18, whose llc can't parse that attribute in the emitted .ll text. * DEBUG: show real llc stderr on failure * fix YAML syntax in debug step * fix CI: install LLVM 22 (matching llvmlite's bundled version), not 19 Verified on CI: LLVM 19's llc still rejects 'captures(none)' as a parse error ('expected ) at end of argument list'). llvmlite 0.49 bundles LLVM 22.1.0 internally; match that generation instead. * remove debug step, LLVM 22 fix confirmed working on CI * avoid running CI twice per push: scope push trigger to master Branches live in this repo, not forks, so a push to a branch with an open PR fired both push and pull_request for the same commit. push now only fires for master (a post-merge check); pull_request already covers every commit on a feature branch.
78 lines
2.2 KiB
TOML
78 lines
2.2 KiB
TOML
[build-system]
|
|
requires = ["setuptools>=61.0"]
|
|
build-backend = "setuptools.build_meta"
|
|
|
|
[project]
|
|
name = "pythonbpf"
|
|
version = "0.1.9"
|
|
description = "Reduced Python frontend for eBPF"
|
|
authors = [
|
|
{ name = "r41k0u", email="pragyanshchaturvedi18@gmail.com" },
|
|
{ name = "varun-r-mallya", email="varunrmallya@gmail.com" }
|
|
]
|
|
classifiers = [
|
|
"Development Status :: 3 - Alpha",
|
|
"Intended Audience :: Developers",
|
|
"Operating System :: POSIX :: Linux",
|
|
"Programming Language :: Python :: 3",
|
|
"Programming Language :: Python :: 3.8",
|
|
"Programming Language :: Python :: 3.9",
|
|
"Programming Language :: Python :: 3.10",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Programming Language :: Python",
|
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
"Topic :: System :: Operating System Kernels :: Linux",
|
|
]
|
|
readme = "README.md"
|
|
license = {text = "Apache-2.0"}
|
|
requires-python = ">=3.10"
|
|
|
|
dependencies = [
|
|
"llvmlite>=0.45",
|
|
"astpretty",
|
|
"pylibbpf"
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
docs = [
|
|
"sphinx>=7.0",
|
|
"myst-parser>=2.0",
|
|
"sphinx-rtd-theme>=2.0",
|
|
"sphinx-copybutton",
|
|
]
|
|
test = [
|
|
"pytest>=8.0",
|
|
"pytest-cov>=5.0",
|
|
"ctypeslib2",
|
|
# Pinned rather than left to ctypeslib2's own (unpinned) dependency: pip
|
|
# installs the latest release by default, and its libclang API surface
|
|
# can be newer than the system libclang (e.g. Ubuntu 24.04 ships
|
|
# libclang-16), which fails with a LibclangError about an undefined
|
|
# symbol. Older bindings against a newer libclang stay compatible, so
|
|
# pin to an old-enough release instead of pinning apt's libclang.
|
|
"clang==16.0.6",
|
|
]
|
|
|
|
[tool.setuptools.packages.find]
|
|
where = ["."]
|
|
include = ["pythonbpf*"]
|
|
|
|
[tool.pytest.ini_options]
|
|
testpaths = ["tests"]
|
|
pythonpath = ["."]
|
|
python_files = ["test_*.py"]
|
|
markers = [
|
|
"verifier: requires sudo/root for kernel verifier tests (not run by default)",
|
|
"vmlinux: requires vmlinux.py for current kernel",
|
|
]
|
|
log_cli = false
|
|
|
|
[tool.coverage.run]
|
|
source = ["pythonbpf"]
|
|
omit = ["*/vmlinux*", "*/__pycache__/*"]
|
|
|
|
[tool.coverage.report]
|
|
show_missing = true
|
|
skip_covered = false
|