Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/actions/build-distribution/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build distribution
description: Build and validate one source distribution or wheel target

inputs:
kind:
description: Distribution kind to build (sdist or wheel)
required: true
wheel-build:
description: cibuildwheel build selector used when kind is wheel
required: false
default: ""

runs:
using: composite
steps:
- name: Validate build selection
shell: bash
env:
DISTRIBUTION_KIND: ${{ inputs.kind }}
WHEEL_BUILD: ${{ inputs.wheel-build }}
run: |
if [[ "$DISTRIBUTION_KIND" != "sdist" && "$DISTRIBUTION_KIND" != "wheel" ]]; then
echo "::error::kind must be 'sdist' or 'wheel'"
exit 1
fi
if [[ "$DISTRIBUTION_KIND" == "wheel" && -z "$WHEEL_BUILD" ]]; then
echo "::error::wheel-build is required when kind is 'wheel'"
exit 1
fi

- name: Prepare source distribution environment
if: ${{ inputs.kind == 'sdist' }}
uses: ./.github/actions/prepare

- name: Build source distribution
if: ${{ inputs.kind == 'sdist' }}
shell: bash
run: uv build -v --sdist

- name: Check source distribution
if: ${{ inputs.kind == 'sdist' }}
shell: bash
run: uv run twine check dist/*

- name: Build and test wheel
if: ${{ inputs.kind == 'wheel' }}
uses: pypa/cibuildwheel@v3.4.1
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_BUILD: ${{ inputs.wheel-build }}
CIBW_BUILD_VERBOSITY: "1"
CIBW_TEST_COMMAND: python {project}/scripts/verify_wheel.py
28 changes: 1 addition & 27 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Prepare Build Environment"
description: "Build/install liburing and install Python deps (repo must already be checked out with submodules)"
description: "Install Python and project dependencies (repo must already be checked out with submodules)"
inputs:
python-version:
description: "Python version to set up"
Expand All @@ -8,36 +8,10 @@ inputs:
runs:
using: "composite"
steps:
- name: Get liburing commit hash
id: cache-info
shell: bash
run: echo "liburing_hash=$(cd libs && git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Cache liburing build
id: cache-liburing
uses: actions/cache@v4
with:
path: libs/
key: ${{ runner.os }}-${{ runner.arch }}-liburing-${{ steps.cache-info.outputs.liburing_hash }}

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Build liburing (if cache miss)
if: steps.cache-liburing.outputs.cache-hit != 'true'
shell: bash
run: |
cd libs
./configure
make

- name: Install liburing (always)
shell: bash
run: |
cd libs
sudo make install

- name: Install UV
uses: astral-sh/setup-uv@v5
with:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,44 @@ jobs:

- name: Run tests
run: uv run pytest tests/ -v

check-sdist:
name: Check source distribution
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build source distribution
uses: ./.github/actions/build-distribution
with:
kind: sdist

check-wheel:
name: Check ${{ matrix.build }}
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
build:
- cp312-manylinux_x86_64
- cp313-manylinux_x86_64
- cp312-musllinux_x86_64
- cp313-musllinux_x86_64
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build wheel
uses: ./.github/actions/build-distribution
with:
kind: wheel
wheel-build: ${{ matrix.build }}
71 changes: 64 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Upload Package
name: Publish package

on:
release:
Expand All @@ -8,7 +8,62 @@ permissions:
contents: read

jobs:
release-build:
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build source distribution
uses: ./.github/actions/build-distribution
with:
kind: sdist

- name: Upload source distribution
uses: actions/upload-artifact@v4
with:
name: distribution-sdist
path: dist/*.tar.gz
if-no-files-found: error

build-wheel:
name: Build ${{ matrix.build }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
build:
- cp312-manylinux_x86_64
- cp313-manylinux_x86_64
- cp312-musllinux_x86_64
- cp313-musllinux_x86_64
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build wheel
uses: ./.github/actions/build-distribution
with:
kind: wheel
wheel-build: ${{ matrix.build }}

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: distribution-${{ matrix.build }}
path: wheelhouse/*.whl
if-no-files-found: error

publish:
name: Upload distributions to PyPI
needs: [build-sdist, build-wheel]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand All @@ -20,15 +75,17 @@ jobs:
- name: Prepare environment
uses: ./.github/actions/prepare

- name: Build release distributions
run: |
uv build -v --sdist
- name: Download distributions
uses: actions/download-artifact@v4
with:
pattern: distribution-*
path: dist
merge-multiple: true

# TODO: switch to PyPI Trusted Publishing (OIDC) and drop the token:
# https://docs.pypi.org/trusted-publishers/
- name: Upload distributions
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
uv run twine upload --verbose --repository pypi dist/*
run: uv run twine upload --verbose --repository pypi dist/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ wheels/
_liburing.c
_liburing.o
_liburing.*.so
_uringcore_liburing.*.so
17 changes: 17 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
include _ffi_build.py
include libs/LICENSE
include libs/Makefile.common
include libs/Makefile.quiet
include libs/configure
include libs/liburing.spec
include libs/src/Makefile
include src/uringcore_liburing.c
include THIRD_PARTY_LICENSES/liburing-MIT.txt
recursive-include libs/src *.c
include libs/src/int_flags.h
include libs/src/lib.h
include libs/src/syscall.h
recursive-include libs/src/arch *.h
include libs/src/include/liburing.h
include libs/src/include/liburing/barrier.h
include libs/src/include/liburing/io_uring.h
recursive-include docs *.md
recursive-include uringloop *.py *.pyi
include uringloop/py.typed
exclude uringloop/_liburing.c
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ A Python implementation of a liburing-based proactor event loop for asyncio, des

- Python 3.12+

- liburing development libraries

```bash
sudo apt install liburing-dev
```
- A C compiler and `make` when installing from source. The pinned liburing
sources are included and built automatically; a system `liburing-dev`
package is not required.

## Installation

Expand All @@ -39,7 +37,8 @@ uv add uringloop
pip install uringloop
```

Only a source distribution is published, so the CFFI extension is compiled during installation; the liburing development headers (see Requirements) and a C compiler must be present.
Only a source distribution is currently published, so the native extensions
and bundled liburing sources are compiled during installation.

## Quick Start

Expand Down
10 changes: 9 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,21 @@ API.
The decision record must compare wheel size, license/attribution, build
complexity, sanitizer coverage, syscall overhead, and the unsafe surface.
Raw syscalls require correctly implementing the acquire/release ordering on
shared ring heads and tails that liburing already handles.
shared ring heads and tails that liburing already handles. The
[Phase 1 backend decision](docs/phase1-native-ring-decision.md), accepted on
2026-08-01, selects the statically linked, vendored liburing route and
records the measurements and required follow-up.

- Move request lifetimes into native structs. A request owns every
kernel-referenced buffer, sockaddr, msghdr, and iovec.

- Use a refcounted, multi-completion request state machine rather than
"release on the first CQE." At minimum it must model submitted,
cancel-pending, operation-complete, notification-pending, and released
states. `SEND_ZC` normally produces an operation CQE followed by a
notification CQE, and asynchronous cancellation can race with a successful
operation completion.

- Add a bounded provided-buffer pool with explicit memory accounting and
backpressure. Be precise about copying:

Expand All @@ -158,8 +164,10 @@ API.
- Size the CQ explicitly for multishot workloads, detect overflow, drain
promptly, and test re-arming when the kernel terminates a multishot
operation by clearing `IORING_CQE_F_MORE`.

- Expose a small, GIL-conscious batch API: prepare operations, submit once per
loop tick, and reap a batch of completions in one native call.

- Add EINTR handling, runtime opcode/feature probing, and registered-ring-fd
support where probing and measurement justify it.

Expand Down
21 changes: 21 additions & 0 deletions THIRD_PARTY_LICENSES/liburing-MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
liburing
Copyright 2020 Jens Axboe

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 0 additions & 3 deletions _ffi_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
"uringloop._liburing",
source_code,
sources=[],
include_dirs=["./libs/src/include"],
define_macros=[("_GNU_SOURCE", "1")],
extra_compile_args=["-D_GNU_SOURCE"],
libraries=["uring"], # Link against liburing
library_dirs=["./libs/src"], # Path to the library
)


Expand Down
Loading
Loading