Skip to content

Commit 416f001

Browse files
chickenandporkymartin59
authored andcommitted
framework: accelerate build, cache upstream pip/wheel downloads (#3620)
* Accelerate build: ensure upstream pip/wheel downloads are cached * Move mkdir to wheel.mk as suggested
1 parent d13f3a4 commit 416f001

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

mk/spksrc.common.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ RUN = cd $(WORK_DIR)/$(PKG_DIR) && env $(ENV)
1515

1616
# Pip command
1717
PIP ?= pip
18-
PIP_WHEEL = $(PIP) wheel --no-binary :all: --no-deps --requirement $(WORK_DIR)/wheelhouse/requirements.txt --wheel-dir $(WORK_DIR)/wheelhouse --build-dir $(WORK_DIR)/wheelbuild
18+
# Why ask for the same thing twice? Always cache downloads
19+
PIP_CACHE_OPT ?= --cache-dir $(PIP_DIR)
20+
PIP_WHEEL = $(PIP) wheel --no-binary :all: $(PIP_CACHE_OPT) --no-deps --requirement $(WORK_DIR)/wheelhouse/requirements.txt --wheel-dir $(WORK_DIR)/wheelhouse --build-dir $(WORK_DIR)/wheelbuild
1921

2022
# Available languages
2123
LANGUAGES = chs cht csy dan enu fre ger hun ita jpn krn nld nor plk ptb ptg rus spn sve trk

mk/spksrc.directories.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
PWD := $(shell pwd)
1313

1414
DISTRIB_DIR = $(PWD)/../../distrib
15-
PIP_DIR = $(PWD)/../../distrib/pip
16-
TOOLCHAINS_DIR = $(PWD)/../../distrib/toolchains
17-
KERNELS_DIR = $(PWD)/../../distrib/kernels
15+
PIP_DIR = $(DISTRIB_DIR)/pip
16+
TOOLCHAINS_DIR = $(DISTRIB_DIR)/toolchains
17+
KERNELS_DIR = $(DISTRIB_DIR)/kernels
1818
PACKAGES_DIR = $(PWD)/../../packages
1919

2020
ifndef WORK_DIR

mk/spksrc.wheel.mk

+7
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@ endif
3434
wheel_msg_target:
3535
@$(MSG) "Processing wheels of $(NAME)"
3636

37+
# PIP distributions caching requires that the user running it owns the cache directory.
38+
# PIP_CACHE_OPT is default "--cache-dir $(PIP_DIR)", PIP_DIR defaults to $(DISTRIB_DIR)/pip, so
39+
# will move if the user chooses a custom persistent distribution dir for caching downloads between
40+
# containers and builds.
3741
pre_wheel_target: wheel_msg_target
3842
@if [ ! -z "$(WHEELS)" ] ; then \
43+
if [ ! -z "$(PIP_CACHE_OPT)" ] ; then \
44+
mkdir -p $(PIP_DIR) ; \
45+
fi; \
3946
mkdir -p $(WORK_DIR)/wheelhouse ; \
4047
if [ -f "$(WHEELS)" ] ; then \
4148
$(MSG) "Using existing requirements file" ; \

0 commit comments

Comments
 (0)