/
installCode.py
1971 lines (1577 loc) · 59.7 KB
/
installCode.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
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
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import glob
import os
import re
import shutil
import subprocess
import sys
ccpnmr_major = 2
ccpnmr_minor = 4
ccpnmr_version = '%d.%d' % (ccpnmr_major, ccpnmr_minor)
api_distribution = 'api'
format_distribution = 'format'
analysis_distribution = 'analysis'
extend_nmr_distribution = 'extendNmr'
backup_suffix = '.bak'
distributions = (api_distribution, format_distribution, analysis_distribution, extend_nmr_distribution)
top_dir = os.getcwd()
distribution = 'analysis'
program_name = None
program_names = { \
api_distribution: 'Api',
format_distribution: 'Format Converter',
analysis_distribution: 'Analysis',
extend_nmr_distribution: 'ExtendNmr',
}
tcl_tk_platform = 'unix' # needed for Tcl/Tk
bin_rel_dir = 'bin'
ccpnmr_rel_dir = 'ccpnmr%s' % ccpnmr_version
#tcltk_version = '8.3'
#tcltk_release = '8.3.4'
#tcltk_version = '8.4'
#tcltk_release = '8.4.14'
#tcltk_version = '8.5'
#tcltk_release = '8.5.4'
#tcltk_release = '8.5.8'
tcltk_version = '8.6'
tcltk_release = '8.6.3'
tcl_rel_dir = 'tcl%s' % tcltk_version
tcl_tar_dir = 'tcl%s' % tcltk_release
tcl_tar_file = tcl_tar_dir + '.tar'
tcl_tar_file_gz = tcl_tar_file + '.gz'
tk_rel_dir = 'tk%s' % tcltk_version
tk_tar_dir = 'tk%s' % tcltk_release
tk_tar_file = tk_tar_dir + '.tar'
tk_tar_file_gz = tk_tar_file + '.gz'
tix_version = '8.4'
tix_release = '8.4.3'
tix_rel_dir = 'tix%s' % tix_version
tix_tar_dir = 'Tix%s' % tix_release
tix_tar_file = tix_tar_dir + '.tar'
tix_tar_file_gz = tix_tar_file + '.gz'
#min_python_version = '2.2'
min_python_version = '2.4'
#python_version = '2.2'
#python_release = '2.2.3'
#python_version = '2.4'
#python_release = '2.4.2'
#python_version = '2.5'
#python_release = '2.5.2'
#python_version = '2.6'
#python_release = '2.6.5'
python_version = '2.7'
python_release = '2.7.9'
python_rel_dir = 'python%s' % python_version
python_tar_dir = 'Python-%s' % python_release
python_tar_file = python_tar_dir + '.tar'
python_tar_file_gz = python_tar_dir + '.tgz'
element_tree_rel_dir = 'elementTree'
element_tree_tar_dir = 'elementtree-1.2.6-20050316'
element_tree_tar_file = element_tree_tar_dir + '.tar'
element_tree_tar_file_gz = element_tree_tar_file + '.gz'
#numpy_version = '1.2'
#numpy_release = '1.2.1'
#numpy_version = '1.4'
#numpy_release = '1.4.1'
numpy_version = '1.9'
numpy_release = '1.9.2'
numpy_rel_dir = 'numpy%s' % numpy_version
numpy_tar_dir = 'numpy-%s' % numpy_release
numpy_tar_file = numpy_tar_dir + '.tar'
numpy_tar_file_gz = numpy_tar_file + '.gz'
mesa_version = '6.0'
mesa_release = '6.0'
mesa_rel_dir = 'mesa%s' % mesa_version
mesa_prefix = 'Mesa'
mesa_tar_dir = '%s-%s' % (mesa_prefix, mesa_release)
mesa_tar_file1 = '%sLib-%s.tar' % (mesa_prefix, mesa_release)
mesa_tar_file1_gz = mesa_tar_file1 + '.gz'
mesa_tar_file2 = '%sDemos-%s.tar' % (mesa_prefix, mesa_release)
mesa_tar_file2_gz = mesa_tar_file2 + '.gz'
possible_platforms = ('linux', 'irix', 'sunos', 'darwin')
# too many choices for irix and sunos to make a guess
comp_arch_guess = { \
'linux': ('linux-x86', 'Linux on a PC'),
'darwin': ('darwin', 'Mac OSX'),
}
mesa_comp_arch_msg = """
aix for AIX systems with xlc
aix-sl for AIX systems, make shared libs
aix-gcc for AIX sytems with gcc
beos-r4 for BeOS R4
cygnus for Win95/NT using Cygnus-Win32
cygnus-linux for Win95/NT using Cygnus-Win32 under Linux
darwin for Darwin - Mac OS X
freebsd for FreeBSD systems with GCC
freebsd-386 for FreeBSD systems with GCC, w/ Intel assembly
gcc-sl for a generic system with GCC for shared libs
hpux9 for HP systems with HPUX 9.x
hpux9-sl for HP systems with HPUX 9.x, make shared libs
hpux9-gcc for HP systems with HPUX 9.x using GCC
hpux9-gcc-sl for HP systems with HPUX 9.x, GCC, make shared libs
hpux10 for HP systems with HPUX 10.x and 11.x
hpux10-sl for HP systems with HPUX 10.x and 11.x, shared libs
hpux10-gcc for HP systems with HPUX 10.x w/ GCC
hpux10-gcc-sl for HP systems with HPUX 10.x w/ GCC, shared libs
irix6-o32 for SGI systems with IRIX 6.x, make o32-bit libs
irix6-o32-dso for SGI systems with IRIX 6.x, make o32-bit DSOs
irix6-n32 for SGI systems with IRIX 6.x, make n32-bit libs
irix6-n32-dso for SGI systems with IRIX 6.x, make n32-bit DSOs
irix6-gcc-n32-sl for SGI systems with IRIX 6.x, GCC, make n32 DSOs
irix6-64 for SGI systems with IRIX 6.x, make 64-bit libs
irix6-64-dso for SGI systems with IRIX 6.x, make 64-bit DSOs
linux for Linux
linux-x86 for Linux with x86 optimizations
linux-ggi for Linux with libggi driver
linux-x86-ggi for Linux with libggi driver and x86 optimizations
linux-glide for Linux with 3Dfx Glide driver
linux-x86-glide for Linux with 3Dfx Glide driver and x86 opts
linux-alpha for Linux with Alpha optimizations
linux-alpha-static for Linux with Alpha opts, make static libs
linux-ppc for Linux with PowerPC opts
linux-ppc-static for Linux with PowerPC opts, make static libs
linux-sparc for Linux with Sparc optimzations
linux-sparc5 for Linux with Sparc5 optimizations
linux-sparc-ultra for Linux with UltraSparc optimizations
linux-osmesa16 for 16-bit/channel OSMesa
linux-osmesa16-static for 16-bit/channel OSMesa, make static libs
linux-osmesa32 for 32-bit/channel OSMesa
linux-solo for Linux standalone with DRI drivers
linux-icc for Linux with the Intel C/C++ compiler
lynxos for LynxOS systems with GCC
mklinux for Linux on Power Macintosh
netbsd for NetBSD 1.0 systems with GCC
openbsd for OpenBSD systems
openstep for OpenStep/MacOSX Server systems
osf1 for DEC Alpha systems with OSF/1
qnx for QNX V4 systems with Watcom compiler
solaris-x86 for PCs with Solaris
solaris-x86-gcc for PCs with Solaris using GCC
sunos4 for Suns with SunOS 4.x
sunos4-sl for Suns with SunOS 4.x, make shared libs
sunos4-gcc for Suns with SunOS 4.x and GCC
sunos4-gcc-sl for Suns with SunOS 4.x, GCC, make shared libs
sunos5 for Suns with SunOS 5.x
sunos5-smp for Suns with SunOS 5.x, SMP optimization
sunos5-gcc for Suns with SunOS 5.x and GCC
sunos5-gcc-debug for Suns with SunOS 5.x and GCC
ultrix-gcc for DEC systems with Ultrix and GCC
unixware for PCs running UnixWare
unixware-shared for PCs running UnixWare, shared libs
"""
mesa_comp_arch = []
s = mesa_comp_arch_msg.split('\n')[1:-1]
for x in s:
mesa_comp_arch.append(x.split()[0])
format_program = 'formatConverter'
data_shifter_program = 'dataShifter'
analysis_program = 'analysis'
eci_program = 'eci'
deposition_program = 'depositionFileImporter'
extend_nmr_program = 'extendNmr'
dangle_program = 'dangle'
pipe2azara_program = 'pipe2azara'
xeasy2azara_program = 'xeasy2azara'
updateCode_program = 'updateCheck'
updateAuto_program = 'updateAll'
python_program = 'python'
share_suffix = 'so'
fp_log = None
def runCmds(cmds):
cmd = ';'.join(cmds)
#print 'COMMAND =', cmd
os.system(cmd)
def writeLog(message):
if (fp_log):
fp_log.write('%s\n' % message)
def doPrint(message):
print message
writeLog(message)
def getInput(prompt, doLower = 1, default = None):
s = ''
while (not s):
s = raw_input(prompt + ' ')
s = s.strip()
if (not s and default is not None):
s = default
writeLog('%s %s' % (prompt, s))
if (doLower):
s = s.lower()
return s
def getPlatform():
platform = sys.platform
flag = 0
for p in possible_platforms:
if (platform.find(p) >= 0):
platform = p
doPrint('Assuming your platform is %s' % platform)
flag = 1
break
if (not flag):
s = getInput('Cannot figure out your platform, is it one of %s (y or n)?' % (possible_platforms,))
if (s == 'y'):
while (platform not in possible_platforms):
platform = getInput('Which platform (%s)?:' % (possible_platforms,))
else:
#doPrint('Unknown platform, there will probably be problems')
platform = None
return platform
def getShell():
shell = 'sh'
for dir in ('/bin', '/usr/bin'):
ss = '%s/%s' % (dir, shell)
if os.path.exists(ss):
break
else:
shell = os.environ.get('SHELL')
if shell:
n = shell.rfind('/')
if n >= 0:
shell = shell[n+1:]
else:
shell = 'csh' # hopefully always exists if sh does not
return shell
def setStandardCodeDict(codeDict, directory, version = None):
codeDict['directory'] = directory
if version:
codeDict['version'] = version
for key in ('include', 'lib'):
codeDict[key] = key
def haveTclTarFile():
return os.path.exists(os.path.join(tcl_rel_dir, tcl_tar_file_gz)) \
or os.path.exists(os.path.join(tcl_rel_dir, tcl_tar_file))
def haveTclFiles():
# checks that platform code directory exists, nothing else
if os.path.exists(os.path.join(tcl_rel_dir, tcl_tar_dir, tcl_tk_platform)):
return True
else:
return False
def unpackTcl():
os.chdir(tcl_rel_dir)
cmds = []
if os.path.exists(tcl_tar_dir):
cmds.append('rm -rf %s' % tcl_tar_dir)
for dir in ('bin', 'include', 'lib', 'man'):
if (os.path.exists(dir)):
cmds.append('rm -rf %s' % dir)
if (os.path.exists(tcl_tar_file_gz)):
cmds.append('gunzip %s' % tcl_tar_file_gz)
# else assume it has already been gunzipped
cmds.append('tar xvf %s' % tcl_tar_file)
cmds.append('gzip %s' % tcl_tar_file)
runCmds(cmds)
#os.chdir('..')
os.chdir(top_dir)
def compileTcl():
os.chdir(os.path.join(tcl_rel_dir, tcl_tar_dir, tcl_tk_platform))
platform = getPlatform()
flags = ''
if platform == 'darwin':
flags = ' --enable-threads --enable-shared --disable-corefoundation'
n = int(os.uname()[2].split('.')[0])
if n >= 10: # OSX >= 10.6 (Snow Leopard)
flags += ' --enable-64bit'
cmds = []
cmds.append('./configure --prefix=%s/%s%s' % (top_dir, tcl_rel_dir, flags))
cmds.append('make')
cmds.append('make install')
runCmds(cmds)
#os.chdir('../../..')
os.chdir(top_dir)
def haveTkTarFile():
return os.path.exists(os.path.join(tk_rel_dir, tk_tar_file_gz)) \
or os.path.exists(os.path.join(tk_rel_dir, tk_tar_file))
def haveTkFiles():
# checks that platform code directory exists, nothing else
if os.path.exists(os.path.join(tk_rel_dir, tk_tar_dir, tcl_tk_platform)):
return True
else:
return False
def unpackTk():
os.chdir(tk_rel_dir)
cmds = []
if (os.path.exists(tk_tar_dir)):
cmds.append('rm -rf %s' % tk_tar_dir)
for dir in ('bin', 'include', 'lib', 'man'):
if (os.path.exists(dir)):
cmds.append('rm -rf %s' % dir)
if (os.path.exists(tk_tar_file_gz)):
cmds.append('gunzip %s' % tk_tar_file_gz)
# else assume it has already been gunzipped
cmds.append('tar xvf %s' % tk_tar_file)
cmds.append('gzip %s' % tk_tar_file)
runCmds(cmds)
#os.chdir('..')
os.chdir(top_dir)
def compileTk(tcl_lib_dir):
os.chdir(os.path.join(tk_rel_dir, tk_tar_dir, tcl_tk_platform))
platform = getPlatform()
flags = ''
if platform == 'darwin':
flags = ' --enable-threads --enable-shared --disable-corefoundation'
n = int(os.uname()[2].split('.')[0])
if n >= 10: # OSX >= 10.6 (Snow Leopard)
flags += ' --enable-64bit'
cmds = []
cmds.append('./configure --prefix=%s/%s --with-tcl=%s%s' % (top_dir, tk_rel_dir, tcl_lib_dir, flags))
cmds.append('make')
cmds.append('make install')
runCmds(cmds)
#os.chdir('../../..')
os.chdir(top_dir)
def haveTixTarFile():
return os.path.exists(os.path.join(tix_rel_dir, tix_tar_file_gz)) \
or os.path.exists(os.path.join(tix_rel_dir, tix_tar_file))
def haveTixFiles():
if os.path.exists(os.path.join(tix_rel_dir, tix_tar_dir)):
return True
else:
return False
def unpackTix():
os.chdir(tix_rel_dir)
cmds = []
if os.path.exists(tix_tar_dir):
cmds.append('rm -rf %s' % tix_tar_dir)
if (os.path.exists(tix_tar_file_gz)):
cmds.append('gunzip %s' % tix_tar_file_gz)
# else assume it has already been gunzipped
cmds.append('tar xvf %s' % tix_tar_file)
cmds.append('gzip %s' % tix_tar_file)
runCmds(cmds)
os.chdir(top_dir)
def compileTix(softwareDict):
x11CodeDict = softwareDict['X11']
x11_abs_dir = x11CodeDict.get('directory')
x11_inc_dir = x11CodeDict['include']
x11_inc_dir = os.path.join(x11_abs_dir, x11_inc_dir)
x11_lib_dir = x11CodeDict['lib']
x11_lib_dir = os.path.join(x11_abs_dir, x11_lib_dir)
tclCodeDict = softwareDict['Tcl']
tcl_abs_dir = tclCodeDict.get('directory')
tcl_lib_dir = tclCodeDict['lib']
tcl_lib_dir = os.path.join(tcl_abs_dir, tcl_lib_dir)
tcltk_version = tclCodeDict['version']
tkCodeDict = softwareDict['Tk']
tk_abs_dir = tkCodeDict.get('directory')
tk_lib_dir = tkCodeDict['lib']
tk_lib_dir = os.path.join(tk_abs_dir, tk_lib_dir)
os.chdir(os.path.join(tix_rel_dir, tix_tar_dir))
platform = getPlatform()
flags = ''
if platform == 'darwin':
flags = ' --enable-threads --enable-shared --disable-corefoundation'
n = int(os.uname()[2].split('.')[0])
if n >= 10: # OSX >= 10.6 (Snow Leopard)
flags += ' --enable-64bit'
if tcltk_version == '8.6':
flags += ' CC="gcc -DUSE_INTERP_RESULT -DUSE_INTERP_ERRORLINE"'
cmds = []
cmds.append('./configure --prefix=%s/%s --with-tcl=%s --with-tk=%s --x-includes=%s --x-libraries=%s %s' % (top_dir, tix_rel_dir, tcl_lib_dir, tk_lib_dir, x11_inc_dir, x11_lib_dir, flags))
cmds.append('make')
cmds.append('make install')
runCmds(cmds)
os.chdir(top_dir)
def havePythonTarFile():
return os.path.exists(os.path.join(python_rel_dir, python_tar_file_gz)) \
or os.path.exists(os.path.join(python_rel_dir, python_tar_file))
def havePythonFiles():
# checks that code directory exists, nothing else
if os.path.exists(os.path.join(python_rel_dir, python_tar_dir)):
return True
else:
return False
def unpackPython():
os.chdir(python_rel_dir)
cmds = []
if (os.path.exists(python_tar_dir)):
cmds.append('rm -rf %s' % python_tar_dir)
for dir in ('bin', 'include', 'lib', 'man'):
if (os.path.exists(dir)):
cmds.append('rm -rf %s' % dir)
if (os.path.exists(python_tar_file_gz)):
cmds.append('gunzip %s' % python_tar_file_gz)
# else assume it has already been gunzipped
cmds.append('tar xvf %s' % python_tar_file)
cmds.append('gzip %s' % python_tar_file)
cmds.append('mv %s.gz %s' % (python_tar_file, python_tar_file_gz))
runCmds(cmds)
#os.chdir('..')
os.chdir(top_dir)
def findFile(directory, pattern):
pattern = os.path.join(directory, pattern)
result = glob.glob(pattern)
if result:
result = '/' + os.path.basename(os.path.dirname(result[0]))
else:
result = ''
return result
def compilePython(softwareDict):
os.chdir(python_rel_dir + '/' + python_tar_dir)
codeDict = softwareDict['X11']
x11_abs_dir = codeDict.get('directory')
platform = getPlatform()
bits = softwareDict['bits']
built_by = os.environ.get('USER', 'unknown')
if x11_abs_dir:
# need to create Modules/Setup so that our Tcl/Tk found
x11_inc_dir = codeDict['include']
x11_lib_dir = codeDict['lib']
codeDict = softwareDict['Tcl']
tcl_abs_dir = codeDict.get('directory')
tcl_inc_dir = codeDict['include']
tcl_lib_dir = codeDict['lib']
tcltk_version = codeDict['version']
codeDict = softwareDict['Tk']
tk_abs_dir = codeDict.get('directory')
tk_inc_dir = codeDict['include']
tk_lib_dir = codeDict['lib']
codeDict = softwareDict['Tix']
tix_abs_dir = codeDict.get('directory', '')
tix_lib_dir = codeDict.get('lib', '')
if tix_abs_dir and tix_lib_dir:
tix_stuff = '-L%s \\\n\t-DWITH_TIX -lTix%s \\\n\t' % (os.path.join(tix_abs_dir, tix_lib_dir), tix_release)
else:
tix_stuff = ''
fp = open('Modules/Setup.dist')
lines = fp.readlines()
fp.close()
fp = open('Modules/Setup.dist', 'w')
s = '# The _tkinter module.'
t = '#SSL=/usr/local/ssl'
n = len(s)
m = len(t)
for line in lines:
fp.write(line)
if (line[:n] == s):
fp.write('''
# lines below added in by CcpNmr installation script
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \\
-L%s/%s -L%s/%s -L%s/%s \\
-I%s/%s -I%s/%s -I%s/%s \\
%s-ltcl%s -ltk%s -lX11
# lines above added in by CcpNmr installation script
''' % (tcl_abs_dir, tcl_lib_dir, tk_abs_dir, tk_lib_dir, x11_abs_dir, x11_lib_dir,
tcl_abs_dir, tcl_inc_dir, tk_abs_dir, tk_inc_dir, x11_abs_dir, x11_inc_dir,
tix_stuff, tcltk_version, tcltk_version))
elif (platform == 'linux') and (bits == 64) and (built_by == 'wb104') and (line[:m] == t): # 2015 Feb 24 hack to get ssl compilation to work on hydra (also needed to edit out SSL2 stuff from Python source code: see http://blog.schmichael.com/2012/05/29/building-python-2-6-8-on-ubuntu-12-04/, although 2.6.5 is somewhat different)
fp.write('''
# lines below added in by CcpNmr installation script
SSL=/usr
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
_hashlib _hashopenssl.c
''')
fp.close()
# now compile and install code
flags = ''
if platform == 'darwin':
flags = ' --enable-threads --disable-toolbox-glue --disable-framework'
cmds = []
cmds.append('./configure --prefix=%s/%s%s' % (top_dir, python_rel_dir, flags))
cmds.append('make')
cmds.append('make install')
runCmds(cmds)
#os.chdir('../..')
os.chdir(top_dir)
def haveElementTreeTarFile():
return os.path.exists(os.path.join(element_tree_rel_dir, element_tree_tar_file_gz)) \
or os.path.exists(os.path.join(element_tree_rel_dir, element_tree_tar_file))
def unpackElementTree():
os.chdir(element_tree_rel_dir)
cmds = []
if (os.path.exists(element_tree_tar_dir)):
cmds.append('rm -rf %s' % element_tree_tar_dir)
if (os.path.exists(element_tree_tar_file_gz)):
cmds.append('gunzip %s' % element_tree_tar_file_gz)
# else assume it has already been gunzipped
cmds.append('tar xvf %s' % element_tree_tar_file)
cmds.append('gzip %s' % element_tree_tar_file)
runCmds(cmds)
#os.chdir('..')
os.chdir(top_dir)
def haveNumpyTarFile():
return os.path.exists(os.path.join(numpy_rel_dir, numpy_tar_file_gz)) \
or os.path.exists(os.path.join(numpy_rel_dir, numpy_tar_file))
def haveNumpyFiles():
# checks that platform code directory exists, nothing else
if os.path.exists(os.path.join(numpy_rel_dir, numpy_tar_dir)):
return True
else:
return False
def unpackNumpy():
os.chdir(numpy_rel_dir)
cmds = []
if (os.path.exists(numpy_tar_dir)):
cmds.append('rm -rf %s' % numpy_tar_dir)
if (os.path.exists(numpy_tar_file_gz)):
cmds.append('gunzip %s' % numpy_tar_file_gz)
# else assume it has already been gunzipped
cmds.append('tar xvf %s' % numpy_tar_file)
cmds.append('gzip %s' % numpy_tar_file)
runCmds(cmds)
#os.chdir('..')
os.chdir(top_dir)
def compileNumpy(python_bin_dir, py_version):
os.chdir(os.path.join(numpy_rel_dir, numpy_tar_dir))
python_exe = '%s/bin/python%s' % (python_bin_dir, py_version)
if not os.path.exists(python_exe):
python_exe = '%s/bin/python' % python_bin_dir
if not os.path.exists(python_exe):
doPrint('Could not find "%s%s" nor "%s" so giving up trying to compile numpy' % (python_exe, py_version, python_exe))
cmds = []
cmds.append('%s setup.py install' % python_exe)
runCmds(cmds)
#os.chdir('../..')
os.chdir(top_dir)
def haveMesaTarFiles():
return (os.path.exists(os.path.join(mesa_rel_dir, mesa_tar_file1_gz))
or os.path.exists(os.path.join(mesa_rel_dir, mesa_tar_file1))) \
and (os.path.exists(os.path.join(mesa_rel_dir, mesa_tar_file2_gz)) \
or os.path.exists(os.path.join(mesa_rel_dir, mesa_tar_file2)))
def haveMesaFiles():
# checks that code directory exists, nothing else
if os.path.exists(os.path.join(mesa_rel_dir, mesa_tar_dir)):
return True
else:
return False
def unpackMesa():
os.chdir(mesa_rel_dir)
cmds = []
if (os.path.exists(mesa_tar_dir)):
cmds.append('rm -rf %s' % mesa_tar_dir)
for dir in ('etc', 'include', 'lib'):
if (os.path.exists(dir)):
cmds.append('rm -rf %s' % dir)
if (os.path.exists(mesa_tar_file1_gz)):
cmds.append('gunzip %s' % mesa_tar_file1_gz)
# else assume it has already been gunzipped
cmds.append('tar xvf %s' % mesa_tar_file1)
if (os.path.exists(mesa_tar_file2_gz)):
cmds.append('gunzip %s' % mesa_tar_file2_gz)
# else assume it has already been gunzipped
cmds.append('tar xvf %s' % mesa_tar_file2)
cmds.append('gzip %s' % mesa_tar_file1)
cmds.append('gzip %s' % mesa_tar_file2)
runCmds(cmds)
#os.chdir('..')
os.chdir(top_dir)
def getCompArch(platform):
if (platform):
(comp_arch, comp_msg) = comp_arch_guess.get(platform, '')
else:
comp_arch = ''
if (comp_arch):
s = getInput('Is your computer %s (%s) (y or n)?' % (comp_arch, comp_msg))
else:
s = 'n'
if (s[0] == 'n'):
doPrint('Possible Mesa architecture compilations:')
doPrint(mesa_comp_arch_msg)
comp_arch = getInput('Which is the most appropriate architecture for your computer?', doLower=0)
while (comp_arch not in mesa_comp_arch):
doPrint('That architecture not on list, try again')
comp_arch = getInput('Which is the most appropriate architecture for your computer?', doLower=0)
return comp_arch
def compileMesa(comp_arch):
os.chdir(mesa_rel_dir + '/' + mesa_tar_dir)
# Mesa compilation changed between v4.0 and v6.0
cmds = []
#cmds.append('./configure --prefix=%s/%s' % (top_dir, mesa_rel_dir))
#cmds.append('make')
#cmds.append('make install')
cmds.append('make %s' % comp_arch)
runCmds(cmds)
os.chdir('..')
for dir in ('include', 'lib'):
os.symlink('%s/%s' % (mesa_tar_dir, dir), dir)
#os.chdir('..')
os.chdir(top_dir)
def createEnvironmentFile(platform, softwareDict, doOpenGL,
needGlutInit, useFrameworkGlut, usePic, useOpenmp):
bits = softwareDict['bits']
codeDict = softwareDict['Tcl']
tcl_abs_dir = codeDict.get('directory', '')
tcl_inc_dir = codeDict.get('include', '')
tcl_lib_dir = codeDict.get('lib', '')
tcl_version = tk_version = codeDict.get('version', '')
codeDict = softwareDict['Tk']
tk_abs_dir = codeDict.get('directory', '')
tk_inc_dir = codeDict.get('include', '')
tk_lib_dir = codeDict.get('lib', '')
codeDict = softwareDict['Python']
python_abs_dir = codeDict.get('directory', '')
python_inc_dir = codeDict.get('include', '')
python_lib_dir = os.path.join(python_abs_dir, codeDict.get('lib', ''))
py_version = codeDict.get('version', '')
codeDict = softwareDict['ElementTree']
element_tree_abs_dir = codeDict.get('directory', '')
element_tree_inc_dir = codeDict.get('elementtree', '')
codeDict = softwareDict['X11']
x11_abs_dir = codeDict.get('directory', '')
x11_inc_dir = codeDict.get('include', '')
x11_lib_dir = codeDict.get('lib', '')
codeDict = softwareDict['OpenGL']
mesa_abs_dir = codeDict.get('directory', '')
mesa_inc_dir = codeDict.get('include', '')
mesa_lib_dir = codeDict.get('lib', '')
codeDict = softwareDict['glut']
glut_abs_dir = codeDict.get('directory', '')
glut_inc_dir = codeDict.get('include', '')
glut_lib_dir = codeDict.get('lib', '')
env_file = '%s/c/environment.txt' % ccpnmr_rel_dir
if not platform:
doPrint('Unknown platform, %s installation procedure will probably fail and you will need to edit %s by hand, continuing anyway using linux options' % (program_name, env_file))
platform = 'linux'
if platform == 'windows':
mallocFlag = ''
else:
# other platforms seem not to need this now
mallocFlag = '-DDO_NOT_HAVE_MALLOC'
if usePic:
picFlag = '-fPIC'
else:
picFlag = ''
if useOpenmp:
openmpComment = ''
else:
openmpComment = '#'
if platform == 'sunos':
xorFlag = '-DXOR_IS_EQUIV'
else:
xorFlag = ''
if doOpenGL:
ignoreGL = ''
glCom = ''
else:
ignoreGL = '-DIGNORE_GL'
glCom = '#'
if platform == 'linux':
glFlag = '-DUSE_GL_FALSE'
else:
glFlag = '-DUSE_GL_TRUE'
if platform == 'linux' and bits == 32:
bigFileFlag = '-D_FILE_OFFSET_BITS=64'
else:
bigFileFlag = ''
if needGlutInit:
glutNeedInit = '-DNEED_GLUT_INIT'
else:
glutNeedInit = ''
if platform == 'sunos':
sharedFlag = '-G'
elif platform == 'darwin':
sharedFlag = '-L%s -bundle -bundle_loader %s/bin/python%s' % (python_lib_dir, python_abs_dir, py_version)
else:
sharedFlag = '-shared'
pythonLib = ''
if platform == 'darwin' and py_version >= '2.6':
try:
n = int(os.uname()[2].split('.')[0])
if n >= 10: # OSX >= 10.6 (Snow Leopard)
pythonLib = '\nPYTHON_LIB = -L$(PYTHON_DIR)/lib/python%s/config -lpython%s' % (py_version, py_version)
except:
pass
if useFrameworkGlut:
glLibs = '-framework GLUT -lGLU -lGL'
extraGlIncludeFlag = '-I/System/Library/Frameworks/GLUT.framework/Headers'
extraGlLibFlag = '-framework GLUT'
glutNotInGl = '-DGLUT_IN_OWN_DIR'
try:
n = int(os.uname()[2].split('.')[0])
if n >= 9: # OSX >= 10.5 (Leopard)
extraGlLibFlag = extraGlLibFlag + ' -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib'
except:
pass
else:
glLibs = '-lglut -lGLU -lGL'
if glut_abs_dir:
extraGlIncludeFlag = '-I%s/%s' % (glut_abs_dir, glut_inc_dir)
extraGlLibFlag = '-L%s/%s' % (glut_abs_dir, glut_lib_dir)
else:
extraGlIncludeFlag = ''
extraGlLibFlag = ''
glutNotInGl = ''
home = '../../../..' # relative to where C source code is
if os.path.exists(env_file):
env_backup = '%s/c/environment%s' % (ccpnmr_rel_dir, backup_suffix)
if (os.path.exists(env_backup)):
os.remove(env_backup)
doPrint('Backing up %s to %s' % (env_file, env_backup))
os.rename(env_file, env_backup)
fp = open('%s/c/environment.txt' % ccpnmr_rel_dir, 'w')
fp.write('''
# should work if suitably edited for Linux, Irix, Solaris, OSX
# the C compiler and associated things
# use below for everything except Windows
CC = cc
LINK = $(CC)
MAKE = make
CO_NAME = -c $<
OUT_NAME = -o $@
OBJ_SUFFIX = o
DYLIB_SUFFIX = so
RM = rm -f
# use below for Windows
#CC = cl
#LINK = $(CC) /LD
#MAKE = nmake
#CO_NAME = -c $**
#OUT_NAME = /Fe$@
#OBJ_SUFFIX = obj
#DYLIB_SUFFIX = pyd
#RM = rm -f
# compiler flags
# Windows specific flag
# use below for everything except Windows
WIN_FLAG =
# use below for Windows
#WIN_FLAG = /DWIN32 /MD
MALLOC_FLAG = %s
# use below for everything with malloc.h
#MALLOC_FLAG =
# use below for everything without malloc.h (e.g. OSX)
#MALLOC_FLAG = -DDO_NOT_HAVE_MALLOC
FPIC_FLAG = %s
# use below for everything with -fPIC option (e.g. gcc)
#FPIC_FLAG = -fPIC
# use below for everything without -fPIC option
#FPIC_FLAG =
XOR_FLAG = %s
# use below for everything where Tk xor behaves normally
#XOR_FLAG =
# use below for everything (e.g. Solaris) where xor is equiv
#XOR_FLAG = -DXOR_IS_EQUIV
# optimisation flag
# use below for everything except Windows
OPT_FLAG = -O2
# use below for Windows
#OPT_FLAG = /Ox
# file flag needed for 32-bit Linux to be able to read > 2Gb files
BIGFILE_FLAG = %s
# use below for everything except 32-bit Linux
#BIGFILE_FLAG =
# use below for 32-bit Linux
#BIGFILE_FLAG = -D_FILE_OFFSET_BITS=64
# Some functions utilise OpenMP for multi-cpu optimisation
# use below if you have more than one cpu
# (these flags for GNU CC, Intel CC differs)
%sOPENMP_FLAGS = -fopenmp
%sOPENMP_LIB = -lgomp
# use below for Windows (note: after VS 2010 VCOMP.LIB is a paid upgrade,
# but is available for free in VS 2008)
#OPENMP_FLAGS = /OPENMP
#OPENMP_LIB = VCOMP.LIB
CC_FLAGS = $(WIN_FLAG) $(OPT_FLAG) $(FPIC_FLAG) $(MALLOC_FLAG) $(XOR_FLAG) $(BIGFILE_FLAG)
LINK_FLAGS = $(WIN_FLAG) $(OPT_FLAG) $(FPIC_FLAG)
# linking command for C libraries into Python world
# (used for everything except Windows)
LINK_LIBRARIES = sh linkSharedObjs
# copying command for C libraries into Python world
# (used only for Windows)
COPY_LIBRARIES = sh copySharedObjs
''' % (mallocFlag, picFlag, xorFlag, bigFileFlag, openmpComment, openmpComment))
fp.write('''
# specify whether or not you want to compile GL
IGNORE_GL_FLAG = %s
# use below if you want to compile GL
#IGNORE_GL_FLAG =
# use below if you want to ignore GL