9 Commits

6 changed files with 18 additions and 57 deletions

View File

@ -14,7 +14,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
platform: [ubuntu-latest] platform: [ubuntu-latest]
python-version: ["3.8", "3.12"] python-version: ["3.12", "3.13"]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
@ -48,4 +48,4 @@ jobs:
run: python -I -c "import pylibbpf; print('Import successful')" run: python -I -c "import pylibbpf; print('Import successful')"
- name: Test - name: Test
run: python -I -m pytest -v run: python -m pytest -v

View File

@ -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,14 +41,14 @@ 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: "cp38-* 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; print(f\"pylibbpf {pylibbpf.__version__} imported successfully\")'"
CIBW_TEST_SKIP: "*-linux_aarch64" CIBW_TEST_SKIP: "*-linux_aarch64"
@ -56,7 +56,9 @@ jobs:
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

View File

@ -5,6 +5,8 @@ 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)
# pybind11 # pybind11
include_directories(${CMAKE_SOURCE_DIR}/src) include_directories(${CMAKE_SOURCE_DIR}/src)
add_subdirectory(pybind11) add_subdirectory(pybind11)

View File

@ -1,6 +1,6 @@
[build-system] [build-system]
requires = [ requires = [
"setuptools>=42", "setuptools>=77",
"wheel", "wheel",
"ninja", "ninja",
"cmake>=4.0", "cmake>=4.0",
@ -17,8 +17,8 @@ authors = [
{ name = "varun-r-mallya", email = "varunrmallya@gmail.com" } { name = "varun-r-mallya", email = "varunrmallya@gmail.com" }
] ]
readme = "README.md" readme = "README.md"
license = { file = "LICENSE" } license = "Apache-2.0"
requires-python = ">=3.8" requires-python = ">=3.12"
classifiers = [ classifiers = [
"Development Status :: 3 - Alpha", "Development Status :: 3 - Alpha",
"Intended Audience :: Developers", "Intended Audience :: Developers",
@ -29,6 +29,7 @@ classifiers = [
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: C++", "Programming Language :: C++",
"Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Operating System Kernels :: Linux", "Topic :: System :: Operating System Kernels :: Linux",
@ -47,7 +48,7 @@ Issues = "https://github.com/pythonbpf/pylibbpf/issues"
[tool.mypy] [tool.mypy]
files = "setup.py" files = "setup.py"
python_version = "3.8" python_version = "3.12"
strict = true strict = true
show_error_codes = true show_error_codes = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
@ -68,7 +69,7 @@ filterwarnings = [
testpaths = ["tests"] testpaths = ["tests"]
[tool.ruff] [tool.ruff]
target-version = "py38" target-version = "py312"
line-length = 88 line-length = 88
[tool.ruff.lint] [tool.ruff.lint]

View File

@ -6,14 +6,6 @@ from pathlib import Path
from setuptools import Extension, find_packages, setup from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext from setuptools.command.build_ext import build_ext
# Convert distutils Windows platform specifiers to CMake -A arguments
PLAT_TO_CMAKE = {
"win32": "Win32",
"win-amd64": "x64",
"win-arm32": "ARM",
"win-arm64": "ARM64",
}
# A CMakeExtension needs a sourcedir instead of a file list. # A CMakeExtension needs a sourcedir instead of a file list.
# The name must be the _single_ output extension from the CMake build. # The name must be the _single_ output extension from the CMake build.
@ -45,8 +37,8 @@ class CMakeBuild(build_ext):
# from Python. # from Python.
cmake_args = [ cmake_args = [
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}", f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm
f"-DPython_EXECUTABLE={sys.executable}",
] ]
build_args = [] build_args = []
@ -122,44 +114,7 @@ if readme_path.exists():
long_description = readme_path.read_text(encoding="utf-8") long_description = readme_path.read_text(encoding="utf-8")
setup( setup(
name="pylibbpf",
version="0.0.1",
author="varun-r-mallya, r41k0u",
author_email="varunrmallyagmail.com",
description="Python Bindings for Libbpf",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/pythonbpf/pylibbpf",
packages=find_packages(where="."),
package_dir={"": "."},
py_modules=[], # Empty since we use packages
ext_modules=[CMakeExtension("pylibbpf.pylibbpf")], ext_modules=[CMakeExtension("pylibbpf.pylibbpf")],
cmdclass={"build_ext": CMakeBuild}, cmdclass={"build_ext": CMakeBuild},
zip_safe=False, zip_safe=False,
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 :: C++",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Operating System Kernels :: Linux",
],
install_requires=[
"llvmlite>=0.40.0", # Required for struct conversion
],
extras_require={"test": ["pytest>=6.0"]},
python_requires=">=3.8",
package_data={
"pylibbpf": [
"*.py",
"py.typed", # For type hints
],
},
include_package_data=True,
) )

View File

@ -2,6 +2,7 @@ import pylibbpf as m
def test_main(): def test_main():
print(dir(m))
assert m.__version__ == "0.0.6" assert m.__version__ == "0.0.6"
prog = m.BpfObject("tests/execve2.o", structs={}) prog = m.BpfObject("tests/execve2.o", structs={})
print(prog) print(prog)