Commit 858ffbbef6a240745cac7d6b662ad3abc5f81180

Authored by Jürgen Knödlseder
1 parent fbd66c42

Bug fix: don't always remove Python wrappers in "make clean" (#1826)

Python wrappers have been always removed when typing "make clean", even if the wrappers have been shipped with the code. This has been corrected and Python wrappers are now only remove if they actually have been built (and hence if they have not been shipped with the code).
ChangeLog
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 * Version 1.2.0 released 3 * Version 1.2.0 released
4 ========================= 4 =========================
5 5
  6 + Fix removal of Python wrappers after make clean (#1826)
6 Add GModelSpectralPlawEnergyFlux class (#1790) 7 Add GModelSpectralPlawEnergyFlux class (#1790)
7 Rename GModelSpectralPlaw2 to GModelSpectralPlawPhotonFlux (#1790) 8 Rename GModelSpectralPlaw2 to GModelSpectralPlawPhotonFlux (#1790)
8 9
@@ -38,7 +38,9 @@ The return value of the following methods has been changed: @@ -38,7 +38,9 @@ The return value of the following methods has been changed:
38 38
39 3. Configuration 39 3. Configuration
40 ----------------- 40 -----------------
41 -None 41 +The Python wrappers were always removed when typing "make clean", even if
  42 +they had been shipped with the code. Now, the Python wrappers are only
  43 +removed in a "make clean" if they have been built (#1826).
42 44
43 45
44 4. Application module 46 4. Application module
pyext/Makefile.am
@@ -263,12 +263,20 @@ uninstall-local: @@ -263,12 +263,20 @@ uninstall-local:
263 # Set files to be removed in 'make clean' 263 # Set files to be removed in 'make clean'
264 CLEANFILES = $(CLEAN_FILES) $(DEPFILES) 264 CLEANFILES = $(CLEAN_FILES) $(DEPFILES)
265 265
266 -# Files to be removed in build directory 266 +# Files to be removed in build directory. Only remove wrapper files if the
  267 +# have been built or if the were copied in the build directory
267 clean-local: 268 clean-local:
268 rm -rf build 269 rm -rf build
  270 +if BUILD_WRAPPERS
269 rm -rf $(builddir)/gammalib/*.py 271 rm -rf $(builddir)/gammalib/*.py
270 - rm -rf $(builddir)/gammalib/*.pyc  
271 rm -rf $(builddir)/gammalib/*_wrap.cpp 272 rm -rf $(builddir)/gammalib/*_wrap.cpp
  273 +else
  274 + if test "x$(builddir)" != "x$(srcdir)"; then \
  275 + rm -rf $(builddir)/gammalib/*.py; \
  276 + rm -rf $(builddir)/gammalib/*_wrap.cpp; \
  277 + fi
  278 +endif
  279 + rm -rf $(builddir)/gammalib/*.pyc
272 rm -rf $(builddir)/gammalib/_*.so 280 rm -rf $(builddir)/gammalib/_*.so
273 rm -rf $(builddir)/gammalib/__pycache__ 281 rm -rf $(builddir)/gammalib/__pycache__
274 282
pyext/setup.py.in
@@ -153,8 +153,10 @@ if '@IS_ELCAPITAN_TRUE@' != '#': @@ -153,8 +153,10 @@ if '@IS_ELCAPITAN_TRUE@' != '#':
153 for module in core_modules: 153 for module in core_modules:
154 154
155 # In case that wrappers were not built then copy the module wrapper files 155 # In case that wrappers were not built then copy the module wrapper files
156 - # from the source to the build directory  
157 - if '@BUILD_WRAPPERS_FALSE@' != '#' and is_build: 156 + # from the source to the build directory. Only do this if the build
  157 + # directory differs from the source directory
  158 + if '@BUILD_WRAPPERS_FALSE@' != '#' and is_build and \
  159 + '@srcdir@' != '@builddir@':
158 py_file = pkg_name+'/'+module+'.py' 160 py_file = pkg_name+'/'+module+'.py'
159 cpp_file = pkg_name+'/'+module+'_wrap.cpp' 161 cpp_file = pkg_name+'/'+module+'_wrap.cpp'
160 os.system('cp %s %s' % ('@srcdir@/'+cpp_file, '@builddir@/'+cpp_file)) 162 os.system('cp %s %s' % ('@srcdir@/'+cpp_file, '@builddir@/'+cpp_file))
@@ -183,8 +185,10 @@ for module in inst_modules: @@ -183,8 +185,10 @@ for module in inst_modules:
183 install_files.extend(glob.glob('@top_srcdir@/inst/'+module+'/pyext/*.i')) 185 install_files.extend(glob.glob('@top_srcdir@/inst/'+module+'/pyext/*.i'))
184 186
185 # In case that wrappers were not built then copy the module wrapper files 187 # In case that wrappers were not built then copy the module wrapper files
186 - # from the source to the build directory  
187 - if '@BUILD_WRAPPERS_FALSE@' != '#' and is_build: 188 + # from the source to the build directory. Only do this if the build
  189 + # directory differs from the source directory
  190 + if '@BUILD_WRAPPERS_FALSE@' != '#' and is_build and \
  191 + '@srcdir@' != '@builddir@':
188 py_file = pkg_name+'/'+module+'.py' 192 py_file = pkg_name+'/'+module+'.py'
189 cpp_file = pkg_name+'/'+module+'_wrap.cpp' 193 cpp_file = pkg_name+'/'+module+'_wrap.cpp'
190 os.system('cp %s %s' % ('@srcdir@/'+cpp_file, '@builddir@/'+cpp_file)) 194 os.system('cp %s %s' % ('@srcdir@/'+cpp_file, '@builddir@/'+cpp_file))