Skip to content

Commit 10a638a

Browse files
committed
ci: fix: merge pyproject.toml [tool.uv]
1 parent 766f937 commit 10a638a

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

.gitlab-ci.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,7 @@ test:
119119
TORCHVISION_VERSION=0.17.0+cu118
120120
fi
121121
- |
122-
if grep -q "tool.uv" pyproject.toml; then
123-
echo "[tool.uv] already exists in pyproject.toml"
124-
exit 1
125-
fi
126-
- |
127-
cat <<EOF >> pyproject.toml
128-
122+
cat <<EOF >> pyproject.toml.delta
129123
[tool.uv]
130124
override-dependencies = [
131125
"torch==$TORCH_VERSION",
@@ -140,7 +134,27 @@ test:
140134
name = "pytorch-$CUDA_VERSION_NAME"
141135
url = "https://download.pytorch.org/whl/$CUDA_VERSION_NAME"
142136
explicit = true
137+
EOF
138+
- uv pip install tomlkit
139+
- |
140+
uv run --no-sync python <<EOF
141+
from collections.abc import MutableMapping
142+
from pathlib import Path
143+
import tomlkit
144+
145+
def update_dict(d, d2):
146+
for k, v in d2.items():
147+
if k not in d:
148+
d[k] = v
149+
elif isinstance(d[k], MutableMapping) and isinstance(v, MutableMapping):
150+
update_dict(d[k], v)
151+
else:
152+
d[k] = v
143153
154+
base = tomlkit.parse(Path("pyproject.toml").read_text())
155+
delta = tomlkit.parse(Path("pyproject.toml.delta").read_text())
156+
update_dict(base, delta)
157+
Path("pyproject.toml").write_text(tomlkit.dumps(base))
144158
EOF
145159
- uv sync --group=test
146160
- *check-torch-cuda

0 commit comments

Comments
 (0)