-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcopy_changed.py
More file actions
executable file
·55 lines (54 loc) · 2.18 KB
/
copy_changed.py
File metadata and controls
executable file
·55 lines (54 loc) · 2.18 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
import os
import shutil
import subprocess
import sys
import zipfile
# Copy any wheels in the ./wheels directory to the ./wheelhouse directory IF
# - the file doesn't exist in the destintation
# For GDAL only IF
# - 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')): # noqa
if not name.endswith('.whl'):
continue
committed = set(subprocess.check_output(
['git', '-C', 'wheelhouse', 'ls-tree', '-r', 'HEAD', '--name-only']
).decode().strip().split('\n'))
if 'GDAL' in name:
current_ver = [line.strip().split()[1] for line in open(
'versions.txt').readlines() if line.startswith('gdal ')][0]
if f'-{current_ver}.' not in name:
continue
if 'mapnik' in name:
current_ver = [line.strip().split()[1] for line in open(
'versions.txt').readlines() if line.startswith('mapnik-release')][0]
if f'-{current_ver}.' not in name:
continue
if name in os.listdir('wheelhouse'):
if name in committed:
continue
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))