Skip to content

Commit 13301a7

Browse files
committed
Use uv to manage python deps
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 13301a7

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

.github/workflows/build-stm.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ jobs:
2323
- name: Checkout repo
2424
uses: actions/checkout@v4
2525

26-
- name: Set up Python
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: 3.11
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v5
3028

3129
- name: Install ${{ matrix.swift }}
3230
run: |

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)