From 55509ac5057be2304da2d4e4a412270571256f0b Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 18 Sep 2012 01:57:56 +0200 Subject: [PATCH] Make compliant to MacPorts gcc compiler. --- pyext/setup.py.in | 60 ++++++++++++++++++++---------------------------------------- 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/pyext/setup.py.in b/pyext/setup.py.in index aba9b56..6c0fdc3 100644 --- a/pyext/setup.py.in +++ b/pyext/setup.py.in @@ -25,13 +25,6 @@ import glob import os import sys -# Detect execution mode -is_unit_test = False -if (len(sys.argv) >= 3): - if (sys.argv[2] == '--inplace'): - print@PYTHON_OPEN@"This build is for unit testing."@PYTHON_CLOSE@ - is_unit_test = True - # Darwin MacPorts kluge: Remove -L/opt/local/lib path from LDSHARED as this # overrides the GammaLib settings. Otherwise, MacPorts libraries would be # used instead of the libraries selected by GammaLib @@ -50,43 +43,17 @@ if sys.platform.lower().startswith("darwin"): else: ldshared_rm += option + ' ' if (len(ldshared_rm) > 0): - print@PYTHON_OPEN@"Removed following option(s) from LDSHARED: "+ldshared_rm@PYTHON_CLOSE@ + sys.stdout.write("Removed following option(s) from LDSHARED: "+ldshared_rm+"\n); # Set LDSHARED cvars['LDSHARED'] = ldshared_new -# Set ctools library name. If we're about to make the test build then -# create a symbolic link to the static library to enforce static linking. -# This is required on some system (such as Mac OS X) to avoid problems -# with finding the shared library during unit testing. -libcta='ctools' -#if is_unit_test: -if sys.platform.lower().startswith("darwin") and is_unit_test: - - # Remove any existing symbolic link to libctools.a. This will - # prevent any exception in creating the symbolic link due to - # an already existing link. - try: - os.remove('../src/.libs/libctools_python.a') - print@PYTHON_OPEN@"Removed ../src/.libs/libctools_python.a"@PYTHON_CLOSE@ - except: - pass - - # Now create a symbolic link and set the library name to this - # symbolic link - try: - os.symlink('libctools.a', '../src/.libs/libctools_python.a') - print@PYTHON_OPEN@"Created ../src/.libs/libctools_python.a"@PYTHON_CLOSE@ - libcta='ctools_python' - except: - print@PYTHON_OPEN@"WARNING: Failed to create symbolic link to static library. Link dynamically."@PYTHON_CLOSE@ - # Set default include directories and data files include_dirs = ['@prefix@/include/gammalib'] install_files = glob.glob('@top_srcdir@/pyext/*.i') library_dirs = ['../src/.libs'] runtime_library_dirs = ['../src/.libs'] -libraries = [libcta,'gamma'] +libraries = ['ctools','gamma'] # Add install directory to runtime library path if os.path.exists('@prefix@/lib'): @@ -126,11 +93,8 @@ for extra_include_dir in extra_include_dirs: if len(dir) > 0: include_dirs.append(dir) -# Set data files to install. Do not install data files in unit testing mode. -if is_unit_test: - data_files=[] -else: - data_files=[('@prefix@/share/ctools/swig', install_files)] +# Set data files to install. +data_files=[('@prefix@/share/ctools/swig', install_files)] # Optionally enable OpenMP if '@OPENMP_TRUE@' != '#': @@ -160,3 +124,19 @@ setup(name='@PACKAGE_NAME@', long_description="CTA science analysis tools", platforms=["Linux", "Solaris", "Mac OS-X", "Unix", "BSD"], ) + +# Post-processing. A symbolic link is created to the directory containing the +# shared wrapper libraries so that we can add this directory to the PYTHONPATH +# for testing. +try: + os.chdir('build') + os.remove('ctools') + sys.stdout.write("Removed symbolic link build/ctools.\n") +except: + pass +try: + path = glob.glob('lib.*') + os.symlink(path[0], 'ctools') + sys.stdout.write("Created symbolic link build/ctools.\n") +except: + sys.stdout.write("WARNING: Failed to create symbolic link build/ctools.\n") -- libgit2 0.21.4