-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
456 lines (371 loc) · 13.2 KB
/
setup.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
import os
import os.path
import re
import sys
import subprocess
import shutil
import codecs
import json
from pathlib import Path
from setuptools import setup
from setuptools import Command
from setuptools import find_packages
from distutils.command.build import build
from distutils.version import StrictVersion
PY_VER = sys.version_info
if PY_VER >= (3, 6):
pass
else:
print('You need python3.6 or newer')
print('Your python version is {0}'.format(PY_VER))
raise RuntimeError('Invalid python version')
with codecs.open(os.path.join(os.path.abspath(os.path.dirname(
__file__)), 'galacteek', '__version__.py'), 'r', 'latin1') as fp:
try:
version = re.findall(r"^__version__ = '([^']+)'\r?$",
fp.read(), re.M)[0]
except IndexError:
raise RuntimeError('Unable to determine version.')
def run(*args):
p = subprocess.Popen(*args, stdout=subprocess.PIPE)
stdout, err = p.communicate()
return stdout
class build_docs(Command):
user_options = [
("all=", None, "Build all docs"),
]
def initialize_options(self):
self.all = None
def finalize_options(self):
pass
def run(self):
args = [
'sphinx-build', '-b', 'html',
'galacteek/docs/manual/en',
'galacteek/docs/manual/en/html'
]
if self.all:
args.append('-a')
os.system(' '.join(args))
class build_contracts(Command):
user_options = [
("deploy=", None, "Deploy given contracts"),
("contracts=", None, "Contracts list to build"),
("rpcurl=", None, "Ethereum RPC url"),
]
def initialize_options(self):
self.deploy = None
self.contracts = None
self.rpcurl = 'http://127.0.0.1:7545'
def finalize_options(self):
pass
def run(self):
from galacteek.smartcontracts import listContracts
from galacteek.smartcontracts import solCompileFile
from galacteek.smartcontracts import vyperCompileFile
from galacteek.blockchain.ethereum.contract import contractDeploy
from galacteek.blockchain.ethereum.ctrl import web3Connect
cdeploy = [c for c in self.deploy.split(',')] if \
self.deploy else []
w3 = web3Connect(self.rpcurl)
for contract in listContracts():
print('>', contract, contract.dir)
ifacePath = os.path.join(contract.dir, 'interface.json')
if contract.type == 'vyper':
iface = vyperCompileFile(contract.sourcePath)
if not iface:
print('Error compiling vyper contract')
continue
elif contract.type == 'solidity':
compiled = solCompileFile(contract.sourcePath)
if not compiled:
print('Error compiling solidity contract')
continue
contractId, iface = compiled.popitem()
else:
continue
try:
with open(ifacePath, 'w+t') as ifacefd:
ifacefd.write(json.dumps(iface, indent=4))
except Exception as err:
print(str(err))
else:
print(contract.name, 'compiled')
if contract.name in cdeploy:
addr = contractDeploy(w3, iface)
print(contract.name, 'deployed at', addr)
class build_ui(Command):
user_options = [
("tasks=", None, 'Tasks'),
("uiforms=", None, "UI forms list to build, separated by ','"),
("themes=", None, "Themes ','")
]
def initialize_options(self):
self.uiforms = None
self.tasks = 'forms,themes'
self.themes = '*'
# Forms where we don't want to have automatic slots
# connection with connectSlotsByName()
self.uiforms_noSlotConnect = [
Path('galacteek/ui/forms/browsertab.ui'),
Path('galacteek/ui/forms/dagview.ui'),
Path('galacteek/ui/forms/files.ui'),
Path('galacteek/ui/forms/qschemecreatemapping.ui')
]
def finalize_options(self):
pass
def filterUic(self, uifile, uicpath):
if uifile in self.uiforms_noSlotConnect:
print('* {ui}: Removing automatic slots connection'.format(
ui=uifile))
with open(str(uicpath), 'rt') as fd:
code = fd.read()
nCode = re.sub(
r'^\s*QtCore.QMetaObject.connectSlotsByName.*\n$', '',
code,
flags=re.MULTILINE
)
with open(str(uicpath), 'wt') as fd:
print('* {ui}: Rewriting {path}'.format(
ui=uifile, path=uicpath))
fd.write(nCode)
def run(self):
from galacteek.ui.themes import themesCompileAll
uifiles = []
uidir = Path('galacteek/ui')
formsdir = Path('galacteek/ui/forms')
tasks = self.tasks.split(',')
if self.uiforms:
uifiles = [formsdir.joinpath(f'{form}.ui') for form
in self.uiforms.split(',')]
else:
uifiles = formsdir.glob('*.ui')
if 'forms' in tasks:
for uifile in uifiles:
print('* Building UI form:', uifile)
fp_out = formsdir.joinpath(
'ui_{}'.format(
uifile.name.replace('.ui', '.py'))
)
run(['pyuic5',
'--from-imports',
str(uifile),
'-o',
str(fp_out)])
self.filterUic(uifile, fp_out)
run(['pylupdate5', '-verbose', 'galacteek.pro'])
trdir = Path('./share/translations')
lrelease = shutil.which('lrelease-qt5')
if not lrelease:
lrelease = shutil.which('lrelease')
for lang in ['en', 'es', 'fr']:
if lrelease:
run([lrelease,
str(trdir.joinpath(f'galacteek_{lang}.ts')),
'-qm',
str(trdir.joinpath(f'galacteek_{lang}.qm'))])
else:
print('lrelease was not found'
', cannot build translation files')
qrcPath = uidir.joinpath('galacteek.qrc')
qrcCPath = formsdir.joinpath('galacteek_rc.py')
run(['pyrcc5', str(qrcPath), '-o',
str(qrcCPath)])
if 'themes' in tasks:
themesCompileAll()
class build_logo(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
logo = 'share/logos/galacteek.png'
os.system(
f'convert {logo} -resize 50% '
'share/icons/galacteek.png'
)
os.system(
f'convert {logo} -resize 25% '
'share/icons/galacteek-128.png'
)
os.system(
f'convert {logo} -resize 50% '
'share/icons/galacteek.ico'
)
os.system(
'png2icns share/icons/galacteek.icns share/icons/galacteek.png'
)
class vbump(Command):
"""
revbump command
"""
user_options = [
("version=", None, 'Version')
]
def initialize_options(self):
self.version = None
def finalize_options(self):
pass
def run(self):
if not self.version:
raise ValueError('No version specified')
v = StrictVersion(self.version)
assert v.version[0] is not None
assert v.version[1] is not None
assert v.version[2] is not None
with open('galacteek/VERSION', 'wt') as f:
f.write(f'{self.version}\n')
os.system('git add galacteek/VERSION')
with open('galacteek/__version__.py', 'wt') as f:
f.write(f"__version__ = '{self.version}'\n")
os.system('git add galacteek/__version__.py')
with open('packaging/windows/galacteek-installer.nsi',
'rt') as f:
data = f.read()
data = re.sub(
r'(\!define VERSIONMAJOR) (\d*)',
rf'\1 {v.version[0]}',
data
)
data = re.sub(
r'(\!define VERSIONMINOR) (\d*)',
rf'\1 {v.version[1]}',
data
)
data = re.sub(
r'(\!define VERSIONBUILD) (\d*)',
rf'\1 {v.version[2]}',
data
)
with open('packaging/windows/galacteek-installer.nsi',
'wt') as f:
f.write(data)
os.system('git add packaging/windows/galacteek-installer.nsi')
class _build(build):
sub_commands = [('build_ui', None)] + build.sub_commands
with open('README.rst', 'r') as fh:
long_description = fh.read()
deps_links = []
def reqs_parse(path):
reqs = []
deps = []
with open(path) as f:
lines = f.read().splitlines()
for line in lines:
if line.startswith('-e'):
link = line.split().pop()
deps.append(link)
else:
reqs.append(line)
return reqs
install_reqs = reqs_parse('requirements.txt')
install_reqs_extra_markdown = reqs_parse('requirements-extra-markdown.txt')
install_reqs_extra_matplotlib = reqs_parse('requirements-extra-matplotlib.txt')
install_reqs_docs = reqs_parse('requirements-docs.txt')
install_reqs_ui_pyqt_513 = reqs_parse('requirements-ui-pyqt-5.13.txt')
install_reqs_ui_pyqt_515 = reqs_parse('requirements-ui-pyqt-5.15.txt')
install_reqs_ld_schemas = reqs_parse('requirements-ld-schemas.txt')
install_reqs_rdf_bsddb = reqs_parse('requirements-rdf-bsddb.txt')
install_reqs_trafficshaping = reqs_parse('requirements-trafficshaping.txt')
install_reqs_chatgpt = reqs_parse('requirements-chatgpt.txt')
found_packages = find_packages(exclude=['tests', 'tests.*'])
setup(
name='galacteek',
version=version,
license='GPL3',
author='cipres',
author_email='BM-87dtCqLxqnpwzUyjzL8etxGK8MQQrhnxnt1@bitmessage',
url='https://gitlab.com/galacteek/galacteek',
description='Browser for the distributed web',
long_description=long_description,
include_package_data=True,
cmdclass={
'build': _build,
'build_ui': build_ui,
'build_docs': build_docs,
'build_contracts': build_contracts,
'build_logo': build_logo,
'vbump': vbump
},
packages=found_packages,
install_requires=install_reqs,
extras_require={
'ld-schemas': install_reqs_ld_schemas,
'markdown-extensions': install_reqs_extra_markdown,
'ui-pyqt-5.13': install_reqs_ui_pyqt_513,
'ui-pyqt-5.15': install_reqs_ui_pyqt_515,
'rdf-bsddb': install_reqs_rdf_bsddb,
'trafficshaping': install_reqs_trafficshaping,
'matplotlib': install_reqs_extra_matplotlib,
'docs': install_reqs_docs,
'chatgpt': install_reqs_chatgpt
},
dependency_links=deps_links,
package_data={
'': [
'*.yaml',
'*.qss',
'*.css',
'*.qrc',
'*.qml',
'*.jinja2',
'*.rq'
],
'galacteek': [
'docs/manual/en/html/*.html',
'docs/manual/en/html/_images/*',
'docs/manual/en/html/_static/*',
'ipfs/p2pservices/gemini/gem-localhost*',
'ld/contexts/*',
'ld/contexts/messages/*',
'ld/contexts/services/*',
'ui/pyramids/*.zip',
'templates/*.html',
'templates/assets/js/*.js',
'templates/assets/css/*.css',
'templates/ipid/*.html',
'templates/layouts/*',
'templates/ld/*.jinja2',
'templates/ld/components/*/*.jinja2',
'templates/ld/lib/*.jinja2',
'templates/usersite/*.html',
'templates/usersite/assets/*',
'templates/usersite/assets/css/*',
'templates/usersite/macros/*',
'templates/imggallery/*.html',
'hashmarks/default/*.yaml'
]
},
entry_points={
'gui_scripts': [
'galacteek = galacteek.guientrypoint:start'
],
'console_scripts': [
'galacteek-eth-master = galacteek.entrypoints.ethtool:ethTool',
'galacteek-rdfifier = galacteek.entrypoints.rdfifier:rdfifier',
'galacteek-eterna = galacteek.entrypoints.rdfifier:rdfifier'
]
},
classifiers=[
'Environment :: X11 Applications :: Qt',
'Framework :: AsyncIO',
'Topic :: Desktop Environment :: File Managers',
'Topic :: Internet :: WWW/HTTP :: Browsers',
'Development Status :: 4 - Beta',
'Natural Language :: English',
'Operating System :: OS Independent',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Topic :: System :: Filesystems',
'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'
],
keywords=[
'asyncio',
'aiohttp',
'ipfs'
]
)