File: 0001-Don-t-fail-when-pyc-files-in-usr-lib-can-t-be-remove.patch

package info (click to toggle)
sasmodels 1.0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,444 kB
  • sloc: python: 26,150; ansic: 8,036; makefile: 150; sh: 50
file content (27 lines) | stat: -rw-r--r-- 1,018 bytes parent folder | download
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