Skip to content

Commit 7473f30

Browse files
committed
starts with
1 parent fab4214 commit 7473f30

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

requirements/base.Makefile

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ REPO_BASE_DIR := $(shell git rev-parse --show-toplevel)
99
.DEFAULT_GOAL := help
1010

1111
DO_CLEAN_OR_UPGRADE:=$(if $(clean),,--upgrade)
12-
STARTSWITH_UPGRADE := $(if $(startswith),$(shell grep '^$(startswith)' $(basename $@).txt 2>/dev/null | cut -d= -f1 | xargs -n1 echo --upgrade-package),)
13-
UPGRADE_OPTION := $(if $(upgrade),--upgrade-package "$(upgrade)",$(if $(startswith),$(STARTSWITH_UPGRADE),$(DO_CLEAN_OR_UPGRADE))
12+
UPGRADE_OPTION := $(if $(upgrade),--upgrade-package "$(upgrade)",$(DO_CLEAN_OR_UPGRADE))
1413

1514

1615
objects = $(sort $(wildcard *.in))
@@ -51,10 +50,28 @@ help: ## this colorful help
5150
# extracting subsets of requiremenst like e.g _dask-distributed.*
5251
#
5352
%.txt: %.in
54-
cd ..; \
55-
uv pip compile $(UPGRADE_OPTION) \
56-
--no-header \
57-
--output-file requirements/$@ requirements/$<
53+
@if [ -n "$(startswith)" ]; then \
54+
MATCHING_PACKAGES=$$(grep '^$(startswith)' $@ 2>/dev/null | cut -d= -f1); \
55+
if [ -z "$$MATCHING_PACKAGES" ]; then \
56+
echo "No packages starting with '$(startswith)' found in $@. Skipping."; \
57+
exit 0; \
58+
fi; \
59+
STARTSWITH_UPGRADE=$$(echo "$$MATCHING_PACKAGES" | xargs -n1 echo --upgrade-package); \
60+
cd ..; \
61+
uv pip compile $$STARTSWITH_UPGRADE \
62+
--no-header \
63+
--output-file requirements/$@ requirements/$<; \
64+
elif [ -n "$(upgrade)" ]; then \
65+
cd ..; \
66+
uv pip compile --upgrade-package "$(upgrade)" \
67+
--no-header \
68+
--output-file requirements/$@ requirements/$<; \
69+
else \
70+
cd ..; \
71+
uv pip compile $(DO_CLEAN_OR_UPGRADE) \
72+
--no-header \
73+
--output-file requirements/$@ requirements/$<; \
74+
fi
5875

5976
_test.txt: _base.txt
6077

0 commit comments

Comments
 (0)