Skip to content

Commit 8ee74c6

Browse files
committed
fix: clarify requirements
A requirement like >=6.33.2 includes >=7.0.0. This was not the intention. Clarify by limiting upper versions to original intention. Also declare script dependencies for versions, making them runnable outside the context of this repository, and removing pillow as a dev dependency for the project project. To run the examples with a locally edited version of wlsonar, we can do: uv run --with-editable . examples/convert_recording.py
1 parent fe6406f commit 8ee74c6

8 files changed

Lines changed: 55 additions & 124 deletions

File tree

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ jobs:
3131
- name: Run ruff
3232
run: uv run ruff check
3333
- name: Run mypy
34-
run: uv run mypy .
34+
run: uv run mypy . --exclude examples
3535
- name: Test
3636
run: uv run pytest

README_dev.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
uv sync
77
```
88

9+
## Examples
10+
11+
To run the example code with a locally edited version of wlsonar, use: `uv run --with-editable . examples/trim_recording.py`.
12+
913
## Linting
1014

1115
The package is linted with `ruff` and `mypy`:
1216

1317
```bash
1418
uv run ruff check
1519
uv run ruff format --diff
16-
uv run mypy .
20+
uv run mypy . --exclude examples
1721
```
1822

1923
## Testing
@@ -44,4 +48,4 @@ uv run protoc \
4448
--python_out=src/wlsonar/range_image_protocol/_proto/ \
4549
--mypy_out=src/wlsonar/range_image_protocol/_proto/ \
4650
src/wlsonar/range_image_protocol/_proto/WaterLinkedSonarIntegrationProtocol.proto
47-
```
51+
```

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ The following examples are provided:
44
- [convert_recording.py](./convert_recording.py)
55
- [trim_recording.py](./trim_recording.py)
66

7-
The examples require the dev dependencies listed in pyproject.toml. If you have [`uv`](https://docs.astral.sh/uv/) installed, you can run the examples with for example `uv run python trim_recording.py`.
7+
The examples declare inline script dependencies. If you have [`uv`](https://docs.astral.sh/uv/) installed, you can `uv run` the examples directly: `uv run examples/trim_recording.py`.
88

9-
There is a short test recording included as test data: [ship_short.sonar](/tests/data/ship_short.sonar).
9+
There is a short test recording included as test data: [ship_short.sonar](/tests/data/ship_short.sonar).

examples/convert_recording.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
# /// script
2+
# requires-python = ">=3.10"
3+
# dependencies = [
4+
# "pillow>12.1.0,<13",
5+
# "wlsonar>=0.3.1,<0.5",
6+
# ]
7+
# ///
18
"""Example use of wlsonar module to convert .sonar recordings to .xyz and .png files."""
29

310
import argparse
411
import os
12+
from importlib.metadata import version
513

614
from PIL import Image
715

@@ -29,6 +37,8 @@ def make_filename(header: rip.Header, extension: str) -> str:
2937

3038

3139
if __name__ == "__main__":
40+
print(f"wlsonar version: {version('wlsonar')}")
41+
3242
parser = argparse.ArgumentParser(
3343
description=(
3444
"Example use of wlsonar module: Convert the first -n packets to .xyz and "

examples/record_udp_to_file.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
# /// script
2+
# requires-python = ">=3.10"
3+
# dependencies = [
4+
# "wlsonar>=0.3.1,<0.5",
5+
# ]
6+
# ///
17
"""Example use of wlsonar module: Record UDP packets from Sonar 3D-15 to a .sonar file."""
28

39
import argparse
410
import time
511
from collections import defaultdict
12+
from importlib.metadata import version
613
from typing import DefaultDict, Set
714

815
import wlsonar.range_image_protocol as rip
@@ -20,6 +27,8 @@ def human_readable_size(size: int) -> str:
2027

2128

2229
if __name__ == "__main__":
30+
print(f"wlsonar version: {version('wlsonar')}")
31+
2332
parser = argparse.ArgumentParser(
2433
description=(
2534
"Example use of wlsonar module: Record UDP multicast packets from Sonar 3D-15 to a "

examples/trim_recording.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
# /// script
2+
# requires-python = ">=3.10"
3+
# dependencies = [
4+
# "wlsonar>=0.3.1,<0.5",
5+
# ]
6+
# ///
17
"""Example use of wlsonar module to trim a .sonar recording by timestamps."""
28

39
import argparse
410
import datetime
11+
from importlib.metadata import version
512
from typing import Optional
613

714
import wlsonar.range_image_protocol as rip
@@ -27,6 +34,8 @@ def parse_time(timestr: str) -> datetime.time:
2734

2835

2936
if __name__ == "__main__":
37+
print(f"wlsonar version: {version('wlsonar')}")
38+
3039
parser = argparse.ArgumentParser(
3140
description=(
3241
"Example use of wlsonar module: Trim the a .sonar recording to include only packets"

pyproject.toml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[project]
22
name = "wlsonar"
3-
version = "0.3.1"
3+
version = "0.4.0"
44
description = "Python client and Range Image Protocol utilities for Water Linked Sonar 3D-15."
55
readme = "README.md"
66
authors = [
77
{ name = "Water Linked" }
88
]
99
requires-python = ">=3.10"
1010
dependencies = [
11-
"protobuf>=6.33.2",
12-
"python-snappy>=0.7.3",
13-
"requests>=2.32.5",
11+
"protobuf>=6.33.2,<7",
12+
"python-snappy>=0.7.3,<0.8",
13+
"requests>=2.32.5,<3",
1414
]
1515

1616
[project.urls]
@@ -27,12 +27,11 @@ disallow_untyped_defs = true
2727

2828
[dependency-groups]
2929
dev = [
30-
"mypy>=1.19.1",
31-
"mypy-protobuf>=4.0.0",
32-
"pdbpp>=0.11.7",
33-
"pillow>=12.1.0",
34-
"pytest>=9.0.2",
35-
"ruff>=0.14.10",
30+
"mypy>=1.19.1,<2",
31+
"mypy-protobuf>=4.0.0,<5",
32+
"pdbpp>=0.11.7,<0.12",
33+
"pytest>=9.0.2,<10",
34+
"ruff>=0.14.10,<0.15",
3635
]
3736

3837
[[tool.mypy.overrides]]

uv.lock

Lines changed: 9 additions & 109 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)