mirror of
https://github.com/varun-r-mallya/pylibbpf.git
synced 2025-12-31 20:36:26 +00:00
Bundle libbpf and switch to vendored build
Signed-off-by: varun-r-mallya <varunrmallya@gmail.com>
This commit is contained in:
1
.github/workflows/pip.yml
vendored
1
.github/workflows/pip.yml
vendored
@ -32,6 +32,7 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libbpf-dev \
|
||||
libelf-dev \
|
||||
linux-headers-generic \
|
||||
build-essential \
|
||||
cmake \
|
||||
|
||||
16
.github/workflows/wheels.yml
vendored
16
.github/workflows/wheels.yml
vendored
@ -44,13 +44,6 @@ jobs:
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
# Set up QEMU for aarch64 emulation
|
||||
- name: Set up QEMU
|
||||
if: matrix.arch == 'aarch64'
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: arm64
|
||||
|
||||
- name: Build wheels
|
||||
uses: pypa/cibuildwheel@v2.17
|
||||
env:
|
||||
@ -59,14 +52,13 @@ jobs:
|
||||
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
|
||||
|
||||
# Python versions to build for
|
||||
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
|
||||
CIBW_BUILD: "cp38-* cp311-*"
|
||||
CIBW_SKIP: "*-musllinux*" # Skip musl builds, focus on glibc
|
||||
|
||||
# Install system dependencies before building
|
||||
# Install minimal system dependencies before building
|
||||
CIBW_BEFORE_ALL_LINUX: >
|
||||
yum install -y epel-release &&
|
||||
yum install -y libbpf-devel kernel-headers ||
|
||||
(apt-get update && apt-get install -y libbpf-dev linux-headers-generic)
|
||||
yum install -y make gcc-c++ kernel-headers ||
|
||||
(apt-get update && apt-get install -y build-essential linux-headers-generic)
|
||||
|
||||
# Test the built wheels
|
||||
CIBW_TEST_COMMAND: "python -c 'import pylibbpf; print(f\"pylibbpf {pylibbpf.__version__} imported successfully\")'"
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -2,3 +2,6 @@
|
||||
path = pybind11
|
||||
url = https://github.com/pybind/pybind11.git
|
||||
branch = master
|
||||
[submodule "libbpf"]
|
||||
path = libbpf
|
||||
url = https://github.com/libbpf/libbpf.git
|
||||
|
||||
@ -4,6 +4,40 @@ project(pylibbpf)
|
||||
add_subdirectory(pybind11)
|
||||
pybind11_add_module(pylibbpf src/main.cpp)
|
||||
|
||||
# Build vendored libbpf
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
libbpf
|
||||
PREFIX libbpf
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libbpf/src
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND
|
||||
make BUILD_STATIC_ONLY=1 OBJDIR=${CMAKE_CURRENT_BINARY_DIR}/libbpf/libbpf
|
||||
DESTDIR=${CMAKE_CURRENT_BINARY_DIR}/libbpf INCLUDEDIR= LIBDIR= UAPIDIR=
|
||||
install install_uapi_headers
|
||||
BUILD_IN_SOURCE TRUE
|
||||
INSTALL_COMMAND ""
|
||||
STEP_TARGETS build)
|
||||
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
|
||||
set(ARCH "x86")
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
||||
set(ARCH "arm")
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
set(ARCH "arm64")
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64le")
|
||||
set(ARCH "powerpc")
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
|
||||
set(ARCH "mips")
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "riscv64")
|
||||
set(ARCH "riscv")
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "loongarch64")
|
||||
set(ARCH "loongarch")
|
||||
endif()
|
||||
|
||||
set(LIBBPF_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/libbpf)
|
||||
set(LIBBPF_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/libbpf/libbpf.a)
|
||||
|
||||
# EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a
|
||||
# define (VERSION_INFO) here.
|
||||
target_compile_definitions(pylibbpf
|
||||
|
||||
1
libbpf
Submodule
1
libbpf
Submodule
Submodule libbpf added at 45e89348ec
@ -16,12 +16,11 @@ authors = [
|
||||
{ name = "varun-r-mallya", email = "varunrmallya@gmail.com" }
|
||||
]
|
||||
readme = "README.md"
|
||||
license = { text = "Apache-2.0" }
|
||||
license = "Apache-2.0"
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
@ -64,31 +63,6 @@ filterwarnings = [
|
||||
]
|
||||
testpaths = ["tests"]
|
||||
|
||||
[tool.cibuildwheel]
|
||||
build = ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*"]
|
||||
skip = ["*-win32", "*-win_amd64", "*-macosx*", "pp*"]
|
||||
|
||||
# Build for both x86_64 and aarch64 on Linux
|
||||
archs = ["x86_64", "aarch64"]
|
||||
|
||||
# Linux-specific settings
|
||||
[tool.cibuildwheel.linux]
|
||||
before-all = [
|
||||
"yum install -y epel-release || apt-get update",
|
||||
"yum install -y libbpf-devel kernel-headers || apt-get install -y libbpf-dev linux-headers-generic",
|
||||
]
|
||||
|
||||
# Skip testing on emulated architectures (too slow)
|
||||
test-skip = ["*_aarch64", "*_arm64"]
|
||||
|
||||
# Test command for supported architectures
|
||||
test-command = "pytest {project}/tests"
|
||||
test-extras = ["test"]
|
||||
|
||||
before-build = "rm -rf {project}/build"
|
||||
|
||||
environment = { CMAKE_BUILD_PARALLEL_LEVEL = "2" }
|
||||
|
||||
[tool.ruff]
|
||||
target-version = "py38"
|
||||
line-length = 88
|
||||
|
||||
1
setup.py
1
setup.py
@ -136,7 +136,6 @@ setup(
|
||||
classifiers=[
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
|
||||
Reference in New Issue
Block a user