iperf3-lib 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. iperf3_lib-0.1.0/.github/workflows/ci.yml +49 -0
  2. iperf3_lib-0.1.0/.github/workflows/release.yml +144 -0
  3. iperf3_lib-0.1.0/.gitignore +213 -0
  4. iperf3_lib-0.1.0/Dockerfile +64 -0
  5. iperf3_lib-0.1.0/LICENSE +21 -0
  6. iperf3_lib-0.1.0/Makefile +67 -0
  7. iperf3_lib-0.1.0/PKG-INFO +102 -0
  8. iperf3_lib-0.1.0/README.md +73 -0
  9. iperf3_lib-0.1.0/docker-entrypoint.sh +13 -0
  10. iperf3_lib-0.1.0/pyproject.toml +116 -0
  11. iperf3_lib-0.1.0/src/iperf3_lib/__init__.py +8 -0
  12. iperf3_lib-0.1.0/src/iperf3_lib/capabilities.py +28 -0
  13. iperf3_lib-0.1.0/src/iperf3_lib/config.py +33 -0
  14. iperf3_lib-0.1.0/src/iperf3_lib/exceptions.py +13 -0
  15. iperf3_lib-0.1.0/src/iperf3_lib/ffi/__init__.py +1 -0
  16. iperf3_lib-0.1.0/src/iperf3_lib/ffi/api.py +38 -0
  17. iperf3_lib-0.1.0/src/iperf3_lib/ffi/symbols.py +38 -0
  18. iperf3_lib-0.1.0/src/iperf3_lib/iperf_client.py +148 -0
  19. iperf3_lib-0.1.0/src/iperf3_lib/iperf_server.py +100 -0
  20. iperf3_lib-0.1.0/src/iperf3_lib/result.py +42 -0
  21. iperf3_lib-0.1.0/tests/conftest.py +185 -0
  22. iperf3_lib-0.1.0/tests/test_capabilities.py +24 -0
  23. iperf3_lib-0.1.0/tests/test_client_async_and_result.py +98 -0
  24. iperf3_lib-0.1.0/tests/test_client_branches.py +172 -0
  25. iperf3_lib-0.1.0/tests/test_client_integration_configs.py +116 -0
  26. iperf3_lib-0.1.0/tests/test_client_mocked.py +101 -0
  27. iperf3_lib-0.1.0/tests/test_client_more.py +176 -0
  28. iperf3_lib-0.1.0/tests/test_config.py +22 -0
  29. iperf3_lib-0.1.0/tests/test_ffi_dlopen.py +37 -0
  30. iperf3_lib-0.1.0/tests/test_ffi_load.py +22 -0
  31. iperf3_lib-0.1.0/tests/test_server.py +30 -0
  32. iperf3_lib-0.1.0/tests/test_server_additional.py +116 -0
  33. iperf3_lib-0.1.0/tests/test_server_iteration.py +38 -0
  34. iperf3_lib-0.1.0/tests/test_server_serve_once.py +75 -0
  35. iperf3_lib-0.1.0/uv.lock +430 -0
