Skip to content

Commit 8887cc9

Browse files
authored
Use uv to manage python deps (#95)
Instead of having users manually manage python venvs this commit migrates the python scripts to use `uv` which can handle installing script dependencies automatically. Additionally it doesn't require sourcing a venv setup script in every shell where you want to build. A further improvement on the swift swift side should also be made to use swiftly to manage swift toolchain versions instead of the `TOOLCHAINS` env variable.
1 parent 513524f commit 8887cc9

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

.github/workflows/build-stm.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
with:
2929
python-version: 3.11
3030

31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v5
33+
3134
- name: Install ${{ matrix.swift }}
3235
run: |
3336
wget -q https://download.swift.org/development/ubuntu2404/${{ matrix.swift }}/${{ matrix.swift }}-ubuntu24.04.tar.gz
@@ -39,6 +42,5 @@ jobs:
3942
- name: Build ${{ matrix.example }}
4043
working-directory: ${{ matrix.example }}
4144
run: |
42-
pip3 install -r ../Tools/requirements.txt
4345
export STM_BOARD=STM32F746G_DISCOVERY
4446
./build-elf.sh

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@ Each example in this repository contains build and deployment instructions, howe
1919

2020
You can follow the [tutorial here](https://apple.github.io/swift-matter-examples/tutorials/swiftmatterexamples/setup-macos/) for instructions on installing and using nighly Swift toolchains.
2121

22-
2. Install the Python3 dependencies listed in `requirements.txt`.
23-
24-
```console
25-
$ cd swift-embedded-examples
26-
$ python3 -m venv .venv
27-
$ source .venv/bin/activate
28-
$ python3 -m pip install -r Tools/requirements.txt
29-
```
22+
2. Install [`uv`](https://github.com/astral-sh/uv) "an extremely fast Python package and project manager".
23+
24+
You can follow the [instructions here](https://docs.astral.sh/uv/getting-started/installation/) to install `uv`.
3025

3126
## Catalog of Examples
3227

Tools/elf2hex.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
#!/usr/bin/env -S python3 -u -tt
1+
#! /usr/bin/env -S uv run --script
2+
3+
# /// script
4+
# dependencies = [
5+
# "pyelftools==0.31",
6+
# ]
7+
# ///
28

39
# This source file is part of the Swift open source project
410
#

Tools/macho2bin.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
#!/usr/bin/env python3 -u -tt
1+
#! /usr/bin/env -S uv run --script
2+
3+
# /// script
4+
# dependencies = [
5+
# "macholib==1.16.3",
6+
# ]
7+
# ///
28

39
# This source file is part of the Swift open source project
410
#

Tools/macho2uf2.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
#!/usr/bin/env python3 -u -tt
1+
#! /usr/bin/env -S uv run --script
2+
3+
# /// script
4+
# dependencies = [
5+
# "macholib==1.16.3",
6+
# ]
7+
# ///
28

39
# This source file is part of the Swift open source project
410
#

Tools/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)