1 | # -*- mode: python -*- |
---|
2 | |
---|
3 | |
---|
4 | from distutils.sysconfig import get_python_lib |
---|
5 | import hashlib |
---|
6 | import os |
---|
7 | import platform |
---|
8 | import shutil |
---|
9 | import struct |
---|
10 | import sys |
---|
11 | |
---|
12 | |
---|
13 | try: |
---|
14 | import allmydata |
---|
15 | del allmydata |
---|
16 | except ImportError: |
---|
17 | sys.exit("Please run inside a virtualenv with Tahoe-LAFS installed.") |
---|
18 | |
---|
19 | |
---|
20 | options = [('u', None, 'OPTION')] # Unbuffered stdio |
---|
21 | |
---|
22 | added_files = [ |
---|
23 | ('COPYING.*', '.'), |
---|
24 | ('CREDITS', '.'), |
---|
25 | ('relnotes.txt', '.'), |
---|
26 | ('src/allmydata/web/*.xhtml', 'allmydata/web'), |
---|
27 | ('src/allmydata/web/static/*', 'allmydata/web/static'), |
---|
28 | ('src/allmydata/web/static/css/*', 'allmydata/web/static/css'), |
---|
29 | ('src/allmydata/web/static/img/*.png', 'allmydata/web/static/img')] |
---|
30 | |
---|
31 | hidden_imports = [ |
---|
32 | '__builtin__', |
---|
33 | 'allmydata.client', |
---|
34 | 'allmydata.introducer', |
---|
35 | 'allmydata.stats', |
---|
36 | 'base64', |
---|
37 | 'cffi', |
---|
38 | 'charset_normalizer.md__mypyc', |
---|
39 | 'collections', |
---|
40 | 'commands', |
---|
41 | 'Crypto', |
---|
42 | 'functools', |
---|
43 | 'future.backports.misc', |
---|
44 | 'itertools', |
---|
45 | 'math', |
---|
46 | 'packaging.specifiers', |
---|
47 | 're', |
---|
48 | 'reprlib', |
---|
49 | 'six.moves.html_parser', |
---|
50 | 'subprocess', |
---|
51 | 'UserDict', |
---|
52 | 'UserList', |
---|
53 | 'UserString', |
---|
54 | 'yaml', |
---|
55 | 'zfec', |
---|
56 | ] |
---|
57 | |
---|
58 | a = Analysis( |
---|
59 | ['static/tahoe.py'], |
---|
60 | pathex=[], |
---|
61 | binaries=None, |
---|
62 | datas=added_files, |
---|
63 | hiddenimports=hidden_imports, |
---|
64 | hookspath=[], |
---|
65 | runtime_hooks=[], |
---|
66 | excludes=[], |
---|
67 | win_no_prefer_redirects=False, |
---|
68 | win_private_assemblies=False, |
---|
69 | cipher=None) |
---|
70 | |
---|
71 | pyz = PYZ( |
---|
72 | a.pure, |
---|
73 | a.zipped_data, |
---|
74 | cipher=None) |
---|
75 | |
---|
76 | exe = EXE( |
---|
77 | pyz, |
---|
78 | a.scripts, |
---|
79 | options, |
---|
80 | exclude_binaries=True, |
---|
81 | name='tahoe', |
---|
82 | debug=False, |
---|
83 | strip=False, |
---|
84 | upx=False, |
---|
85 | console=True) |
---|
86 | |
---|
87 | coll = COLLECT( |
---|
88 | exe, |
---|
89 | a.binaries, |
---|
90 | a.zipfiles, |
---|
91 | a.datas, |
---|
92 | strip=False, |
---|
93 | upx=False, |
---|
94 | name='Tahoe-LAFS') |
---|
95 | |
---|
96 | |
---|
97 | print("Creating archive...") |
---|
98 | platform_tag = platform.system().replace('Darwin', 'MacOS') |
---|
99 | bitness_tag = str(struct.calcsize('P') * 8) + 'bit' |
---|
100 | archive_name = 'Tahoe-LAFS-{}-{}'.format(platform_tag, bitness_tag) |
---|
101 | if sys.platform == 'win32': |
---|
102 | archive_format = 'zip' |
---|
103 | archive_suffix = '.zip' |
---|
104 | else: |
---|
105 | archive_format = 'gztar' |
---|
106 | archive_suffix = '.tar.gz' |
---|
107 | base_name = os.path.join('dist', archive_name) |
---|
108 | shutil.make_archive(base_name, archive_format, 'dist', 'Tahoe-LAFS') |
---|
109 | |
---|
110 | print("Hashing (SHA256)...") |
---|
111 | archive_path = base_name + archive_suffix |
---|
112 | hasher = hashlib.sha256() |
---|
113 | with open(archive_path, 'rb') as f: |
---|
114 | for block in iter(lambda: f.read(4096), b''): |
---|
115 | hasher.update(block) |
---|
116 | print("{} {}".format(hasher.hexdigest(), archive_path)) |
---|