about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh')
-rw-r--r--nixpkgs/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh13
1 files changed, 7 insertions, 6 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh b/nixpkgs/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh
index 50f21819d176..15d2bd0eb34c 100644
--- a/nixpkgs/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh
+++ b/nixpkgs/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh
@@ -17,16 +17,17 @@ pythonNamespacesHook() {
         for pathSegment in ${pathSegments[@]}; do
             constructedPath=${constructedPath}/${pathSegment}
             pathToRemove=${constructedPath}/__init__.py
-            pycachePath=${constructedPath}/__pycache__/__init__*
+            pycachePath=${constructedPath}/__pycache__/
 
+            # remove __init__.py
             if [ -f "$pathToRemove" ]; then
-                echo "Removing $pathToRemove"
-                rm "$pathToRemove"
+                rm -v "$pathToRemove"
             fi
 
-            if [ -f "$pycachePath" ]; then
-                echo "Removing $pycachePath"
-                rm "$pycachePath"
+            # remove __pycache__/ entry, can be interpreter specific. E.g. __init__.cpython-38.pyc
+            # use null characters to perserve potential whitespace in filepath
+            if [ -d "$pycachePath" ]; then
+                @findutils@/bin/find "$pycachePath" -name '__init__*' -exec rm -v "{}" +
             fi
         done
     done