From adc6fa6c94dc90ed430de5e01f7dbd9f67e26fbe Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Wed, 5 Apr 2017 10:21:07 +0200 Subject: [PATCH] Copy shared Python libraries instead of creating a symbolic link (#1987) --- ChangeLog | 3 ++- NEWS | 6 +++++- inst/cta/src/GCTACubeExposure.cpp | 2 -- pyext/setup.py.in | 38 +++++++++++++++++++++++++++----------- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index d31268a..0f6533f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2017-04-04 +2017-04-05 * Version 1.3.0 released ========================= + Copy shared Python libraries instead of creating a symbolic link (#1987) Added FITS image conversion operators (#1986) If code originates from Git, always compile the Python bindings (#1985) Raise exception instead of exiting with return code in Python tests (#1983) diff --git a/NEWS b/NEWS index ae0e1d3..dbfb4c6 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in GammaLib 1.3.0.dev1 -4 April 2017 +5 April 2017 1. Introduction @@ -54,6 +54,10 @@ This solves the problem that occured for developers that could not get rid of existing Python wrappers, even if they modified the Python interface (#1985). +The shared libraries needed by the Python wrappers are now copied into a +build/gammalib directory for unit testing instead of creating a symbolic +link since on shared VM file systems symbolic links may not work (#1987). + 4. Application module --------------------- diff --git a/inst/cta/src/GCTACubeExposure.cpp b/inst/cta/src/GCTACubeExposure.cpp index af888b9..19d20f6 100644 --- a/inst/cta/src/GCTACubeExposure.cpp +++ b/inst/cta/src/GCTACubeExposure.cpp @@ -701,11 +701,9 @@ void GCTACubeExposure::fill_cube(const GCTAObservation& obs, GLog* log) // approximation, but probably the only we can really do. // We allow here for a small margin in case of rounding // errors in the energy boundaries. -//std::cout << obs_ebounds.emin() << " <= " << m_energies[iebin] << " <= " << obs_ebounds.emax() << std::endl; if (!(obs_ebounds.contains(m_energies[iebin]) || obs_ebounds.contains(m_energies[iebin]-margin) || obs_ebounds.contains(m_energies[iebin]+margin))) { -//std::cout << "Skip" << std::endl; continue; } diff --git a/pyext/setup.py.in b/pyext/setup.py.in index 8041ed3..5cebd92 100644 --- a/pyext/setup.py.in +++ b/pyext/setup.py.in @@ -1,7 +1,7 @@ ############################################################################# # Disutils setup file for gammalib Python extension module # # ------------------------------------------------------------------------- # -# Copyright (C) 2011-2016 Juergen Knoedlseder # +# Copyright (C) 2011-2017 Juergen Knoedlseder # # ------------------------------------------------------------------------- # # # # This program is free software: you can redistribute it and/or modify # @@ -24,6 +24,7 @@ import glob import os import sys import re +import shutil # Define package name pkg_name = 'gammalib' @@ -228,19 +229,34 @@ setup(name='@PACKAGE_NAME@', 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. +# Post-processing. The shared wrapper libraries are copied into the +# build/gammalib directory and this directory is appended to the PYTHONPATH +# so that shared libraries can be accessed during unit testing. This kluge +# is needed since the name of the build directory where the shared libraries +# reside is not known when building the Makefile. if is_build: + + # Remove existing build/gammalib directory try: - os.chdir('build') - os.remove('gammalib') - print('Removed symbolic link build/gammalib.') + os.remove('build/gammalib') + print('Removed "build/gammalib" directory.') except: pass + + # Create build/gammalib directory try: - path = glob.glob('lib.*/gammalib') - os.symlink(path[0], 'gammalib') - print('Created symbolic link build/gammalib.') + os.mkdir('build/gammalib') + print('Created "build/gammalib" directory.') + except (OSError): + print('Directory "build/gammalib" exists already.') except: - print('WARNING: Failed to create symbolic link build/gammalib.') + print('ERROR: Failed to create directory "build/gammalib".') + raise + + # Copy over shared libraries from lib.*/gammalib folder + files = glob.glob('build/lib.*/gammalib/_*.so') + for file in files: + dst = os.path.join('build/gammalib', os.path.basename(file)) + shutil.copy2(file, dst) + print('Copied %s -> %s' % (file, dst)) + print('Copied shared libraries into "build/gammalib" directory.') -- libgit2 0.21.4