python/hooks/pythonNamespaces: fix __pycache__ logic
This commit is contained in:
parent
95d9ff16f3
commit
f5d9dd3050
@ -5,6 +5,7 @@
|
|||||||
, disabledIf
|
, disabledIf
|
||||||
, isPy3k
|
, isPy3k
|
||||||
, ensureNewerSourcesForZipFilesHook
|
, ensureNewerSourcesForZipFilesHook
|
||||||
|
, findutils
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -94,7 +95,7 @@ in rec {
|
|||||||
makeSetupHook {
|
makeSetupHook {
|
||||||
name = "python-namespaces-hook.sh";
|
name = "python-namespaces-hook.sh";
|
||||||
substitutions = {
|
substitutions = {
|
||||||
inherit pythonSitePackages;
|
inherit pythonSitePackages findutils;
|
||||||
};
|
};
|
||||||
} ./python-namespaces-hook.sh) {};
|
} ./python-namespaces-hook.sh) {};
|
||||||
|
|
||||||
|
@ -17,17 +17,16 @@ pythonNamespacesHook() {
|
|||||||
for pathSegment in ${pathSegments[@]}; do
|
for pathSegment in ${pathSegments[@]}; do
|
||||||
constructedPath=${constructedPath}/${pathSegment}
|
constructedPath=${constructedPath}/${pathSegment}
|
||||||
pathToRemove=${constructedPath}/__init__.py
|
pathToRemove=${constructedPath}/__init__.py
|
||||||
pycachePath=${constructedPath}/__pycache__/__init__*
|
pycachePath=${constructedPath}/__pycache__/
|
||||||
|
|
||||||
|
# remove __init__.py
|
||||||
if [ -f "$pathToRemove" ]; then
|
if [ -f "$pathToRemove" ]; then
|
||||||
echo "Removing $pathToRemove"
|
rm -v "$pathToRemove"
|
||||||
rm "$pathToRemove"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$pycachePath" ]; then
|
# remove __pycache__/ entry, can be interpreter specific. E.g. __init__.cpython-38.pyc
|
||||||
echo "Removing $pycachePath"
|
# use null characters to perserve potential whitespace in filepath
|
||||||
rm "$pycachePath"
|
@findutils@/bin/find $pycachePath -name '__init__*' -print0 | xargs -0 rm -v
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user