Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/alpine-vm/start-alpine-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ VM_BUILD_DIR="$REPO_ROOT/.alpine-vm-build"
VM_IMAGE="$VM_BUILD_DIR/alpine.qcow2"
VM_SSH_PORT="2222"
VM_CONSOLE_LOG="vm-console.log"
VM_PACKAGES="bluez poetry openssh uv"
VM_PACKAGES="bluez openssh uv"

# Colors for output
GREEN='\033[0;32m'
Expand Down
43 changes: 17 additions & 26 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,41 @@ jobs:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
id: py

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
with:
version: "latest"
python-version: ${{ matrix.python-version }}
- name: Create virtual environment
run: pipx run poetry env use '${{ steps.py.outputs.python-path }}'
- name: Install dependencies
# work around https://github.com/python-poetry/poetry/issues/7161
env:
SYSTEM_VERSION_COMPAT: 0
run: pipx run poetry install --only main,test
activate-environment: true

- name: Test with pytest
run: pipx run poetry run pytest -v --cov-report=xml --junitxml=junit.xml -o junit_family=legacy
run: uv run pytest -v --cov-report=xml --junitxml=junit.xml -o junit_family=legacy

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
report_type: coverage
flags: ${{ matrix.os }}-py${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5
with:
report_type: test_results
flags: ${{ matrix.os }}-py${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}

- name: Type checking
# We don't do this in the lint job because we have conditionals
# on both the platform and the Python version in the code, so we
# need to check each matrix combination.
run: |
pipx run poetry run pip install pyright
pipx run poetry run pyright
pipx run poetry run pip install mypy
pipx run poetry run mypy -p bleak -p tests -p examples
uv tool install pyright
pyright
uv tool install mypy
mypy -p bleak -p tests -p examples


integration_tests_bluez:
Expand All @@ -78,23 +77,15 @@ jobs:
- name: Build and boot Alpine VM
run: ./.github/alpine-vm/start-alpine-vm.sh

- name: Install Python and dependencies in VM
run: |
./.github/alpine-vm/vm-ssh.sh '
bluetoothctl --version
uv python install ${{ matrix.python-version }}
uv python pin ${{ matrix.python-version }}
poetry env use ${{ matrix.python-version }}
poetry install --only main,test
'

- name: Run pytest in VM
run: |
./.github/alpine-vm/vm-ssh.sh '
bluetoothctl --version
export UV_PROJECT_ENVIRONMENT=../.venv # We are in an mounted folder, so to speed things up put the venv outside the mount
export FORCE_COLOR=1
export CI=true
export GITHUB_ACTIONS=true
poetry run pytest -v tests --bleak-bluez-vhci -v --cov-report=xml --junitxml=junit.xml -o junit_family=legacy
uv run pytest -v tests --bleak-bluez-vhci -v --cov-report=xml --junitxml=junit.xml -o junit_family=legacy -o cache_dir=../.pytest_cache
'

- name: Upload coverage reports to Codecov
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/format_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install development dependencies
run: pipx run poetry install --only docs,lint

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
with:
version: "latest"
activate-environment: true

- name: Check import sort with isort
run: pipx run poetry run isort {.,docs} --check --diff
run: uv run isort {.,docs} --check --diff

- name: Check code formatting with black
run: pipx run poetry run black . --check --diff
run: uv run black . --check --diff

- name: Lint with flake8
run: pipx run poetry run flake8 . --count --show-source --statistics
run: uv run flake8 . --count --show-source --statistics

- name: Build docs
run: pipx run poetry run make -C docs html
run: uv run make -C docs html
12 changes: 10 additions & 2 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
with:
version: "latest"
activate-environment: true

- name: Build
run: pipx run poetry build
run: uv build

- name: Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: pipx run twine upload dist/*
run: uvx twine upload dist/*
12 changes: 5 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ build:
python: "3.12"
jobs:
post_create_environment:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry
# Install uv
# https://docs.astral.sh/uv/
- pip install uv
post_install:
# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
# VIRTUAL_ENV needs to be set manually for now.
# See https://github.com/readthedocs/readthedocs.org/pull/11152/
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only docs
# https://docs.astral.sh/uv/concepts/projects/dependencies/
- uv sync --only-group docs

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"isort.importStrategy": "fromEnvironment",
"isort.args":["--profile", "black"],
"flake8.importStrategy": "fromEnvironment",
"python-envs.defaultEnvManager": "ms-python.python:poetry",
"python-envs.defaultPackageManager": "ms-python.python:poetry",
"python-envs.defaultEnvManager": "ms-python.python:venv",
"python-envs.defaultPackageManager": "ms-python.python:pip",
"python-envs.pythonProjects": []
}
14 changes: 7 additions & 7 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Get Started!

Ready to contribute? Here's how to set up ``bleak`` for local development.

You will need `Git <https://git-scm.com>`_ and `Poetry <https://python-poetry.org>`_
You will need `Git <https://git-scm.com>`_ and `uv <https://docs.astral.sh/uv/>`_
and your favorite text editor. And Python of course.

1. Fork the ``bleak`` repo on GitHub.
Expand All @@ -71,7 +71,7 @@ and your favorite text editor. And Python of course.
3. Set up the Python environment::

$ cd bleak/
$ poetry install
$ uv sync

4. Create a branch for local development, originating from the ``develop`` branch::

Expand All @@ -81,15 +81,15 @@ and your favorite text editor. And Python of course.

5. When you're done making changes, check that your changes pass linting and the tests::

$ poetry run isort .
$ poetry run black .
$ poetry run flake8
$ poetry run pytest
$ uv run isort .
$ uv run black .
$ uv run flake8
$ uv run pytest

6. Additionally, you can run integration tests by adding the ``--bleak-hci-transport`` argument to ``pytest``.
For more information, see `tests/integration/README.rst <tests/integration/README.rst>`_.

$ poetry run pytest --bleak-hci-transport=serial:/dev/tty.usbmodem1101
$ uv run pytest --bleak-hci-transport=serial:/dev/tty.usbmodem1101

7. Commit your changes and push your branch to GitHub::

Expand Down
Loading