Skip to content

Commit 270f433

Browse files
authored
Merge pull request #6 from pythonbpf/test-workflow
Fix GH Actions, make Python3.12 the oldest supported version
2 parents 298df7e + ffc5a9f commit 270f433

File tree

7 files changed

+104
-35
lines changed

7 files changed

+104
-35
lines changed

.github/workflows/pip.yml

Lines changed: 85 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
name: Pip
22

33
on:
4-
workflow_dispatch:
5-
pull_request:
64
push:
7-
branches:
8-
- master
9-
- main
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
workflow_dispatch:
109

1110
jobs:
12-
build:
11+
test:
12+
name: Test on Python ${{ matrix.python-version }}
13+
runs-on: ubuntu-latest
1314
strategy:
1415
fail-fast: false
1516
matrix:
16-
platform: [ubuntu-latest]
17-
python-version: ["3.12", "3.13"]
18-
19-
runs-on: ${{ matrix.platform }}
17+
python-version: ['3.12', '3.13']
2018

2119
steps:
22-
- uses: actions/checkout@v5
20+
- name: Checkout code
21+
uses: actions/checkout@v5
2322
with:
24-
submodules: true
23+
submodules: recursive
2524

26-
- uses: actions/setup-python@v6
25+
- name: Verify submodules
26+
run: |
27+
echo "Checking submodule status:"
28+
git submodule status
29+
echo "Checking libbpf directory:"
30+
ls -la libbpf/
31+
echo "Checking libbpf/src:"
32+
ls -la libbpf/src/ || echo "libbpf/src not found!"
33+
34+
- name: Set up Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v5
2736
with:
2837
python-version: ${{ matrix.python-version }}
2938

@@ -33,19 +42,72 @@ jobs:
3342
sudo apt-get install -y \
3443
libbpf-dev \
3544
libelf-dev \
36-
linux-headers-generic \
45+
zlib1g-dev \
3746
build-essential \
47+
clang \
3848
cmake \
39-
ninja-build
49+
ninja-build \
50+
pkg-config \
51+
git \
52+
make
4053
41-
- name: Add requirements
42-
run: python -m pip install --upgrade pip wheel setuptools
54+
- name: Install Python build dependencies
55+
run: |
56+
python -m pip install --upgrade pip
57+
pip install --upgrade "setuptools>=77.0.0" wheel
58+
pip install cmake ninja pybind11
4359
44-
- name: Build and install
45-
run: pip install --verbose .[test]
60+
- name: Check build requirements
61+
run: |
62+
echo "Python version:"
63+
python --version
64+
echo "CMake version:"
65+
cmake --version
66+
echo "Ninja version:"
67+
ninja --version
68+
echo "Setuptools version:"
69+
python -c "import setuptools; print(setuptools.__version__)"
4670
47-
- name: Test import
48-
run: python -I -c "import pylibbpf; print('Import successful')"
71+
- name: Build and install pylibbpf (verbose)
72+
run: |
73+
pip install -v -e . 2>&1 | tee build.log
74+
continue-on-error: false
4975

50-
- name: Test
51-
run: python -I -m pytest -v
76+
- name: Check build output
77+
run: |
78+
echo "Build directory contents:"
79+
find build -type f -name "*.so" 2>/dev/null || echo "No .so files found in build/"
80+
echo ""
81+
echo "Looking for pylibbpf extension:"
82+
find . -name "pylibbpf*.so" -o -name "pylibbpf*.pyd"
83+
echo ""
84+
echo "Site-packages contents:"
85+
python -c "import site; print(site.getsitepackages())"
86+
ls -la $(python -c "import site; print(site.getsitepackages()[0])")/pylibbpf/ || echo "pylibbpf not in site-packages"
87+
88+
- name: Try importing extension directly
89+
run: |
90+
python -c "
91+
import sys
92+
print('Python path:', sys.path)
93+
try:
94+
from pylibbpf import pylibbpf
95+
print('Successfully imported pylibbpf.pylibbpf')
96+
print('pylibbpf.pylibbpf members:', dir(pylibbpf))
97+
except ImportError as e:
98+
print(f'Failed to import pylibbpf.pylibbpf: {e}')
99+
"
100+
101+
- name: Verify extension loaded
102+
run: |
103+
python -c "import pylibbpf; print('Members:', dir(pylibbpf)); assert hasattr(pylibbpf, 'BpfObject'), 'BpfObject not found!'; print('✓ OK')"
104+
105+
- name: Install test dependencies
106+
if: success()
107+
run: |
108+
pip install pytest pytest-cov
109+
110+
- name: Run tests
111+
if: success()
112+
run: |
113+
python -I -m pytest -v -s --cov=pylibbpf --cov-report=term-missing

