Skip to content

Commit f6d8780

Browse files
committed
Fix case where compiled extension doesn't exist.
1 parent 89c572c commit f6d8780

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.08.04
1+
20.08.04.2

cppimport/checksum.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@ def calc_cur_checksum(file_lst, module_data):
2424
return hashlib.md5(text).hexdigest()
2525

2626
def load_checksum_trailer(module_data):
27-
with open(module_data['ext_path'], 'rb') as f:
28-
f.seek(-_FMT.size, 2)
29-
json_len, tag = _FMT.unpack(f.read(_FMT.size))
30-
if tag != _TAG:
31-
cppimport.config.quiet_print("Missing trailer tag")
32-
return None, None
33-
f.seek(-(_FMT.size + json_len), 2)
34-
json_s = f.read(json_len)
27+
try:
28+
with open(module_data['ext_path'], 'rb') as f:
29+
f.seek(-_FMT.size, 2)
30+
json_len, tag = _FMT.unpack(f.read(_FMT.size))
31+
if tag != _TAG:
32+
cppimport.config.quiet_print("Missing trailer tag")
33+
return None, None
34+
f.seek(-(_FMT.size + json_len), 2)
35+
json_s = f.read(json_len)
36+
except FileNotFoundError:
37+
cppimport.config.quiet_print("Failed to find compiled extension; rebuilding.")
38+
return None, None
39+
3540
try:
3641
deps, old_checksum = json.loads(json_s)
3742
except ValueError:

0 commit comments

Comments
 (0)