-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·806 lines (718 loc) · 25.7 KB
/
Copy pathconfigure
File metadata and controls
executable file
·806 lines (718 loc) · 25.7 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
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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
#!/usr/bin/env python
from __future__ import print_function
import argparse, atexit, os, re, shutil, subprocess, sys
DIR = os.path.dirname(os.path.realpath(__file__))
CONF = os.path.join(DIR, 'Make.config')
TMP = os.path.join(DIR, 'configure-tmp')
OPTS = None
LOGFILE = 'configure.log'
LOG = open(LOGFILE, 'w')
g_missing_prereqs = []
g_install_steps = []
g_did_pipcheck = False
class Tee(object):
def __init__(self, stream):
self.term = stream
self.log = LOG
def write(self, msg):
self.term.write(msg)
self.log.write(msg)
def flush(self):
pass
sys.stdout = Tee(sys.stdout)
sys.stderr = Tee(sys.stderr)
@atexit.register
def remove_tmpdir():
rmdir(TMP)
def rmdir(dirname):
if os.path.exists(dirname):
log('Removing %s' % dirname)
shutil.rmtree(dirname)
# Python 2/3 compatibility.
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
if PY2:
input = raw_input
def ensure_str(s):
if type(s) is str:
return s
elif PY2 and isinstance(s, unicode):
return s.encode('utf-8')
elif PY3 and isinstance(s, bytes):
return s.decode('utf-8')
elif PY2:
assert isinstance(s, (unicode, str))
else:
assert isinstance(s, (str, bytes))
return s
# System commands.
def log(msg='', tail='\n'):
LOG.write(msg)
LOG.write(tail)
def say(msg='', tail='\n'):
sys.stdout.write(msg)
sys.stdout.write(tail)
def warn(msg='', tail='\n'):
sys.stderr.write(msg)
sys.stderr.write(tail)
def which(name, path=None):
if path is None:
path = os.environ['PATH'].split(':')
for dirname in path:
dirname = dirname.strip()
filename = os.path.join(dirname, name)
if os.path.exists(filename):
return filename
return
def shell(cmd):
ans = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
return ensure_str(ans).strip()
def shellexec(cmd):
child = subprocess.Popen(cmd, shell=True)
try:
out,err = child.communicate()
except:
child.kill()
raise
try:
retcode = child.wait()
except:
child.kill()
raise
return retcode == os.EX_OK
def commit(settings, variable_name, value, validation=None):
if value is None:
return False
if variable_name is not None:
log('Selecting %s=%r' % (variable_name, value))
for v in (validation or []):
if not v(value):
return False
if settings is not None:
settings[variable_name] = value
return True
def abort(soft=False):
if soft:
warn('\nAborted.')
else:
warn('\nSee %s for details.' % LOGFILE)
warn('\nAborted.')
sys.exit(1)
def abort_python():
warn('\nPython development files could not be located.')
warn('If you are using a package manager, you might need to install one of the -dev packages.')
abort()
def get_options():
global OPTS
parser = argparse.ArgumentParser(
description='Configure Sprite Builds'
, usage='\n configure [-Dfi] [--with...] [--install-prereqs[-only] [--yes] [--pip-nosudo]]'
'\n configure [-Dfi] [--with...] --check-prereqs [--pip-nosudo]'
)
parser.add_argument('-D', '--doc', action='store_true', help='check dependencies needed to build documentation')
parser.add_argument('-f', '--fast', action='store_true', help='skip expensive checks')
parser.add_argument('-i', '--interactive', action='store_true', help='configure interactively')
prereqs = parser.add_argument_group('prerequisite arguments', 'Checks or installs prerequites.')
prereqs.add_argument('--check-prereqs', action='store_true', help='list missing prerequisites but do not install them')
prereqs.add_argument('--install-prereqs', action='store_true', help='install missing prerequisites and configure')
prereqs.add_argument('--install-prereqs-only', action='store_true', help='install missing prerequisites only; '
'do not remove prior builds or write a configuruation file')
prereqs.add_argument('-y', '--yes', action='store_true', help='do not prompt before installing prerequisites')
prereqs.add_argument('--pip-nosudo', action='store_true', help='install Python packages with --user rather than sudo; see pip documentation')
versions = parser.add_argument_group(
'software selection arguments'
, 'Specifies external programs. Program names are taken, in order of '
'preference, from: (1) the command-line arguments below; (2) the '
'environment; (3) the defaults shown below. If the program name is not an '
'absolute path, then PATH will be searched to find the program.'
)
versions.add_argument('--with-cc' , type=str, metavar='gcc', help='specifies the C compiler (env: CC)')
versions.add_argument('--with-cxx' , type=str, metavar='g++', help='specifies the C++ compiler (env: CXX)')
versions.add_argument('--with-cxx-postinstall', type=str, metavar='g++', help='specifies the C++ compiler used after installation (env: CXX)')
versions.add_argument('--with-icurry' , type=str, metavar='icurry', help='specifies the icurry executable (env: ICURRY)')
versions.add_argument('--with-jq' , type=str, metavar='jq', help='specifies the jq executable (env: JQ)')
versions.add_argument('--with-pakcs' , type=str, metavar='pakcs', help='specifies the PAKCS executable (env: PAKCS)')
versions.add_argument('--with-prolog' , type=str, metavar='swipl', help='specifies the Prolog executable (env: PROLOG)')
versions.add_argument('--with-python' , type=str, metavar='python', help='specifies the Python executable (env: PYTHON)')
versions.add_argument('--with-stack' , type=str, metavar='stack', help='specifies the Haskell stack executable (env: STACK)')
dev = parser.add_argument_group('development arguments', 'Enables features for Sprite developers.')
dev.add_argument('--cache', type=str, metavar="['all'|'icurry'|'json']", help='enables caching; useful when the same Curry program will be run many times')
OPTS = parser.parse_args()
OPTS.write_config = not OPTS.check_prereqs and not OPTS.install_prereqs_only
OPTS.install_prereqs = OPTS.install_prereqs or not OPTS.write_config
if OPTS.cache not in [None, 'all', 'icurry', 'json']:
warn('invalid argument to --enable-cache')
warn(' expected %r, %r or %r' % ('all', 'icurry', 'json'))
warn(' got %r' % OPTS.cache)
abort()
# Validation.
def executable(program):
log('Checking whether %s is executable' % program, '...')
ok = os.access(program, os.R_OK | os.X_OK)
log('OK' if ok else 'FAILED')
return ok
def readable(filename):
log('Checking whether %s is readable' % filename, '...')
ok = os.access(filename, os.R_OK)
log('OK' if ok else 'FAILED')
return ok
def readabledir(dirname):
log('Checking whether %s is a readable directory' % dirname, '...')
ok = os.access(dirname, os.R_OK)
ok = ok and os.path.isdir(dirname)
log('OK' if ok else 'FAILED')
return ok
def main():
get_options()
if OPTS.check_prereqs:
say('Checking prerequisites.')
else:
say('Configuring Sprite.')
# Preparation.
os.chdir(DIR)
remove_tmpdir()
os.mkdir(TMP)
if OPTS.write_config:
rmdir(os.path.join(DIR, 'install'))
rmdir(os.path.join(DIR, 'object-root'))
# Determine the settings.
say('*** Finding programs')
try:
settings = {
'ENABLE_ICURRY_CACHE' : int(OPTS.cache in ['all', 'icurry'])
, 'ENABLE_PARSED_JSON_CACHE': int(OPTS.cache in ['all', 'json'])
}
set_from_path(
settings, 'PYTHON', 'python', 'Python installation'
, default=OPTS.with_python
)
set_from_path(settings, 'CC', 'gcc', 'GNU C compiler'
, install_steps=get_build_essential_install_steps
, default=OPTS.with_cc
)
set_from_path(settings, 'CXX', 'g++', 'GNU C++ compiler'
, install_steps=get_build_essential_install_steps
, default=OPTS.with_cxx
)
set_from_path(settings, 'CXX_POSTINSTALL', 'g++', 'GNU C++ compiler'
, install_steps=get_build_essential_install_steps
, default=OPTS.with_cxx_postinstall
)
set_from_path(settings, 'PAKCS', 'pakcs', 'PAKCS executable'
, web='https://www.informatik.uni-kiel.de/~pakcs/download.html'
, altdir='extern/pakcs-3.4.1/bin'
, install_steps=get_pakcs_install_steps
, default=OPTS.with_pakcs
)
set_from_path(settings, 'ICURRY', 'icurry', 'icurry executable'
, web='https://www-ps.informatik.uni-kiel.de/currywiki/tools/cpm'
, hint='try `cypm update; cypm add icurry; cypm install icurry`'
, altdir=os.path.join(os.environ.get('HOME', ''), '.cpm', 'bin')
, install_steps=get_icurry_install_steps
, default=OPTS.with_icurry
)
set_from_path(settings, 'JQ', 'jq', 'jq executable'
, web='https://stedolan.github.io/jq/'
, install_steps=[
'# Install jq.'
, 'sudo apt-get install jq'
]
, default=OPTS.with_jq
)
set_from_path(settings, 'BOOST', 'boost', 'Boost libraries'
, web='https://www.boost.org'
, install_steps=[
'# Install Boost.'
, 'sudo apt-get install libboost-all-dev'
]
, path=['/usr/local/include', '/usr/include']
, validation=[readabledir]
)
if 'PYTHON' in settings:
say('*** Checking Python')
check_python_version(settings)
check_python_modules(settings)
set_python_config(settings)
if 'PAKCS' in settings:
say('*** Checking PAKCS')
set_pakcs_home(settings)
set_pakcs_name(settings)
set_pakcs_version(settings)
if 'ICURRY' in settings and not OPTS.fast:
say('*** Checking ICurry (this takes some time).')
check_icurry(settings)
except KeyboardInterrupt:
abort()
except EOFError:
abort()
if OPTS.check_prereqs:
say()
if g_install_steps or g_missing_prereqs:
say(get_banner('SUMMARY', '='))
say()
say('Missing: %s' % ', '.join(g_missing_prereqs))
say()
say('Installation steps:')
say('(rerun with --install-prereqs[-only] [--yes] to install)')
say()
say('\n'.join(' ' + step for step in g_install_steps))
say()
say('Prerequisite check complete.')
n_prob = len(g_missing_prereqs)
say('Found %s problem%s.' % (n_prob, '' if n_prob == 1 else 's'))
if OPTS.write_config:
# Render the output file.
text = TEMPLATE.format(**settings)
with open(CONF, 'w') as ostream:
ostream.write(text)
say()
say('****** Configuration succeeded! ******')
say('Details logged to %s' % LOGFILE)
say('Configuration written to %s' % CONF)
else:
say()
say('Details logged to %s' % LOGFILE)
say('Configuration NOT written.')
def set_from_path(
settings, variable_name, program_name, desc, web=None, hint=None
, altdir=None, default=None, install_steps=None, path=None
, validation=[executable], allow_interact=True
):
if default is None:
if variable_name is not None:
default = os.environ.get(variable_name)
if default is not None: log("Using default %s=%r from the environment" % (variable_name, default))
if default is None or os.sep not in default:
program_name = program_name if default is None else default
default = which(program_name, path=path)
if default is None and altdir is not None:
default = os.path.join(altdir, program_name)
default = os.path.abspath(default)
if not os.path.exists(default):
default = None
if default is None and web is not None:
more = 'See %s\n' % web
else:
more = ''
if OPTS.interactive and allow_interact:
while True:
value = input('\nPlease specify the %s [%s]\n%s> ' % (desc, default, more))
if not value:
if default is None and OPTS.install_prereqs:
say('%s will be installed. Checking its prerequisites now.' % desc)
break
value = default
if commit(settings, variable_name, value, validation):
return
if default is None:
steps = list(
install_steps(settings) if callable(install_steps) else install_steps
) if install_steps else None
installed = handle_missing_prereq(
program_name
, '%r is required.' % desc
, steps
, web=web
, hint=hint
)
if installed:
set_from_path(
settings, variable_name, program_name, desc, web, hint, altdir
, path=path, validation=validation, allow_interact=False
)
return
if not commit(settings, variable_name, default, validation):
abort()
def check_python_version(settings):
log('Checking the Python version', '...')
vstr = shell(
'''{} -c "import sys; sys.stdout.write('%s.%s.%s' % sys.version_info[:3])"'''
.format(settings['PYTHON'])
)
vtuple = tuple(int(x) for x in vstr.split('.'))
minimum = 2,7,18
if vtuple < minimum:
log('FAILED')
warn('The Python version %s is less than the minimum requirement [%s.%s.%s]' % ((vstr,) + minimum))
abort()
else:
log('%s, OK' % vstr)
if vtuple[0] == 3 and vtuple < (3,5,1):
warn('Sprite has not been tested with Python %s' % vstr)
warn('Consider using Python 2.7.18 or 3.5.1+')
g_num_warnings = 0
def check_python_modules(settings):
modules = [
# module req'd enabled whatfor
# -----------------------------------------------------------------
('json' , True , True , None )
, ('mmap' , True , True , None )
, ('numpy' , False, True , 'for certain tests' )
, ('six' , True , True , None )
, ('sphinx' , True , OPTS.doc , 'to build documentation')
, ('sphinx_rtd_theme', False, OPTS.doc , 'for HTML theming' )
, ('sqlite3' , False, OPTS.cache, 'for caching' )
, ('zlib' , True , True , None )
]
for modname,required,enabled,whatfor in modules:
check_python_module(settings, modname, required, enabled, whatfor)
def ensurepip(settings, required, whatfor):
pyexe = settings['PYTHON']
global g_did_pipcheck
if not g_did_pipcheck:
g_did_pipcheck = True
# if OPTS.pip_nosudo:
# steps = [
# '# Install pip.'
# , '%s -m ensurepip --user' % pyexe
# ]
# else:
# steps = [
# '# Install pip.'
# , 'sudo %s -m ensurepip' % pyexe
# ]
check_python_module(settings, 'pip', required, True, whatfor)
def check_python_module(
settings, modname, required, enabled, whatfor, steps=None
):
pyexe = settings['PYTHON']
try:
if enabled:
log('Checking for module %r' % modname, '...')
shell("""%s -c 'import %s'""" % (pyexe, modname))
log('OK')
except subprocess.CalledProcessError:
log('FAILED')
msg='The Python %r module is %s%s.' % (
modname
, 'required' if required else 'recommended'
, ' %s' % whatfor if whatfor is not None else ''
)
if steps is None:
if OPTS.pip_nosudo:
steps = [
'# Install %s.' % modname
, '%s -m pip --user install %s' % (pyexe, modname)
]
else:
steps = [
'# Install %s.' % modname
, 'sudo %s -m pip install %s' % (pyexe, modname)
]
handle_missing_prereq(
modname, msg, steps, required
, deps=lambda: ensurepip(settings, required, 'to install %s' % modname)
)
settings['HAVE_PYTHON_' + modname] = 0
else:
settings['HAVE_PYTHON_' + modname] = 1
def get_banner(title, char='-', width=80):
title = ' %s ' % title
n = max(3, (width - len(title)) // 2)
return char * n + title + char * n
def handle_missing_prereq(
name, msg, steps=None, required=True, web=None, hint=None
, deps=None
):
global g_num_warnings, g_missing_prereqs, g_install_steps
g_num_warnings += 1
g_missing_prereqs.append(name)
warn()
warn(get_banner('PREREQUISITE ISSUE #%s' % g_num_warnings))
warn()
warn(' ' + msg)
warn()
if steps:
warn(' Suggestion:')
warn('')
for step in steps:
warn(' ' + step)
warn('')
if deps is not None:
deps()
if steps:
g_install_steps += (list(steps) + [''])
if OPTS.check_prereqs:
return False
if OPTS.install_prereqs and steps:
if install(name, steps):
return True
elif not required:
return False
if web is not None:
warn('For installation info, see %s' % web)
if hint is not None:
warn('hint: %s' % hint)
abort()
PYTHON_CONFIG_SCRIPT = \
r'''
from __future__ import print_function
import sys, sysconfig
for val in sysconfig.get_config_vars('CONFINCLUDEPY', 'LIBDIR', 'MULTIARCH', 'INSTSONAME'):
sys.stdout.write(str(val))
sys.stdout.write('\n')
'''
def set_python_config(settings):
scriptname = os.path.join(TMP, 'version_script.py')
with open(scriptname, 'w') as ostream:
ostream.write(PYTHON_CONFIG_SCRIPT)
data = shell('%s %s' % (settings['PYTHON'], scriptname))
include, libdir, multiarch, soname = data.split('\n')
keyfile = os.path.join(include, 'pyconfig.h')
if not commit(settings, 'PYTHON_INCLUDE_PATH', include, [readabledir, lambda _: readable(keyfile)]):
abort_python()
log('Looking for %r' % soname, '...')
pylib = re.match('lib(\S+)\.so', soname).group(1)
for maybe_libdir in [libdir, os.path.join(libdir, multiarch)]:
libfile = os.path.join(maybe_libdir, soname)
if os.access(libfile, os.R_OK):
log('found %s, OK' % libfile)
commit(settings, 'PYTHON_LIBRARY_PATH', maybe_libdir)
commit(settings, 'PYTHON_LIBRARY', pylib)
break
else:
log('FAILED')
abort_python()
def set_pakcs_home(settings):
pakcs = settings['PAKCS']
dirname = os.path.dirname(pakcs)
parent = os.path.join(dirname, '..')
pakcshome = os.path.realpath(parent)
commit(settings, 'PAKCS_HOME', pakcshome, [readabledir])
def set_pakcs_name(settings):
pakcs = settings['PAKCS']
log('Checking the PAKCS compiler name', '...')
name = shell('%s --compiler-name' % pakcs)
ok = (name == 'pakcs')
log('OK' if ok else 'FAILED')
if not ok:
log('The PAKCS Curry system is required.')
abort()
commit(settings, 'PAKCS_NAME', name)
def set_pakcs_version(settings):
pakcs = settings['PAKCS']
GOOD_PAKCS_VERSIONS = ['3.4.1']
log('Checking the PAKCS version', '...')
ver = shell('%s --numeric-version' % pakcs)
ok = ver in GOOD_PAKCS_VERSIONS
log('OK' if ok else 'FAILED')
if not ok:
warn('Acceptable PAKCS versions are: %s' % GOOD_PAKCS_VERSIONS)
abort()
commit(settings, 'PAKCS_VERSION', ver)
def check_icurry(settings):
log('Checking the behavior of the icurry program')
icurry = settings['ICURRY']
filename = os.path.join(TMP, 'sample.curry')
with open(filename, 'w') as ostream:
ostream.write('main :: Int\n')
ostream.write('main = 42\n')
try:
shell('cd %s && %s sample' % (TMP, icurry))
except subprocess.CalledProcessError:
warn('Failed to run icury')
abort()
# Look for the expected files and directories.
currydir = os.path.join(TMP, '.curry')
pakcs_subdir_name = '{PAKCS_NAME}-{PAKCS_VERSION}'.format(**settings)
pakcs_subdir = os.path.join(currydir, pakcs_subdir_name)
if not all([
readabledir(currydir)
, readabledir(pakcs_subdir)
, readable(os.path.join(pakcs_subdir, 'sample.icy'))
]):
abort()
def install(name, steps):
steps = list(steps)
if not OPTS.yes:
warn()
warn('-' * 80)
warn('configure wants to install %r:' % name)
warn()
for step in steps:
warn(' ' + step)
warn()
while True:
warn('(run configure with --yes to skip this question)')
go = input('Continue? [Y/n]> ')
if not go or go in 'yY':
break
elif go in 'nN':
return False
for step in steps:
if step and not step.startswith('#'):
say('% ' + step)
if not shellexec(step):
abort()
return True
def prereq_curl():
set_from_path(None, None, 'curl', 'curl program'
, install_steps=[
'# Install curl.'
, 'sudo apt-get install curl'
]
, allow_interact=False
)
def prereq_cypm(settings):
dirname,pakcs = os.path.split(settings['PAKCS'])
cypm = os.path.join(dirname, 'cypm')
if not executable(cypm):
abort()
return cypm
def prereq_make():
set_from_path(None, None, 'make', 'make program'
, install_steps=get_build_essential_install_steps
, allow_interact=False
)
def prereq_sqlite3():
set_from_path(None, None, 'sqlite3', 'sqlite3 program'
, install_steps=[
'# Install SQLITE.'
, 'sudo apt-get install sqlite'
]
)
def prereq_tar():
set_from_path(None, None, 'tar', 'tar program', allow_interact=False)
def prereq_wget():
set_from_path(None, None, 'wget', 'wget program'
, install_steps=[
'# Install wget.'
, 'sudo apt-get install wget'
]
, allow_interact=False
)
def get_build_essential_install_steps(settings=None):
yield '# Install gcc, g++, make.'
yield 'sudo apt-get install build-essential'
def get_pakcs_install_steps(settings=None):
prereq_make()
prereq_tar()
prereq_wget()
prereq_curl()
set_from_path(None, None, 'swipl', 'Prolog system'
, install_steps=[
'# Install SWI Prolog.'
, 'sudo apt-get install swi-prolog'
]
, default=OPTS.with_prolog
)
set_from_path(None, None, 'stack', 'Haskell Stack'
, install_steps=[
'# Install Haskell Stack.'
, 'wget -qO- https://get.haskellstack.org/ | sh'
]
, default=OPTS.with_stack
)
yield '# Install PAKCS 3.4.1.'
pakcs_dir = 'extern/pakcs-3.4.1'
pakcs_url = 'https://www.informatik.uni-kiel.de/~pakcs/download/pakcs-3.4.1-src.tar.gz'
pakcs_tar = 'extern/pakcs-3.4.1-src.tar.gz'
if not os.path.exists(pakcs_dir):
if not os.path.exists(pakcs_tar):
yield 'wget -P extern --no-clobber %s' % pakcs_url
yield 'tar xvzf %s -C extern' % pakcs_tar
yield 'make -C %s' % pakcs_dir
def get_icurry_install_steps(settings=None):
cypm = prereq_cypm(settings)
prereq_sqlite3()
yield '# Install icurry.'
yield '%s update' % cypm
yield 'cd && %s add icurry' % cypm
yield 'cd && %s install icurry' % cypm
TEMPLATE = '''
# Python Configuration
# ====================
PYTHON_EXECUTABLE := {PYTHON}
PYTHON_INCLUDE_PATH := {PYTHON_INCLUDE_PATH}
PYTHON_LIBRARY_PATH := {PYTHON_LIBRARY_PATH}
PYTHON_LIBRARY := {PYTHON_LIBRARY}
# C/C++ Compilers
# ===============
CC := {CC}
CXX := {CXX}
# Used to compile Curry for the 'cxx' backend.
CXX_POSTINSTALL := {CXX_POSTINSTALL}
ifeq ($(DEBUG),1)
CFLAGS += -O0 -ggdb -Wno-register -Wall
else
CFLAGS += -O2 -Wno-register -Wall
endif
ifeq ($(TRACE),1)
CFLAGS += -DSPRITE_TRACE_ENABLED
endif
CXXFLAGS += $(CFLAGS) -std=c++17
# PAKCS
# =====
# PAKCS is an implementation of Curry that Sprite relies on. Download it from
# https://www.informatik.uni-kiel.de/~pakcs/download.html.
PAKCS := {PAKCS}
PAKCS_HOME := {PAKCS_HOME}
PAKCS_NAME := {PAKCS_NAME}
PAKCS_VERSION := {PAKCS_VERSION}
# ICURRY
# ======
# ICurry is used to convert Curry source code into ICurry. It can be
# downloaded with CPM. See
# https://www-ps.informatik.uni-kiel.de/currywiki/tools/cpm.
ICURRY_EXECUTABLE := {ICURRY}
# MISC
# ====
# JQ is used to compact JSON.
JQ_EXECUTABLE := {JQ}
HAVE_PYTHON_numpy := {HAVE_PYTHON_numpy}
HAVE_PYTHON_sqlite3 := {HAVE_PYTHON_sqlite3}
HAVE_PYTHON_sphinx := {HAVE_PYTHON_sphinx}
# Sprite Configuration
# ====================
# The name of the top-level Python package, e.g., curry in 'import curry'.
PYTHON_PACKAGE_NAME := curry
# The name of the backed used by default. Must match one of the subpackages
# under src/python/backends.
DEFAULT_BACKEND := py
# Caching (development feature)
# =============================
# Sprite can be configured to cache certain steps in the compile chain, such as
# the conversion from Curry to ICurry, or ICurry to Python. This is intended
# for development use, so you should leave it off unless you plan to edit the
# Sprite source and run the unit tests repeatedly. Cached data is stored in an
# SQLite database.
#
# The following environment variables can be used to control
# caching at *runtime*:
#
# SPRITE_CACHE_FILE
# Overrides the default cache file. Setting this to the empty string
# disables caching.
#
# SPRITE_CACHE_UPDATE=<pattern>
# Upates cached data matching the pattern. Everything in the cache is
# keyed by a file name (e.g., of the ICurry file or JSON file), and the
# pattern is compared against these file names. The pattern is a glob
# unless it is enclosed with slashes (/), in which case it is a regular
# expression. Regex patterns are not anchored, so the pattern needs only
# to match some part of the file name.
#
# Examples:
# SPRITE_CACHE_UPDATE='*' -- update everything
# SPRITE_CACHE_UPDATE='*.json' -- update JSON data
# SPRITE_CACHE_UPDATE='/foo\d+/' -- update files associated with
# -- foo00.curry, foo01.curry, etc.
# This specifies the file to use by default for caching. Clear the value to
# disable caching by default. The environment variable SPRITE_CACHE_FILE can
# be used when invoking Sprite to override this or disable caching altogether.
DEFAULT_SPRITE_CACHE_FILE := {{HOME}}/.sprite/cache.db
# Whether to cache Curry-to-ICurry conversions. If True, the cache file will
# store the output of the 'icurry' program keyed on the input filename, source
# text, and CURRYPATH environment variable.
ENABLE_ICURRY_CACHE := {ENABLE_ICURRY_CACHE}
# Whether to cache parsing of ICurry-JSON. If True, the cache file will store
# the result of loading a JSON file into Python. The stored data consists of
# pickled objects from the curry.icurry module.
ENABLE_PARSED_JSON_CACHE := {ENABLE_PARSED_JSON_CACHE}
'''
# MPS
# ===
# Download the Memory Pool System (MPS) from www.ravenbrook.com/project/mps.
# MPS_HOME := /usr/local/src/mps
if __name__ == '__main__':
main()