Skip to content

Commit c9b6d5d

Browse files
committed
setup uv in ZarrPythonTests automatically
1 parent 695a0f6 commit c9b6d5d

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ jobs:
4343
run: |
4444
uv venv && uv init
4545
uv add zarr
46-
uv add zarrita
4746
4847
- name: Download testdata
4948
run: |

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,7 @@ array.write(
4343
## Development Start-Guide
4444

4545
### Run Tests Locally
46-
To be able to run the tests locally, make sure to have `python3.11` installed.
47-
Also, you need to set up a venv for zarrita at the root of the project:
48-
`python3.11 -m venv venv_zarrita`.
49-
50-
Then install zarrita there with `venv_zarrita/Scripts/pip install zarrita`
51-
for Windows and `venv_zarrita/bin/pip install zarrita` for Linux.
46+
To be able to run the tests locally, make sure to have `python3.11` and `uv` installed.
5247

5348
Furthermore, you will need the `l4_sample` test data:
5449

src/test/java/dev/zarr/zarrjava/ZarrPythonTests.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ public static void clearTestoutputFolder() throws IOException {
3939
Files.createDirectory(TESTOUTPUT);
4040
}
4141

42-
public void run_python_script(String scriptName, String... args) throws IOException, InterruptedException {
42+
public static int runCommand(String... command) throws IOException, InterruptedException {
4343
ProcessBuilder pb = new ProcessBuilder();
44-
pb.command().add("uv");
45-
pb.command().add("run");
46-
pb.command().add(PYTHON_TEST_PATH.resolve(scriptName).toString());
47-
pb.command().addAll(Arrays.asList(args));
44+
pb.command().addAll(Arrays.asList(command));
4845
Process process = pb.start();
4946

5047
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
@@ -58,7 +55,27 @@ public void run_python_script(String scriptName, String... args) throws IOExcept
5855
System.err.println(line);
5956
}
6057

61-
int exitCode = process.waitFor();
58+
return process.waitFor();
59+
}
60+
61+
@BeforeAll
62+
public static void setupUV() {
63+
try {
64+
int exitCode = runCommand("uv", "version");
65+
if (exitCode != 0) {
66+
//setup uv
67+
assert runCommand("uv", "venv") == 0;
68+
assert runCommand("uv", "init") == 0;
69+
assert runCommand("uv", "add", "zarr") == 0;
70+
}
71+
} catch (IOException | InterruptedException e) {
72+
throw new RuntimeException("uv not installed or not in PATH. See");
73+
}
74+
}
75+
76+
public void run_python_script(String scriptName, String... args) throws IOException, InterruptedException {
77+
int exitCode = runCommand(Stream.concat(Stream.of("uv", "run", PYTHON_TEST_PATH.resolve(scriptName)
78+
.toString()), Arrays.stream(args)).toArray(String[]::new));
6279
assert exitCode == 0;
6380
}
6481

0 commit comments

Comments
 (0)