Skip to content

Commit 253587a

Browse files
committed
NO-JIRA: replace uv with micropipenv in sync-requirements-txt.sh and add sync-pylock-toml.sh script
1 parent 7f0a6e7 commit 253587a

File tree

3 files changed

+35
-23
lines changed

3 files changed

+35
-23
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ refresh-pipfilelock-files:
477477
echo "Regenerating requirements.txt files"
478478
pushd $(ROOT_DIR)
479479
bash $(ROOT_DIR)/scripts/sync-requirements-txt.sh
480+
bash $(ROOT_DIR)/scripts/sync-pylock-toml.sh
480481
popd
481482

482483
# This is only for the workflow action

scripts/sync-pylock-toml.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -Eeuxo pipefail
3+
4+
# The following will create a pylock.toml file for every jupyter/ requirements.txt we have.
5+
uv --version || pip install uv
6+
cd jupyter
7+
find . -name "requirements.txt" -type f > files.txt
8+
cd ..
9+
while read -r file; do
10+
11+
echo "Processing $file"
12+
path="${file#./*}"
13+
image_name="${path%/*/*}"
14+
python_version="${path%/*}"
15+
python_version="${python_version##*-}"
16+
image_name="${image_name/+/-}"
17+
18+
if [[ "$path" == *"rocm/"* ]]; then
19+
image_name="${image_name#*/}-rocm"
20+
fi
21+
22+
# NOTE: --format requirements.txt is useless because of https://github.com/astral-sh/uv/issues/15534
23+
# uv pip compile --format requirements.txt --python ${python_version} -o jupyter/${path} --generate-hashes --emit-index-url --group jupyter-${image_name}-image --python-platform linux --no-annotate -q
24+
uv pip compile --format pylock.toml --python "${python_version}" -o "jupyter/${path%requirements.txt}pylock.toml" --generate-hashes --emit-index-url --group "jupyter-${image_name}-image" --python-platform "linux" --no-annotate -q
25+
26+
done < jupyter/files.txt
27+
28+
rm jupyter/files.txt

scripts/sync-requirements-txt.sh

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,9 @@ set -Eeuxo pipefail
44
# Our build tooling depends on requirements.txt files with hashes
55
# Namely, Konflux (https://konflux-ci.dev/), and Cachi2 (https://github.com/containerbuildsystem/cachi2).
66

7-
# The following will create an extra requirement.txt file for every Pipfile.lock we have.
8-
uv --version || pip install uv
9-
cd jupyter
10-
find . -name "requirements.txt" -type f > files.txt
11-
cd ..
12-
while read -r file; do
13-
14-
echo "Processing $file"
15-
path="${file#./*}"
16-
image_name="${path%/*/*}"
17-
python_version="${path%/*}"
18-
python_version="${python_version##*-}"
19-
image_name="${image_name/+/-}"
20-
21-
if [[ "$path" == *"rocm/"* ]]; then
22-
image_name="${image_name#*/}-rocm"
23-
fi
24-
25-
uv pip compile --format requirements.txt --python ${python_version} -o jupyter/${path} --generate-hashes --group jupyter-${image_name}-image --python-platform linux --no-annotate -q
26-
27-
done < jupyter/files.txt
28-
29-
rm jupyter/files.txt
7+
# The following will create an extra requirements.txt file for every Pipfile.lock we have.
8+
micropipenv --version || pip install micropipenv
9+
find . -name Pipfile.lock -execdir bash -c '
10+
echo "# Generated by /scripts/sync-requirements-txt.sh from Pipfile.lock" > requirements.txt &&
11+
echo >> requirements.txt &&
12+
micropipenv requirements >> requirements.txt' \;

0 commit comments

Comments
 (0)