Update pip.yml

This commit is contained in:
2025-09-20 23:27:41 +05:30
parent 97eb8f6d1a
commit 761bf2d660
4 changed files with 24 additions and 25 deletions

View File

@ -15,18 +15,18 @@ jobs:
matrix: matrix:
platform: [ubuntu-latest] platform: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Install system dependencies - name: Install system dependencies
run: | run: |
sudo apt-get update sudo apt-get update
@ -36,16 +36,15 @@ jobs:
build-essential \ build-essential \
cmake \ cmake \
ninja-build ninja-build
- name: Add requirements - name: Add requirements
run: python -m pip install --upgrade pip wheel setuptools run: python -m pip install --upgrade pip wheel setuptools
- name: Build and install - name: Build and install
run: pip install --verbose .[test] run: pip install --verbose .[test]
- name: Test import - name: Test import
run: python -c "import pylibbpf; print('Import successful')" run: python -c "import pylibbpf; print('Import successful')"
- name: Test - name: Test
run: python -m pytest -v run: python -m pytest -v

View File

@ -18,13 +18,13 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Build SDist - name: Build SDist
run: pipx run build --sdist run: pipx run build --sdist
- name: Check metadata - name: Check metadata
run: pipx run twine check dist/* run: pipx run twine check dist/*
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: cibw-sdist name: cibw-sdist
@ -38,46 +38,46 @@ jobs:
matrix: matrix:
# Build for both x86_64 and aarch64 # Build for both x86_64 and aarch64
arch: [x86_64, aarch64] arch: [x86_64, aarch64]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
submodules: true submodules: true
# Set up QEMU for aarch64 emulation # Set up QEMU for aarch64 emulation
- name: Set up QEMU - name: Set up QEMU
if: matrix.arch == 'aarch64' if: matrix.arch == 'aarch64'
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
with: with:
platforms: arm64 platforms: arm64
- name: Build wheels - name: Build wheels
uses: pypa/cibuildwheel@v2.17 uses: pypa/cibuildwheel@v2.17
env: env:
# Only build for Linux # Only build for Linux
CIBW_PLATFORM: linux CIBW_PLATFORM: linux
CIBW_ARCHS_LINUX: ${{ matrix.arch }} CIBW_ARCHS_LINUX: ${{ matrix.arch }}
# Python versions to build for # Python versions to build for
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*" CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
CIBW_SKIP: "*-musllinux*" # Skip musl builds, focus on glibc CIBW_SKIP: "*-musllinux*" # Skip musl builds, focus on glibc
# Install system dependencies before building # Install system dependencies before building
CIBW_BEFORE_ALL_LINUX: > CIBW_BEFORE_ALL_LINUX: >
yum install -y epel-release && yum install -y epel-release &&
yum install -y libbpf-devel kernel-headers || yum install -y libbpf-devel kernel-headers ||
(apt-get update && apt-get install -y libbpf-dev linux-headers-generic) (apt-get update && apt-get install -y libbpf-dev linux-headers-generic)
# Test the built wheels # Test the built wheels
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\")'"
# Skip testing on emulated architectures (too slow) # Skip testing on emulated architectures (too slow)
CIBW_TEST_SKIP: "*-linux_aarch64" CIBW_TEST_SKIP: "*-linux_aarch64"
- name: Verify clean directory - name: Verify clean directory
run: git diff --exit-code run: git diff --exit-code
shell: bash shell: bash
- name: Upload wheels - name: Upload wheels
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
@ -95,7 +95,7 @@ jobs:
environment: environment:
name: pypi name: pypi
# url: https://pypi.org/project/pylibbpf/${{ github.event.release.name }} # url: https://pypi.org/project/pylibbpf/${{ github.event.release.name }}
steps: steps:
- name: Download all artifacts - name: Download all artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
@ -103,7 +103,7 @@ jobs:
pattern: cibw-* pattern: cibw-*
path: dist path: dist
merge-multiple: true merge-multiple: true
- name: Publish to PyPI - name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1 uses: pypa/gh-action-pypi-publish@release/v1
with: with:

View File

@ -1,5 +1,4 @@
import os import os
import re
import subprocess import subprocess
import sys import sys
from pathlib import Path from pathlib import Path
@ -50,7 +49,7 @@ class CMakeBuild(build_ext):
f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm
] ]
build_args = [] build_args = []
# Adding CMake arguments set as environment variable # Adding CMake arguments set as environment variable
# (needed e.g. to build for ARM OSx on conda-forge) # (needed e.g. to build for ARM OSx on conda-forge)
if "CMAKE_ARGS" in os.environ: if "CMAKE_ARGS" in os.environ:

View File

@ -1,5 +1,6 @@
import pylibbpf as m import pylibbpf as m
def test_main(): def test_main():
assert m.__version__ == "0.0.1" assert m.__version__ == "0.0.1"
assert m.add(1, 2) == 3 assert m.add(1, 2) == 3