@@ -0,0 +1,49 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ lint-and-types:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v4
16
+ with:
17
+ version: "latest"
18
+ - name: Install Python via uv
19
+ run: uv python install 3.12
20
+ - name: Install deps & run checks
21
+ run: |
22
+ uv sync --dev
23
+ make check
24
+
25
+ docker-matrix-tests:
26
+ runs-on: ubuntu-latest
27
+ needs: lint-and-types
28
+ strategy:
29
+ matrix:
30
+ python_base: ["python:3.12-slim", "python:3.13-slim", "python:3.14-slim"]
31
+ iperf_version: ["3.18", "3.19.1", "3.20"]
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - name: Build docker test image
35
+ run: |
36
+ PY_BASE="${{ matrix.python_base }}"
37
+ SANITIZED_PY_BASE="${PY_BASE//:/-}"
38
+ TAG="py-iperf3-test:${SANITIZED_PY_BASE}-${{ matrix.iperf_version }}"
39
+ docker build \
40
+ --build-arg PYTHON_BASE="${PY_BASE}" \
41
+ --build-arg IPERF3_VERSION=${{ matrix.iperf_version }} \
42
+ -t "${TAG}" .
43
+ - name: Run tests in container
44
+ run: |
45
+ PY_BASE="${{ matrix.python_base }}"
46
+ SANITIZED_PY_BASE="${PY_BASE//:/-}"
47
+ TAG="py-iperf3-test:${SANITIZED_PY_BASE}-${{ matrix.iperf_version }}"
48
+ docker run --rm -v "${{ github.workspace }}:/app" "${TAG}" \
49
+ bash -c "pytest -vvv --cov=src --cov-report=term-missing"
@@ -0,0 +1,144 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+ inputs:
9
+ version:
10
+ description: "Version to release (e.g., 0.1.0)"
11
+ required: true
12
+ type: string
13
+
14
+ jobs:
15
+ build:
16
+ name: Build Package
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Install system dependencies
22
+ run: sudo apt-get update && sudo apt-get install -y iperf3
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v4
26
+ with:
27
+ version: "latest"
28
+
29
+ - name: Set up Python
30
+ run: uv python install 3.12
31
+
32
+ - name: Install dependencies
33
+ run: uv sync --frozen
34
+
35
+ - name: Build package
36
+ run: uv build
37
+
38
+ - name: Upload dist artifacts
39
+ uses: actions/upload-artifact@v4
40
+ with:
41
+ name: dist
42
+ path: dist/
43
+
44
+ test:
45
+ name: Test Built Package
46
+ runs-on: ubuntu-latest
47
+ needs: build
48
+ strategy:
49
+ matrix:
50
+ python-version: ["3.12", "3.13"]
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+
54
+ - name: Install system dependencies
55
+ run: sudo apt-get update && sudo apt-get install -y iperf3
56
+
57
+ - name: Install uv
58
+ uses: astral-sh/setup-uv@v4
59
+ with:
60
+ version: "latest"
61
+
62
+ - name: Set up Python ${{ matrix.python-version }}
63
+ run: uv python install ${{ matrix.python-version }}
64
+
65
+ - name: Download dist artifacts
66
+ uses: actions/download-artifact@v4
67
+ with:
68
+ name: dist
69
+ path: dist/
70
+
71
+ - name: Create venv and install built package
72
+ run: |
73
+ uv venv --python ${{ matrix.python-version }}
74
+ uv pip install dist/*.whl
75
+
76
+ - name: Verify import
77
+ run: |
78
+ uv run python -c "import iperf3_lib; print('iperf3-lib imported successfully')"
79
+
80
+ publish-testpypi:
81
+ name: Publish to TestPyPI
82
+ runs-on: ubuntu-latest
83
+ needs: [build, test]
84
+ if: github.event_name == 'workflow_dispatch'
85
+ environment:
86
+ name: testpypi
87
+ url: https://test.pypi.org/p/iperf3-lib
88
+ permissions:
89
+ id-token: write
90
+ steps:
91
+ - name: Download dist artifacts
92
+ uses: actions/download-artifact@v4
93
+ with:
94
+ name: dist
95
+ path: dist/
96
+
97
+ - name: Publish to TestPyPI
98
+ uses: pypa/gh-action-pypi-publish@release/v1
99
+ with:
100
+ repository-url: https://test.pypi.org/legacy/
101
+
102
+ publish-pypi:
103
+ name: Publish to PyPI
104
+ runs-on: ubuntu-latest
105
+ needs: [build, test]
106
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
107
+ environment:
108
+ name: pypi
109
+ url: https://pypi.org/project/iperf3-lib
110
+ permissions:
111
+ id-token: write
112
+ steps:
113
+ - name: Download dist artifacts
114
+ uses: actions/download-artifact@v4
115
+ with:
116
+ name: dist
117
+ path: dist/
118
+
119
+ - name: Publish to PyPI
120
+ uses: pypa/gh-action-pypi-publish@release/v1
121
+
122
+ github-release:
123
+ name: Create GitHub Release
124
+ runs-on: ubuntu-latest
125
+ needs: publish-pypi
126
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
127
+ permissions:
128
+ contents: write
129
+ steps:
130
+ - uses: actions/checkout@v4
131
+
132
+ - name: Download dist artifacts
133
+ uses: actions/download-artifact@v4
134
+ with:
135
+ name: dist
136
+ path: dist/
137
+
138
+ - name: Create GitHub Release
139
+ uses: softprops/action-gh-release@v1
140
+ with:
141
+ files: dist/*
142
+ generate_release_notes: true
143
+ draft: false
144
+ prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }}
@@ -0,0 +1,213 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ # iPerf source files
210
+ iperf-3.*
211
+
212
+ # IntelliJ IDEA
213
+ .idea/
@@ -0,0 +1,64 @@
1
+ ARG PYTHON_BASE=python:3.12-slim
2
+ FROM ${PYTHON_BASE}
3
+
4
+ # Build-time argument to select which iperf3 release to build
5
+ # Default to 3.20 (use ARG to override if needed)
6
+ ARG IPERF3_VERSION=3.20
7
+
8
+ # Install system dependencies: build tools, runtime libs, and packages needed to build iperf3
9
+ RUN apt-get update && \
10
+ apt-get install -y --no-install-recommends \
11
+ build-essential \
12
+ autoconf \
13
+ automake \
14
+ libtool \
15
+ pkg-config \
16
+ git \
17
+ curl \
18
+ ca-certificates \
19
+ libssl-dev \
20
+ zlib1g-dev \
21
+ libffi-dev \
22
+ && rm -rf /var/lib/apt/lists/*
23
+
24
+ ARG IPERF3_ENABLE_MPTCP=0
25
+ # Build and install iperf3 from source so we can select a new enough version
26
+ RUN set -eux; \
27
+ cd /tmp; \
28
+ # prefer official es.net downloads which publish tarballs like iperf-3.19.1.tar.gz
29
+ curl -fsSL -o iperf.tar.gz "https://downloads.es.net/pub/iperf/iperf-${IPERF3_VERSION}.tar.gz"; \
30
+ tar xzf iperf.tar.gz; \
31
+ cd iperf-*; \
32
+ # Some releases include configure, others need bootstrap; try both
33
+ if [ -x ./bootstrap.sh ]; then ./bootstrap.sh; fi; \
34
+ if [ -x ./configure ]; then \
35
+ # Run the package's configure script with a standard prefix. Enabling
36
+ # MPTCP at build time requires kernel and header support on the host
37
+ # which may not be present inside the container; do not force it here.
38
+ ./configure --prefix=/usr/local || true; \
39
+ fi; \
40
+ make -j"$(nproc)"; \
41
+ make install; \
42
+ ldconfig; \
43
+ rm -rf /tmp/iperf*;
44
+
45
+ # Create app directory (code will be mounted here at runtime)
46
+ WORKDIR /app
47
+
48
+ # Create and activate a virtual environment
49
+ ENV VIRTUAL_ENV=/opt/venv
50
+ RUN python -m venv $VIRTUAL_ENV
51
+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
52
+
53
+ # Pre-install common dependencies so they're cached in the image
54
+ # (cffi, pydantic, pytest, pytest-asyncio, ty - the actual project install happens at runtime)
55
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
56
+ pip install --no-cache-dir cffi pydantic pytest pytest-asyncio ty
57
+
58
+ # Entrypoint script: install project in editable mode then run command
59
+ # This allows code changes without rebuilding the image
60
+ COPY docker-entrypoint.sh /usr/local/bin/
61
+ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
62
+
63
+ ENTRYPOINT ["docker-entrypoint.sh"]
64
+ CMD ["pytest", "-q"]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dariusz Panas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,67 @@
1
+ .PHONY: help install test test-cov test-integration lint format type-check check clean docker-build docker-test docker-shell all
2
+
3
+ # Default target
4
+ help:
5
+ @echo "Available targets:"
6
+ @echo " install - Install project with dev dependencies (using uv)"
7
+ @echo " all - Format, type-check, and run the full test suite (including integration)"
8
+ @echo " test - Run tests (excluding integration)"
9
+ @echo " test-cov - Run tests with coverage report"
10
+ @echo " test-integration - Run integration tests (requires iperf3 server)"
11
+ @echo " lint - Run ruff linter (via uv)"
12
+ @echo " format - Format code with ruff (via uv)"
13
+ @echo " type-check - Run ty type checker (via uv)"
14
+ @echo " check - Run all checks (lint, format check, type-check)"
15
+ @echo " clean - Remove build artifacts and caches"
16
+ @echo " docker-build - Build Docker test image"
17
+ @echo " docker-test - Run tests in Docker container"
18
+ @echo " docker-shell - Open shell in Docker container"
19
+
20
+ # Installation
21
+ install:
22
+ # Sync project virtualenv and install dev dependencies via uv
23
+ uv sync --dev
24
+
25
+ # Testing
26
+ test:
27
+ uv run pytest -v -m "not integration"
28
+
29
+ test-cov:
30
+ uv run pytest -v -m "not integration" --cov=src --cov-report=term-missing --cov-report=html
31
+
32
+ test-integration:
33
+ uv run pytest -v -m integration
34
+
35
+ # Code quality
36
+ lint:
37
+ uv run ruff check src tests
38
+
39
+ format:
40
+ uv run ruff format src tests
41
+ uv run ruff check --fix src tests
42
+
43
+ type-check:
44
+ uv run ty check src
45
+
46
+ check: lint type-check
47
+ uv run ruff format --check src tests
48
+
49
+ # Cleanup
50
+ clean:
51
+ rm -rf build dist *.egg-info .pytest_cache .coverage htmlcov .ruff_cache
52
+ find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
53
+ find . -type f -name "*.pyc" -delete 2>/dev/null || true
54
+
55
+ # Docker targets
56
+ docker-build:
57
+ docker build -t py-iperf3-test .
58
+
59
+ docker-test: docker-build
60
+ docker run --rm -v "$(CURDIR):/app" py-iperf3-test bash -c "pytest -vvv --cov=src --cov-report=term-missing --cov-report=xml"
61
+
62
+ # Aggregate target: format, type-check, and docker-test (full run)
63
+ all: format type-check docker-test
64
+
65
+
66
+ docker-shell: docker-build
67
+ docker run --rm -it -v "$(CURDIR):/app" py-iperf3-test bash
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: iperf3-lib
3
+ Version: 0.1.0
4
+ Summary: Modern Python wrapper for iperf3 using cffi (libiperf), with async support.
5
+ Project-URL: Homepage, https://github.com/dariuszpanas/iperf3-lib
6
+ Project-URL: Documentation, https://github.com/dariuszpanas/iperf3-lib/tree/main/docs
7
+ Project-URL: Repository, https://github.com/dariuszpanas/iperf3-lib
8
+ Project-URL: Issues, https://github.com/dariuszpanas/iperf3-lib/issues
9
+ Author: Dariusz Panas
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: MPTCP,SCTP,async,benchmark,cffi,iperf3,network,throughput
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: System Administrators
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: System :: Benchmark
24
+ Classifier: Topic :: System :: Networking
25
+ Requires-Python: >=3.12
26
+ Requires-Dist: cffi>=1.16
27
+ Requires-Dist: pydantic>=2.8
28
+ Description-Content-Type: text/markdown
29
+
30
+ # iperf3-lib
31
+
32
+ Modern Python wrapper for **iperf3** using **cffi** against **libiperf**.
33
+ - Typed configs/results (Pydantic)
34
+ - Sync + Async APIs
35
+ - Feature detection for SCTP / bidirectional / MPTCP (when lib supports it)
36
+ - Ready for `uv` workflows, ruff/ty/pytest
37
+
38
+ ## Quickstart
39
+
40
+ ```bash
41
+ # create env & install
42
+ uv venv
43
+ source .venv/bin/activate
44
+ uv pip install -e ".[dev]"
45
+ ```
46
+
47
+ You need a system libiperf (install iperf3 via your package manager).
48
+ To point to a non-standard library path:
49
+
50
+ ```bash
51
+ export IPERF3_LIB=/usr/local/lib/libiperf.so
52
+ ```
53
+
54
+ ```python
55
+ from iperf3_lib.config import ClientConfig, Protocol
56
+ from iperf3_lib.iperf_client import Client
57
+
58
+ cfg = ClientConfig(server="127.0.0.1", duration=2, protocol=Protocol.TCP, parallel=2)
59
+ res = Client(cfg).run()
60
+ print("OK:", res.ok, "Mbps:", f"{res.summary_mbps:.2f}", "err:", res.error)
61
+ ```
62
+ Notes
63
+ * Full features require a recent libiperf (iperf3 ≥ 3.19.x recommended).
64
+ * Some symbols may not exist on older builds; we detect and degrade gracefully.
65
+ * Integration tests are marked with @pytest.mark.integration.
66
+
67
+ ---
68
+
69
+ ## Running tests
70
+
71
+ - Run tests locally with Docker (recommended for Windows):
72
+
73
+ ```bash
74
+ # build the test image (pick python base and iperf version if needed)
75
+ docker build --build-arg PYTHON_BASE=python:3.12-slim --build-arg IPERF3_VERSION=3.20 -t py-iperf3-test .
76
+
77
+ # run the full test suite inside the container (mounted volume allows editing without rebuilding)
78
+ docker run --rm -v "$(pwd):/app" py-iperf3-test bash -c "pytest -vv --cov=src --cov-report=term-missing"
79
+ ```
80
+
81
+ - Quick single-test run (example):
82
+
83
+ ```bash
84
+ docker run --rm -v "$(pwd):/app" py-iperf3-test bash -c "pytest -q tests/test_client_integration_configs.py::test_client_various_configs\[udp_rate\] -vv"
85
+ ```
86
+
87
+ Notes about optional features
88
+ - MPTCP and some other features are optional and require the libiperf to be built with kernel/header support. Tests that exercise optional features will be skipped or xfailed depending on whether the built shared object exports the required symbol.
89
+
90
+ CI
91
+ - This repository includes a GitHub Actions workflow that builds and runs the tests inside the Docker image for a matrix of Python base images and iperf versions (see `.github/workflows/ci.yml`).
92
+
93
+ ---
94
+
95
+ ```markdown
96
+ # Changelog
97
+
98
+ ## 0.1.0
99
+ - Initial release: cffi (ABI) wrapper of libiperf (client & server),
100
+ Pydantic models, async support, ruff/ty/pytest, CI with uv.
101
+
102
+ ```