~ubuntu-branches/ubuntu/warty/petsc/warty

« back to all changes in this revision

Viewing changes to python/BuildSystem/install/setuprc.py

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2004-06-07 13:41:43 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040607134143-92p586zrauvie0le
Tags: 2.2.0-2
* Upstream patch level 2.
* New PETSC_BOPT_EXTRA option for different BOPT and lib names, with _c++
  symlinks only for plain and single (closes: #249617).
* New DEBIAN_DIST=contrib option to link with hypre, parmetis (closes:
  #249619).
* Combined petsc-c and petsc-fortran substvars into petsc-compilers.
* Extra quote in -dev prerm eliminates "too many arguments" problem.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
'''Creates a .pythonrc.py file and puts the path for BuildSystem in it'''
 
3
 
 
4
import os
 
5
import sys
 
6
import os.path
 
7
 
 
8
def setupHostname():
 
9
  '''Check that hostname returns something BitKeeper is happy with, and returns any lines to be added to the RC file
 
10
     - Set BK_HOST if necessary'''
 
11
  import socket
 
12
 
 
13
  hostname = socket.gethostname()
 
14
  if len(hostname) > 8 and hostname[0:9] == 'localhost':
 
15
    return ['os.putenv("BK_HOST", "bkneedsname.org")']
 
16
  elif hostname[-1] == '.':
 
17
    return ['os.putenv("BK_HOST", "'+hostname+'org")']
 
18
  elif hostname.find('.') == -1:
 
19
    return ['os.putenv("BK_HOST", "'+hostname+'.org")']
 
20
  return []
 
21
 
 
22
def setupASESection(lines, path):
 
23
  '''Fill in the ASE section of the RC file'''
 
24
  top       = []
 
25
  bottom    = []
 
26
  ase       = []
 
27
  foundASE  = 0
 
28
  skipASE   = 0
 
29
  aseMarker = '###### ASE Section'
 
30
 
 
31
  for line in [l.strip() for l in lines]:
 
32
    if line == aseMarker:
 
33
      foundASE = 1
 
34
      skipASE  = not skipASE
 
35
      continue
 
36
    if skipASE:
 
37
      continue
 
38
    if foundASE:
 
39
      bottom.append(line)
 
40
    else:
 
41
      top.append(line)
 
42
 
 
43
  ase.append(aseMarker)
 
44
  ase.extend(['# Code added by sidl/BuildSystem/install/setuprc.py', 'import sys', 'sys.path.insert(0,"'+path+'")'])
 
45
  ase.extend(setupHostname())
 
46
  ase.append(aseMarker)
 
47
 
 
48
  return top+ase+bottom
 
49
 
 
50
def setupRC(path):
 
51
  filename = os.path.join(os.getenv('HOME'),'.pythonrc.py')
 
52
  if os.path.isfile(filename):
 
53
    f     = open(filename)
 
54
    lines = f.readlines()
 
55
    f.close()
 
56
  else:
 
57
    lines = []
 
58
 
 
59
  f = open(filename,'w')
 
60
  f.write('\n'.join(setupASESection(lines, path)))
 
61
  f.close()
 
62
  sys.path.insert(0, path)
 
63
  return
 
64
 
 
65
if __name__ ==  '__main__':
 
66
  import sys
 
67
  if len(sys.argv) < 2:
 
68
    sys.exit('Usage: setupRC.py <BuildSystem path>')
 
69
  setupRC(sys.argv[1])
 
70