-
Notifications
You must be signed in to change notification settings - Fork 3
/
copy_changed.py
executable file
·38 lines (37 loc) · 1.49 KB
/
copy_changed.py
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
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import os
import shutil
import sys
import zipfile
# Copy any wheels in the ./wheels directory to the ./wheelhouse directory IF
# - the file doesn't exist in the destintation
# - the zip files contain a different number of internal file entries
# - the internal file entries differ in name
# - any of the CRC checksums of the internal file entries differ EXCEPT for
# the records for RECORD and WHEEL. These can change when only the version
# of setuptools changes, which isn't a significant change.
for name in sorted(os.listdir('wheels')):
if not name.endswith('.whl'):
continue
if name in os.listdir('wheelhouse'):
z1 = zipfile.ZipFile(os.path.join('wheels', name))
z2 = zipfile.ZipFile(os.path.join('wheelhouse', name))
if len(z1.infolist()) == len(z2.infolist()):
for entry in z1.infolist():
try:
if entry.CRC != z2.getinfo(entry.filename).CRC:
if entry.filename.rsplit('/')[-1] not in {'WHEEL', 'RECORD'}:
print('differ', entry.filename)
break
except Exception:
print('new file', entry.filename)
break
else:
continue
else:
print('file count')
else:
print('new wheel')
print('Copy', name)
if len(sys.argv) <= 1:
shutil.copy2(os.path.join('wheels', name), os.path.join('wheelhouse', name))