Commit d554118bed3968e7fc5d8fe17b19c6dc1d96d016

Authored by Jürgen Knödlseder
1 parent 7ce9224b

Detect execution mode.

The script execution mode is detected, an no file modifications are done in install mode to prevent changing of file ownership.
Showing 1 changed file with 23 additions and 12 deletions
pyext/setup.py.in
... ... @@ -25,6 +25,16 @@ import glob
25 25 import os
26 26 import sys
27 27  
  28 +# Detect execution mode
  29 +is_build = True
  30 +if (len(sys.argv) >= 2):
  31 + if (sys.argv[1] == 'install'):
  32 + is_build = False
  33 +if is_build:
  34 + sys.stdout.write("Python extension module building:\n")
  35 +else:
  36 + sys.stdout.write("Python extension module installation:\n")
  37 +
28 38 # Darwin MacPorts kluge: Remove -L/opt/local/lib path from LDSHARED as this
29 39 # overrides the GammaLib settings. Otherwise, MacPorts libraries would be
30 40 # used instead of the libraries selected by GammaLib
... ... @@ -128,15 +138,16 @@ setup(name='@PACKAGE_NAME@',
128 138 # Post-processing. A symbolic link is created to the directory containing the
129 139 # shared wrapper libraries so that we can add this directory to the PYTHONPATH
130 140 # for testing.
131   -try:
132   - os.chdir('build')
133   - os.remove('ctools')
134   - sys.stdout.write("Removed symbolic link build/ctools.\n")
135   -except:
136   - pass
137   -try:
138   - path = glob.glob('lib.*')
139   - os.symlink(path[0], 'ctools')
140   - sys.stdout.write("Created symbolic link build/ctools.\n")
141   -except:
142   - sys.stdout.write("WARNING: Failed to create symbolic link build/ctools.\n")
  141 +if is_build:
  142 + try:
  143 + os.chdir('build')
  144 + os.remove('ctools')
  145 + sys.stdout.write("Removed symbolic link build/ctools.\n")
  146 + except:
  147 + pass
  148 + try:
  149 + path = glob.glob('lib.*')
  150 + os.symlink(path[0], 'ctools')
  151 + sys.stdout.write("Created symbolic link build/ctools.\n")
  152 + except:
  153 + sys.stdout.write("WARNING: Failed to create symbolic link build/ctools.\n")
... ...