Commit 55509ac5057be2304da2d4e4a412270571256f0b

Authored by Jürgen Knödlseder
1 parent 98fe2f28

Make compliant to MacPorts gcc compiler.

A Darwin kluge consisted of linking statically with the ctools library for unit testing. It turned out that this is no longer necessary, so I removed the Darwin kluge of static linking.

Furthermore, a post-processing step was added that creates a symbolic link to the directory that contains the shared wrapper library. In that way, we do not need a double compilation anymore (before, we compiled once for the install and a second time for the unit test). This should now speed up the unit testing step.
Showing 1 changed file with 20 additions and 40 deletions
pyext/setup.py.in
... ... @@ -25,13 +25,6 @@ import glob
25 25 import os
26 26 import sys
27 27  
28   -# Detect execution mode
29   -is_unit_test = False
30   -if (len(sys.argv) >= 3):
31   - if (sys.argv[2] == '--inplace'):
32   - print@PYTHON_OPEN@"This build is for unit testing."@PYTHON_CLOSE@
33   - is_unit_test = True
34   -
35 28 # Darwin MacPorts kluge: Remove -L/opt/local/lib path from LDSHARED as this
36 29 # overrides the GammaLib settings. Otherwise, MacPorts libraries would be
37 30 # used instead of the libraries selected by GammaLib
... ... @@ -50,43 +43,17 @@ if sys.platform.lower().startswith("darwin"):
50 43 else:
51 44 ldshared_rm += option + ' '
52 45 if (len(ldshared_rm) > 0):
53   - print@PYTHON_OPEN@"Removed following option(s) from LDSHARED: "+ldshared_rm@PYTHON_CLOSE@
  46 + sys.stdout.write("Removed following option(s) from LDSHARED: "+ldshared_rm+"\n);
54 47  
55 48 # Set LDSHARED
56 49 cvars['LDSHARED'] = ldshared_new
57 50  
58   -# Set ctools library name. If we're about to make the test build then
59   -# create a symbolic link to the static library to enforce static linking.
60   -# This is required on some system (such as Mac OS X) to avoid problems
61   -# with finding the shared library during unit testing.
62   -libcta='ctools'
63   -#if is_unit_test:
64   -if sys.platform.lower().startswith("darwin") and is_unit_test:
65   -
66   - # Remove any existing symbolic link to libctools.a. This will
67   - # prevent any exception in creating the symbolic link due to
68   - # an already existing link.
69   - try:
70   - os.remove('../src/.libs/libctools_python.a')
71   - print@PYTHON_OPEN@"Removed ../src/.libs/libctools_python.a"@PYTHON_CLOSE@
72   - except:
73   - pass
74   -
75   - # Now create a symbolic link and set the library name to this
76   - # symbolic link
77   - try:
78   - os.symlink('libctools.a', '../src/.libs/libctools_python.a')
79   - print@PYTHON_OPEN@"Created ../src/.libs/libctools_python.a"@PYTHON_CLOSE@
80   - libcta='ctools_python'
81   - except:
82   - print@PYTHON_OPEN@"WARNING: Failed to create symbolic link to static library. Link dynamically."@PYTHON_CLOSE@
83   -
84 51 # Set default include directories and data files
85 52 include_dirs = ['@prefix@/include/gammalib']
86 53 install_files = glob.glob('@top_srcdir@/pyext/*.i')
87 54 library_dirs = ['../src/.libs']
88 55 runtime_library_dirs = ['../src/.libs']
89   -libraries = [libcta,'gamma']
  56 +libraries = ['ctools','gamma']
90 57  
91 58 # Add install directory to runtime library path
92 59 if os.path.exists('@prefix@/lib'):
... ... @@ -126,11 +93,8 @@ for extra_include_dir in extra_include_dirs:
126 93 if len(dir) > 0:
127 94 include_dirs.append(dir)
128 95  
129   -# Set data files to install. Do not install data files in unit testing mode.
130   -if is_unit_test:
131   - data_files=[]
132   -else:
133   - data_files=[('@prefix@/share/ctools/swig', install_files)]
  96 +# Set data files to install.
  97 +data_files=[('@prefix@/share/ctools/swig', install_files)]
134 98  
135 99 # Optionally enable OpenMP
136 100 if '@OPENMP_TRUE@' != '#':
... ... @@ -160,3 +124,19 @@ setup(name='@PACKAGE_NAME@',
160 124 long_description="CTA science analysis tools",
161 125 platforms=["Linux", "Solaris", "Mac OS-X", "Unix", "BSD"],
162 126 )
  127 +
  128 +# Post-processing. A symbolic link is created to the directory containing the
  129 +# shared wrapper libraries so that we can add this directory to the PYTHONPATH
  130 +# 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")
... ...