mirror of
https://github.com/varun-r-mallya/pylibbpf.git
synced 2026-03-22 13:11:28 +00:00
Merge pull request #6 from pythonbpf/test-workflow
Fix GH Actions, make Python3.12 the oldest supported version
This commit is contained in:
108
.github/workflows/pip.yml
vendored
108
.github/workflows/pip.yml
vendored
@ -1,29 +1,38 @@
|
|||||||
name: Pip
|
name: Pip
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
pull_request:
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [main, master]
|
||||||
- master
|
pull_request:
|
||||||
- main
|
branches: [main, master]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
|
name: Test on Python ${{ matrix.python-version }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
platform: [ubuntu-latest]
|
python-version: ['3.12', '3.13']
|
||||||
python-version: ["3.12", "3.13"]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: recursive
|
||||||
|
|
||||||
- uses: actions/setup-python@v6
|
- name: Verify submodules
|
||||||
|
run: |
|
||||||
|
echo "Checking submodule status:"
|
||||||
|
git submodule status
|
||||||
|
echo "Checking libbpf directory:"
|
||||||
|
ls -la libbpf/
|
||||||
|
echo "Checking libbpf/src:"
|
||||||
|
ls -la libbpf/src/ || echo "libbpf/src not found!"
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
@ -33,19 +42,72 @@ jobs:
|
|||||||
sudo apt-get install -y \
|
sudo apt-get install -y \
|
||||||
libbpf-dev \
|
libbpf-dev \
|
||||||
libelf-dev \
|
libelf-dev \
|
||||||
linux-headers-generic \
|
zlib1g-dev \
|
||||||
build-essential \
|
build-essential \
|
||||||
|
clang \
|
||||||
cmake \
|
cmake \
|
||||||
ninja-build
|
ninja-build \
|
||||||
|
pkg-config \
|
||||||
|
git \
|
||||||
|
make
|
||||||
|
|
||||||
- name: Add requirements
|
- name: Install Python build dependencies
|
||||||
run: python -m pip install --upgrade pip wheel setuptools
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install --upgrade "setuptools>=77.0.0" wheel
|
||||||
|
pip install cmake ninja pybind11
|
||||||
|
|
||||||
- name: Build and install
|
- name: Check build requirements
|
||||||
run: pip install --verbose .[test]
|
run: |
|
||||||
|
echo "Python version:"
|
||||||
|
python --version
|
||||||
|
echo "CMake version:"
|
||||||
|
cmake --version
|
||||||
|
echo "Ninja version:"
|
||||||
|
ninja --version
|
||||||
|
echo "Setuptools version:"
|
||||||
|
python -c "import setuptools; print(setuptools.__version__)"
|
||||||
|
|
||||||
- name: Test import
|
- name: Build and install pylibbpf (verbose)
|
||||||
run: python -I -c "import pylibbpf; print('Import successful')"
|
run: |
|
||||||
|
pip install -v -e . 2>&1 | tee build.log
|
||||||
|
continue-on-error: false
|
||||||
|
|
||||||
- name: Test
|
- name: Check build output
|
||||||
run: python -I -m pytest -v
|
run: |
|
||||||
|
echo "Build directory contents:"
|
||||||
|
find build -type f -name "*.so" 2>/dev/null || echo "No .so files found in build/"
|
||||||
|
echo ""
|
||||||
|
echo "Looking for pylibbpf extension:"
|
||||||
|
find . -name "pylibbpf*.so" -o -name "pylibbpf*.pyd"
|
||||||
|
echo ""
|
||||||
|
echo "Site-packages contents:"
|
||||||
|
python -c "import site; print(site.getsitepackages())"
|
||||||
|
ls -la $(python -c "import site; print(site.getsitepackages()[0])")/pylibbpf/ || echo "pylibbpf not in site-packages"
|
||||||
|
|
||||||
|
- name: Try importing extension directly
|
||||||
|
run: |
|
||||||
|
python -c "
|
||||||
|
import sys
|
||||||
|
print('Python path:', sys.path)
|
||||||
|
try:
|
||||||
|
from pylibbpf import pylibbpf
|
||||||
|
print('Successfully imported pylibbpf.pylibbpf')
|
||||||
|
print('pylibbpf.pylibbpf members:', dir(pylibbpf))
|
||||||
|
except ImportError as e:
|
||||||
|
print(f'Failed to import pylibbpf.pylibbpf: {e}')
|
||||||
|
"
|
||||||
|
|
||||||
|
- name: Verify extension loaded
|
||||||
|
run: |
|
||||||
|
python -c "import pylibbpf; print('Members:', dir(pylibbpf)); assert hasattr(pylibbpf, 'BpfObject'), 'BpfObject not found!'; print('✓ OK')"
|
||||||
|
|
||||||
|
- name: Install test dependencies
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
pip install pytest pytest-cov
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
python -I -m pytest -v -s --cov=pylibbpf --cov-report=term-missing
|
||||||
|
|||||||
12
.github/workflows/wheels.yml
vendored
12
.github/workflows/wheels.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: recursive
|
||||||
|
|
||||||
- name: Build SDist
|
- name: Build SDist
|
||||||
run: pipx run build --sdist
|
run: pipx run build --sdist
|
||||||
@ -41,22 +41,24 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: recursive
|
||||||
|
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
uses: pypa/cibuildwheel@v3.2
|
uses: pypa/cibuildwheel@v3.2
|
||||||
env:
|
env:
|
||||||
CIBW_PLATFORM: linux
|
CIBW_PLATFORM: linux
|
||||||
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
|
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
|
||||||
CIBW_BUILD: "cp311-*"
|
CIBW_BUILD: "cp312-* cp313-*"
|
||||||
CIBW_SKIP: "*-musllinux*"
|
CIBW_SKIP: "*-musllinux*"
|
||||||
CIBW_TEST_COMMAND: "python -c 'import pylibbpf; print(f\"pylibbpf {pylibbpf.__version__} imported successfully\")'"
|
CIBW_TEST_COMMAND: "python -c 'import pylibbpf; assert hasattr(pylibbpf, \"BpfObject\"), \"BpfObject not found\"; print(f\"pylibbpf {pylibbpf.__version__} OK\")'"
|
||||||
CIBW_TEST_SKIP: "*-linux_aarch64"
|
CIBW_TEST_SKIP: "*-linux_aarch64"
|
||||||
|
|
||||||
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
|
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
|
||||||
|
|
||||||
CIBW_BEFORE_ALL_LINUX: |
|
CIBW_BEFORE_ALL_LINUX: |
|
||||||
dnf install -y elfutils-libelf-devel zlib-devel
|
dnf install -y elfutils-libelf-devel zlib-devel make gcc gcc-c++ git
|
||||||
|
CIBW_BEFORE_BUILD: >
|
||||||
|
pip install --upgrade "setuptools>=77.0.0" wheel cmake ninja pybind11
|
||||||
|
|
||||||
- name: Verify clean directory
|
- name: Verify clean directory
|
||||||
run: git diff --exit-code
|
run: git diff --exit-code
|
||||||
|
|||||||
@ -5,7 +5,10 @@ set(CMAKE_CXX_STANDARD 20)
|
|||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
|
find_package(
|
||||||
|
Python
|
||||||
|
COMPONENTS Interpreter Development.Module
|
||||||
|
REQUIRED)
|
||||||
|
|
||||||
# pybind11
|
# pybind11
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import ctypes
|
import ctypes
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict, Type
|
|
||||||
|
|
||||||
from llvmlite import ir
|
from llvmlite import ir
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ def _make_repr(struct_name: str, fields: list):
|
|||||||
return __repr__
|
return __repr__
|
||||||
|
|
||||||
|
|
||||||
def convert_structs_to_ctypes(structs_sym_tab) -> Dict[str, Type[ctypes.Structure]]:
|
def convert_structs_to_ctypes(structs_sym_tab) -> dict[str, type[ctypes.Structure]]:
|
||||||
"""Convert PythonBPF's structs_sym_tab to ctypes.Structure classes."""
|
"""Convert PythonBPF's structs_sym_tab to ctypes.Structure classes."""
|
||||||
if not structs_sym_tab:
|
if not structs_sym_tab:
|
||||||
return {}
|
return {}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
from typing import Callable, Optional
|
from collections.abc import Callable
|
||||||
|
|
||||||
|
|
||||||
class PerfEventArrayHelper:
|
class PerfEventArrayHelper:
|
||||||
@ -13,7 +13,7 @@ class PerfEventArrayHelper:
|
|||||||
callback: Callable,
|
callback: Callable,
|
||||||
struct_name: str = "",
|
struct_name: str = "",
|
||||||
page_cnt: int = 8,
|
page_cnt: int = 8,
|
||||||
lost_callback: Optional[Callable] = None,
|
lost_callback: Callable | None = None,
|
||||||
):
|
):
|
||||||
"""Open perf buffer with auto-deserialization."""
|
"""Open perf buffer with auto-deserialization."""
|
||||||
from .pylibbpf import PerfEventArray
|
from .pylibbpf import PerfEventArray
|
||||||
|
|||||||
@ -80,3 +80,7 @@ extend-select = [
|
|||||||
"RUF", # Ruff-specific
|
"RUF", # Ruff-specific
|
||||||
"UP", # pyupgrade
|
"UP", # pyupgrade
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[tool.setuptools]
|
||||||
|
packages = ["pylibbpf"]
|
||||||
|
package-data = {"pylibbpf" = ["*.py", "*.so", "*.pyd", "py.typed"]}
|
||||||
|
|||||||
3
setup.py
3
setup.py
@ -3,7 +3,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from setuptools import Extension, find_packages, setup
|
from setuptools import Extension, setup
|
||||||
from setuptools.command.build_ext import build_ext
|
from setuptools.command.build_ext import build_ext
|
||||||
|
|
||||||
|
|
||||||
@ -116,5 +116,4 @@ if readme_path.exists():
|
|||||||
setup(
|
setup(
|
||||||
ext_modules=[CMakeExtension("pylibbpf.pylibbpf")],
|
ext_modules=[CMakeExtension("pylibbpf.pylibbpf")],
|
||||||
cmdclass={"build_ext": CMakeBuild},
|
cmdclass={"build_ext": CMakeBuild},
|
||||||
zip_safe=False,
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user