Skip to content

Commit 87eebdf

Browse files
committed
scripts: switch everything to use uv and add uv instructions in the README.md
1 parent 3653a59 commit 87eebdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+93
-80
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,21 @@ so refer to the in-tree [./manual/](./manual/) for more up-to-date instructions.
5050
### Prerequisites
5151

5252
C2Rust requires LLVM 7 or later with its corresponding clang compiler and libraries.
53-
Python 3.6 or later, CMake 3.5 or later, and openssl (1.0) are also required. These prerequisites may be installed with the following commands, depending on your platform:
53+
Python (through `uv`), CMake 3.5 or later and openssl (1.0) are also required.
54+
These prerequisites may be installed with the following commands, depending on your platform:
55+
56+
Python:
57+
58+
```sh
59+
curl -LsSf https://astral.sh/uv/install.sh | sh
60+
uv venv
61+
uv pip install -r scripts/requirements.txt
62+
```
5463

5564
- **Ubuntu 18.04, Debian 10, and later:**
5665

5766
```sh
58-
apt install build-essential llvm clang libclang-dev cmake libssl-dev pkg-config python3 git
67+
apt install build-essential llvm clang libclang-dev cmake libssl-dev pkg-config git
5968
```
6069

6170
Depending on the LLVM distribution, the `llvm-dev` package may also be required.
@@ -64,7 +73,7 @@ For example, the official LLVM packages from [apt.llvm.org](https://apt.llvm.org
6473
- **Arch Linux:**
6574

6675
```sh
67-
pacman -S base-devel llvm clang cmake openssl python
76+
pacman -S base-devel llvm clang cmake openssl
6877
```
6978

7079
- **NixOS / nix:**
@@ -77,7 +86,7 @@ For example, the official LLVM packages from [apt.llvm.org](https://apt.llvm.org
7786

7887
```sh
7988
xcode-select --install
80-
brew install llvm python3 cmake openssl
89+
brew install llvm cmake openssl
8190
```
8291

8392
The C2Rust transpiler now builds using a stable Rust compiler.
@@ -302,7 +311,7 @@ is very similar, but not always as up-to-date and comprehensive as `bear`.
302311
but a standalone version can be easily installed via `pip` with:
303312

304313
```sh
305-
pip install scan-build
314+
uv tool install scan-build
306315
```
307316

308317
#### ... with `compiledb`
@@ -312,7 +321,7 @@ Unlike the others, it doesn't require a clean build/`make clean`.
312321
Install via `pip` with:
313322

314323
```sh
315-
pip install compiledb
324+
uv tool install compiledb
316325
```
317326

318327
Usage:

book.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ create-missing = false
77
preprocess = ["links", "index"]
88

99
[preprocessor.generator_dispatch]
10-
command = "python3 manual/preprocessors/generator_dispatch.py"
10+
command = "./manual/preprocessors/generator_dispatch.py"
1111

1212
[output.html]
1313

c2rust-analyze/rename_nll_facts.py

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#!/usr/bin/env -S uv run
2+
13
'''
2-
Usage: `python3 rename_nll_facts.py src ref dest`
4+
Usage: `./rename_nll_facts.py src ref dest`
35
46
Renames atoms in `src/*.facts` to match the names used in `ref/*.facts`, then
57
writes the renamed facts to `dest/`.

c2rust-analyze/scripts/auto_fix_errors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env -S uv run
2+
23
import argparse
34
from collections import defaultdict, namedtuple
45
import json

c2rust-analyze/scripts/extract_working_defs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env -S uv run
2+
23
"""
34
Script for extracting defs on which rewriting succeeded. Currently, this is
45
specific to lighttpd_rust_amalgamated, but it could be generalized to work on
@@ -8,6 +9,7 @@
89
then locates each working def in the rewritten code by searching for "start/end
910
of def" comments and prints the code for each working def to stdout.
1011
"""
12+
1113
from dataclasses import dataclass
1214
import re
1315
import subprocess

c2rust-analyze/scripts/pointwise_metrics.py

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env -S uv run
2+
13
'''
24
Process logs to compute pointwise success rate metrics.
35

c2rust-analyze/scripts/run_pointwise_metrics.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ done |& tee "$unmodified_log_file"
100100
echo
101101
echo
102102

103-
python3 "$SCRIPT_DIR/pointwise_metrics.py" "$pointwise_log_file" "$unmodified_log_file"
103+
"$SCRIPT_DIR/pointwise_metrics.py" "$pointwise_log_file" "$unmodified_log_file"

c2rust-analyze/tests/auto_fix_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ fn test(file_name: &str) {
3838
);
3939

4040
// Run the script to fix errors.
41-
let mut cmd = Command::new("python3");
42-
cmd.arg(&script_path).arg(&json_path);
41+
let mut cmd = Command::new(script_path);
42+
cmd.arg(&json_path);
4343
let status = cmd.status().unwrap();
4444
assert!(
4545
status.success(),

c2rust-analyze/tests/filecheck/lighttpd_buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ cargo test lighttpd_buffer
1414
1515
# Auto-fix remaining compile errors
1616
rustc --crate-type rlib --error-format json test_buffer.rs 2>errors.json
17-
python3 scripts/auto_fix_errors.py errors.json
17+
./scripts/auto_fix_errors.py errors.json
1818
# Run again to fix newly uncovered errors
1919
rustc --crate-type rlib --error-format json test_buffer.rs 2>errors.json
20-
python3 scripts/auto_fix_errors.py errors.json
20+
./scripts/auto_fix_errors.py errors.json
2121
2222
# Remove `unsafe`
2323
sed -i -e 's/\<unsafe //' test_buffer.rs

c2rust-refactor/build.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ use std::path::Path;
55
use std::process::Command;
66

77
fn process_ast(mode: &str, dest: &Path) {
8-
let mut p = Command::new("python3")
9-
.arg("-B") // Don't write bytecode files (and thus pollute the source
10-
// directory)
11-
.arg("gen/process_ast.py")
8+
let mut p = Command::new("gen/process_ast.py")
129
.arg(mode)
1310
.arg(dest)
1411
.spawn()
15-
.expect("failed to run process_ast.py. Make sure python3 is in your PATH.");
12+
.expect("failed to run process_ast.py");
1613

1714
let ret = p.wait().expect("failed to wait on process_ast.py");
1815

0 commit comments

Comments
 (0)