Skip to content

Commit

Permalink
build: install Bleak by default on Linux (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
terop authored Jul 27, 2024
1 parent 3fdb4e0 commit c501d94
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Changelog

### [Unreleased]
* ADD: Install Bleak automatically on all platforms

## [2.3.1] - 2024-03-10
* ADD: Bluez as option to RUUVI_BLE_ADAPTER environment variable
Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,10 @@ In case of errors, the application tries to exit immediately, so it can be autom

### Bleak

On Windows and macOS Bleak is installed and used automatically with `ruuvitag-sensor` package.
Bleak is automatically installed with `ruuvitag-sensor` package on all platforms.
On Windows and macOS it is automatically used with `ruuvitag-sensor` package.

On Linux install it manually from PyPI and enable it with `RUUVI_BLE_ADAPTER` environment variable.

```sh
$ python -m pip install bleak
```

Add environment variable RUUVI_BLE_ADAPTER with value Bleak. E.g.
To enable Bleak use the `RUUVI_BLE_ADAPTER` environment variable as shown below.

```sh
$ export RUUVI_BLE_ADAPTER="bleak"
Expand All @@ -467,7 +462,7 @@ import os
os.environ["RUUVI_BLE_ADAPTER"] = "bleak"
```

Bleak supports only async methods.
Bleak only supports asynchronous methods.

```py
import asyncio
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies = [
"ptyprocess;platform_system=='Linux'",
"mypy-extensions;python_version<'3.8'",
"importlib-metadata<4.3,>=1.1.0;python_version<'3.8'",
"bleak;platform_system=='Windows' or platform_system=='Darwin'",
"bleak",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -87,4 +87,4 @@ line_length = 120
ensure_newline_before_comments = true

[tool.black]
line-length = 120
line-length = 120
6 changes: 4 additions & 2 deletions ruuvitag_sensor/adapters/bleak_ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ def _get_scanner(detection_callback: AdvertisementDataCallback, bt_device: str =

if bt_device:
return BleakScanner(
detection_callback=detection_callback, scanning_mode=scanning_mode, adapter=bt_device
) # type: ignore[arg-type]
detection_callback=detection_callback,
scanning_mode=scanning_mode, # type: ignore[arg-type]
adapter=bt_device,
)

return BleakScanner(detection_callback=detection_callback, scanning_mode=scanning_mode) # type: ignore[arg-type]

Expand Down

0 comments on commit c501d94

Please sign in to comment.