on master help sign in
Merge pull request #2421 from return42/mod-pyenvinstall

[perf] optimize creation of the virtualenv & pyenvinstal targets

commit48b4af1e08d54ec399f8ab77dd34b0f6380b3111 authorAlexandre Flament <alex@al-f.net> dateSun 27 Dec 2020, 08:27 (6 years ago) parent2fc2d17d175a0f
4 files changed+25−14
utils/lib.sh+7−7 utils/makefile.include+1−1 utils/makefile.lxc+5−2 utils/makefile.python+12−4
utils/lib.sh+7−7
@@ -41,7 +41,7 @@ DOT_CONFIG="${DOT_CONFIG:-${REPO_ROOT}/.config.sh}"
4141
4242source_dot_config() {
4343 if [[ ! -e "${DOT_CONFIG}" ]]; then
44− err_msg "configuration does not extsts at: ${DOT_CONFIG}"
44+ err_msg "configuration does not exists at: ${DOT_CONFIG}"
4545 return 42
4646 fi
4747 # shellcheck disable=SC1090
@@ -159,7 +159,7 @@ clean_stdin() {
159159}
160160
161161wait_key(){
162− # usage: waitKEY [<timeout in sec>]
162+ # usage: wait_key [<timeout in sec>]
163163
164164 clean_stdin
165165 local _t=$1
@@ -639,7 +639,7 @@ nginx_distro_setup() {
639639 NGINX_DEFAULT_SERVER=/etc/nginx/nginx.conf
640640
641641 # Including *location* directives from a dedicated config-folder into the
642− # server directive is, what what fedora and centos (already) does.
642+ # server directive is, what fedora and centos (already) does.
643643 NGINX_APPS_ENABLED="/etc/nginx/default.d"
644644
645645 # We add a apps-available folder and linking configurations into the
@@ -692,7 +692,7 @@ nginx_reload() {
692692
693693nginx_install_app() {
694694
695− # usage: nginx_install_app [<template option> ...] <myapp>
695+ # usage: nginx_install_app [<template option> ...] <myapp.conf>
696696 #
697697 # <template option>: see install_template
698698
@@ -1381,7 +1381,7 @@ in_container() {
13811381LXC_ENV_FOLDER=
13821382if in_container; then
13831383 # shellcheck disable=SC2034
1384− LXC_ENV_FOLDER="lxc/$(hostname)/"
1384+ LXC_ENV_FOLDER="lxc-env/$(hostname)/"
13851385fi
13861386
13871387lxc_init_container_env() {
@@ -1413,8 +1413,8 @@ LXC_BASE_PACKAGES_centos="bash git python3"
14131413case $DIST_ID in
14141414 ubuntu|debian) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_debian}" ;;
14151415 arch) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_arch}" ;;
1416− fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;;
1417− centos) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_centos}" ;;
1416+ fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;;
1417+ centos) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_centos}" ;;
14181418 *) err_msg "$DIST_ID-$DIST_VERS: pkg_install LXC_BASE_PACKAGES not yet implemented" ;;
14191419esac
14201420
utils/makefile.include+1−1
@@ -5,7 +5,7 @@ PHONY += lxc-activate lxc-purge
55lxc-activate:
66 @$(MAKE) -s -f "$$(dirname $(abspath $(lastword $(MAKEFILE_LIST))))/makefile.lxc" lxc-activate
77lxc-purge:
8− $(Q)rm -rf ./lxc
8+ $(Q)rm -rf ./lxc-env
99else
1010 include /.lxcenv.mk
1111endif
utils/makefile.lxc+5−2
@@ -9,10 +9,10 @@
99# sudo make ./utils/makefile.lxc lxc-activate
1010# sudo make ./utils/makefile.lxc lxc-deactivate
1111
12−LXC_ENV_FOLDER=lxc/$(shell hostname)/
12+LXC_ENV_FOLDER=lxc-env/$(shell hostname)/
1313
1414lxc-help::
15− @echo 'LXC: running in container LXC_ENV_FOLDER=$(LXC_ENV_FOLDER)'
15+ @echo ' LXC: running in container LXC_ENV_FOLDER=$(LXC_ENV_FOLDER)'
1616
1717# If not activated, serve target 'lxc-activate' ..
1818ifeq (,$(wildcard /.lxcenv.mk))
@@ -24,6 +24,9 @@ else
2424PHONY += lxc-deactivate
2525lxc-deactivate:
2626 rm /.lxcenv.mk
27+$(LXC_ENV_FOLDER):
28+ $(Q)mkdir -p $(LXC_ENV_FOLDER)
29+ $(Q)echo placeholder > $(LXC_ENV_FOLDER).placeholder
2730endif
2831
2932.PHONY: $(PHONY)
utils/makefile.python+12−4
@@ -75,7 +75,9 @@ msg-python-exe:
7575 https://www.python.org or install it from your package\n\
7676 manager. On debian based OS these requirements are\n\
7777 installed by::\n\n\
78− sudo -H apt-get install $(PYTHON)\n" | $(FMT)
78+ sudo -H add-apt-repository ppa:deadsnakes/ppa\n\
79+ sudo -H apt update\n\
80+ sudo -H apt-get install $(PYTHON) $(PYTHON)-venv\n"
7981
8082ifeq ($(shell which $(PYTHON) >/dev/null 2>&1; echo $$?), 1)
8183python-exe: msg-python-exe
@@ -95,7 +97,13 @@ quiet_cmd_pyinstall = INSTALL $2
9597
9698# $2 path to folder with setup.py, this uses pip from pyenv (not OS!)
9799quiet_cmd_pyenvinstall = PYENV install $2
98− cmd_pyenvinstall = $(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) install -e $2$(PY_SETUP_EXTRAS)
100+ cmd_pyenvinstall = \
101+ if ! cat $(PY_ENV)/requirements.sha256 2>/dev/null | sha256sum --check --status 2>/dev/null; then \
102+ $(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) install -e $2$(PY_SETUP_EXTRAS) ;\
103+ sha256sum requirements*.txt > $(PY_ENV)/requirements.sha256 ;\
104+ else \
105+ echo "PYENV $2 already installed"; \
106+ fi
99107
100108# Uninstall the package. Since pip does not uninstall the no longer needed
101109# depencies (something like autoremove) the depencies remain.
@@ -113,6 +121,8 @@ quiet_cmd_virtualenv = PYENV usage: $ source ./$@/bin/activate
113121 cmd_virtualenv = \
114122 if [ ! -d "./$(PY_ENV)" ];then \
115123 $(PYTHON) -m venv $(VTENV_OPTS) $2; \
124+ $(PY_ENV_BIN)/python -m pip install $(PIP_VERBOSE) -U pip wheel setuptools; \
125+ $(PY_ENV_BIN)/python -m pip install $(PIP_VERBOSE) -r requirements.txt; \
116126 else \
117127 echo "PYENV using virtualenv from $2"; \
118128 fi
@@ -193,8 +203,6 @@ pyclean:
193203pyenv: $(PY_ENV)
194204$(PY_ENV): python-exe
195205 $(call cmd,virtualenv,$(PY_ENV))
196− $(Q)$(PY_ENV_BIN)/python -m pip install $(PIP_VERBOSE) -U pip wheel pip setuptools
197− $(Q)$(PY_ENV_BIN)/python -m pip install $(PIP_VERBOSE) -r requirements.txt
198206
199207PHONY += pylint-exe
200208pylint-exe: $(PY_ENV)