.github/workflows/wheels.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v5
1919
with:
20-
submodules: true
20+
submodules: recursive
2121

2222
- name: Build SDist
2323
run: pipx run build --sdist
@@ -41,22 +41,24 @@ jobs:
4141
steps:
4242
- uses: actions/checkout@v5
4343
with:
44-
submodules: true
44+
submodules: recursive
4545

4646
- name: Build wheels
4747
uses: pypa/[email protected]
4848
env:
4949
CIBW_PLATFORM: linux
5050
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
51-
CIBW_BUILD: "cp311-*"
51+
CIBW_BUILD: "cp312-* cp313-*"
5252
CIBW_SKIP: "*-musllinux*"
53-
CIBW_TEST_COMMAND: "python -c 'import pylibbpf; print(f\"pylibbpf {pylibbpf.__version__} imported successfully\")'"
53+
CIBW_TEST_COMMAND: "python -c 'import pylibbpf; assert hasattr(pylibbpf, \"BpfObject\"), \"BpfObject not found\"; print(f\"pylibbpf {pylibbpf.__version__} OK\")'"
5454
CIBW_TEST_SKIP: "*-linux_aarch64"
5555

5656
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
5757

5858
CIBW_BEFORE_ALL_LINUX: |
59-
dnf install -y elfutils-libelf-devel zlib-devel
59+
dnf install -y elfutils-libelf-devel zlib-devel make gcc gcc-c++ git
60+
CIBW_BEFORE_BUILD: >
61+
pip install --upgrade "setuptools>=77.0.0" wheel cmake ninja pybind11
6062
6163
- name: Verify clean directory
6264
run: git diff --exit-code

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ set(CMAKE_CXX_STANDARD 20)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_CXX_EXTENSIONS OFF)
77

8-
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
8+
find_package(
9+
Python
10+
COMPONENTS Interpreter Development.Module
11+
REQUIRED)
912

1013
# pybind11
1114
include_directories(${CMAKE_SOURCE_DIR}/src)

pylibbpf/ir_to_ctypes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import ctypes
22
import logging
3-
from typing import Dict, Type
43

54
from llvmlite import ir
65

@@ -51,7 +50,7 @@ def __repr__(self):
5150
return __repr__
5251

5352

54-
def convert_structs_to_ctypes(structs_sym_tab) -> Dict[str, Type[ctypes.Structure]]:
53+
def convert_structs_to_ctypes(structs_sym_tab) -> dict[str, type[ctypes.Structure]]:
5554
"""Convert PythonBPF's structs_sym_tab to ctypes.Structure classes."""
5655
if not structs_sym_tab:
5756
return {}

pylibbpf/wrappers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable, Optional
1+
from collections.abc import Callable
22

33

44
class PerfEventArrayHelper:
@@ -13,7 +13,7 @@ def open_perf_buffer(
1313
callback: Callable,
1414
struct_name: str = "",
1515
page_cnt: int = 8,
16-
lost_callback: Optional[Callable] = None,
16+
lost_callback: Callable | None = None,
1717
):
1818
"""Open perf buffer with auto-deserialization."""
1919
from .pylibbpf import PerfEventArray

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,7 @@ extend-select = [
8080
"RUF", # Ruff-specific
8181
"UP", # pyupgrade
8282
]
83+
84+
[tool.setuptools]
85+
packages = ["pylibbpf"]
86+
package-data = {"pylibbpf" = ["*.py", "*.so", "*.pyd", "py.typed"]}

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
from pathlib import Path
55

6-
from setuptools import Extension, find_packages, setup
6+
from setuptools import Extension, setup
77
from setuptools.command.build_ext import build_ext
88

99

@@ -116,5 +116,4 @@ def build_extension(self, ext: CMakeExtension) -> None:
116116
setup(
117117
ext_modules=[CMakeExtension("pylibbpf.pylibbpf")],
118118
cmdclass={"build_ext": CMakeBuild},
119-
zip_safe=False,
120119
)

0 commit comments

Comments
 (0)