Skip to content

Commit 09105fd

Browse files
committed
Merge remote-tracking branch 'origin/adjust/isolate-python-cache-by-execution-env' into experimental
2 parents b9ecf13 + 759cdb9 commit 09105fd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

envhelp/dpython

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if [ -n "${PY}" ]; then
3737
DOCKER_FILE_SUFFIX="$PYTHON_SUFFIX"
3838
elif [ -n "${PYVER}" ]; then
3939
PY=3
40-
PYTHON_SUFFIX="pyver-$PYVER"
40+
PYTHON_SUFFIX="pyver_$PYVER"
4141
DOCKER_FILE_SUFFIX="pyver"
4242
else
4343
echo "No python version specified - please supply a PY env var"
@@ -61,6 +61,10 @@ PYTHONPATH='/usr/src/app'
6161
# default any variables for container development
6262
MIG_ENV=${MIG_ENV:-'docker'}
6363

64+
# arrange for an explicit python cache hierarhy such that running different
65+
# containers with potentially radically different python APIs do not conflict
66+
PYTHONPYCACHEPREFIX="$PYTHONPATH/envhelp/output/__pycache.${PYTHON_SUFFIX}__"
67+
6468
# determine if the image has changed
6569
echo -n "validating python $PY container.. "
6670

@@ -84,5 +88,6 @@ echo "using image id $IMAGEID"
8488
${DOCKER_BIN} run -it --rm \
8589
--mount "type=bind,source=$MIG_BASE,target=/usr/src/app" \
8690
--env "PYTHONPATH=$PYTHONPATH" \
91+
--env "PYTHONPYCACHEPREFIX=$PYTHONPYCACHEPREFIX" \
8792
--env "MIG_ENV=$MIG_ENV" \
8893
"$IMAGEID" python$PY $@

envhelp/lpython

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ PYTHONPATH=${PYTHONPATH:-"$MIG_BASE"}
4343
# default any variables for local development
4444
MIG_ENV=${MIG_ENV:-'local'}
4545

46-
PYTHONPATH="$PYTHONPATH" MIG_ENV="$MIG_ENV" "$PYTHON_BIN" "$@"
46+
# arrange for an explicit python cache hierarhy - this is primarily done for
47+
# consistency with the dpython script where it is necessary to avoid conflict
48+
PYTHONPYCACHEPREFIX="$PYTHONPATH/envhelp/output/__pycache.${MIG_ENV}__"
49+
50+
PYTHONPATH="$PYTHONPATH" PYTHONPYCACHEPREFIX="$PYTHONPYCACHEPREFIX" MIG_ENV="$MIG_ENV" "$PYTHON_BIN" "$@"

0 commit comments

Comments
 (0)