1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
From: Stuart Prescott <stuart@debian.org>
Date: Tue, 4 Feb 2025 20:58:09 +1100
Subject: Don't fail when pyc files in /usr/lib can't be removed
sasview tries to open local_config.py using load_module_from_path() but
local_config.py(c) will be in a read-only location in /usr/lib so this
fails.
---
sasmodels/custom/__init__.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sasmodels/custom/__init__.py b/sasmodels/custom/__init__.py
index 9e7b9b0..054e394 100644
--- a/sasmodels/custom/__init__.py
+++ b/sasmodels/custom/__init__.py
@@ -42,7 +42,10 @@ except ImportError:
del sys.modules[fullname]
if path.endswith(".py") and os.path.exists(path) and os.path.exists(path+"c"):
# remove automatic pyc file before loading a py file
- os.unlink(path+"c")
+ try:
+ os.unlink(path+"c")
+ except:
+ pass
module = imp.load_source(fullname, os.path.expanduser(path))
return module
|