Commit b9f19355 authored by Karl Wette's avatar Karl Wette

Implement Jolien's self-executing header for executable Python scripts

- Modified ".py:" rule in lalsuite_python.am to generate, from myscript.py:
  * ./myscript, which sets PYTHONPATH to uninstalled locations
  * .pybin/myscript, which sets PYTHONPATH to installed location
- Python scripts are installed using gnuscripts/lalsuite_python_install_script,
  which installs .pybin/myscript in place of myscript
Original: dcd692cc66cadf78a98fbf10106c60a51986d104
parent 6186b11f
SUFFIXES = .py
pybindir = $(bindir)
BUILT_SOURCES += $(pymodule_PYTHON) $(pybin_SCRIPTS)
MOSTLYCLEANFILES += $(pybin_SCRIPTS)
python_install_script = $(top_srcdir)/gnuscripts/lalsuite_python_install_script
INSTALL_SCRIPT = $(python_install_script) $(INSTALL)
EXTRA_DIST += $(python_install_script)
.PHONY: pymodule-all-local
all-local: pymodule-all-local
pymodule-all-local: pymodule-mostlyclean-local
......@@ -33,13 +38,28 @@ $(pybin_SCRIPTS): Makefile
echo "" >&2; \
exit 1; \
fi; \
if $(SED) -e 's|[@]PYTHON[@]|@PYTHON@|g;s|[@]pkgpythondir[@]|@pkgpythondir@|g;' $< > $@; then \
chmod +x $@; \
exit 0; \
else \
rm -f $@; \
exit 1; \
fi
$(MKDIR_P) .pybin/ || exit 1; \
rm -f $@ $@.tmp .pybin/$@ || exit 1; \
echo "#!/bin/sh" > $@.tmp; \
echo "### SHELL SELF-EXECUTING HEADER SCRIPT" >> $@.tmp; \
echo "''':'" >> $@.tmp; \
echo "PYTHONPATH=\"$(abs_builddir):$(abs_srcdir):$(LAL_PYTHON_PATH):\$${PYTHONPATH}\"" >> $@.tmp; \
echo "export PYTHONPATH" >> $@.tmp; \
echo "exec $(PYTHON) \"\$$0\" \"\$$@\"" >> $@.tmp; \
echo "exit \$$?" >> $@.tmp; \
echo "fi" >> $@.tmp; \
echo "'''" >> $@.tmp; \
echo "### PYTHON SCRIPT" >> $@.tmp; \
$(SED) -e "s|^PYTHONPATH=.*|PYTHONPATH=\"$(pyexecdir):$(pythondir):\$${PYTHONPATH}\"|" $@.tmp > .pybin/$@ || exit 1; \
cat $< >> .pybin/$@ || exit 1; \
cat $< >> $@.tmp || exit 1; \
chmod +x $@.tmp || exit 1; \
mv -f $@.tmp $@
.PHONY: pybin-clean-local
clean-local: pybin-clean-local
pybin-clean-local:
-rm -rf .pybin/
.PHONY: pybin-dist-hook
dist-hook: pybin-dist-hook
......
#!/bin/sh
# Install Python scripts from .pybin/, which have the correct PYTHONPATH
# Author: Karl Wette, 2014
# first command line argument is 'install' command
cmd="$1"
if test "x${cmd}" = x; then
echo "$0: insufficient arguments" >&2
exit 1
fi
shift
# iterate over 'install' arguments
while test "x$1" != x; do
arg="$1"
if test -f "${arg}" && test -f ".pybin/${arg}"; then
arg=".pybin/${arg}"
fi
cmd="${cmd} '${arg}'"
shift
done
# print and execute 'install' command
echo " ${cmd}"
eval "${cmd}"
exit $?
......@@ -11,6 +11,7 @@
.deps
.dvi-dep
.libs
.pybin
/_build/
/_inst/
/lal-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = lal
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
pymoduledir = $(pkgpythondir)/spectrum
......
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
pymoduledir = $(pkgpythondir)/utils
......
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/lalapps-*/
......
../../gnuscripts/lalsuite_python.am
\ No newline at end of file
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/lalburst-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = lalburst
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/laldetchar-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = laldetchar
......
#!@PYTHON@
import sys
import glob
from optparse import OptionParser
......
#!@PYTHON@
#
# Copyright (C) 2013 Chris Pankow
#
......@@ -18,7 +17,7 @@
# MA 02111-1307 USA
#
# Based on the reference implementation in MATLAB by Josh Smith, et al.
"""trigger based hierarchical veto"""
__doc__ = """trigger based hierarchical veto"""
import sys
......
#!@PYTHON@
#
# Copyright (C) 2013 Chris Pankow
#
......@@ -15,7 +14,7 @@
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""Generate segments from thresholding data"""
__doc__ = """Generate segments from thresholding data"""
import sys
......
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
pymoduledir = $(pkgpythondir)/hveto
......
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
pymoduledir = $(pkgpythondir)/triggers
......
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/lalframe-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = lalframe
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
pymoduledir = $(pkgpythondir)/utils
......
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/lalinference-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = lalinference
......
#!@PYTHON@
#
# Copyright (C) 2013 Leo Singer
#
......@@ -18,7 +17,7 @@
#
from __future__ import division
from __future__ import print_function
"""
__doc__ = """
Match sky maps with injections in an inspinjfind-style sqlite database and print
summary values for each sky map:
......
#!@PYTHON@
#
# Copyright (C) 2011 Leo Singer
#
......@@ -15,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
__doc__ = """
Convert a list of posterior samples to a HEALPix FITS image using an adaptively
refined HEALPix tree, subdividing each node if it contains more than
--samples-per-bin posterior samples. By default, the resolution is set to the
......
#!@PYTHON@
#
# Copyright (C) 2013 Leo Singer
#
......
#!@PYTHON@
#
# Copyright (C) 2013 Leo Singer
#
......@@ -17,7 +16,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
from __future__ import division
"""
__doc__ = """
Synthesize triggers for simulated sources using a miniature matched-filter
detection pipeline. The input file (or stdin if the input file is omitted)
should be an optionally gzip-compressed LIGO-LW XML file of the form
......
#!@PYTHON@
#
# Copyright (C) 2013 Leo Singer
#
......@@ -16,7 +15,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
"""
__doc__ = """
Produce GW sky maps for all coincidences in a LIGO-LW XML file.
The filename of the (optionally gzip-compressed) LIGO-LW XML input is an
......
#!@PYTHON@
#
# Copyright (C) 2013 Leo Singer
#
......@@ -16,7 +15,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
"""
__doc__ = """
Listen for new events from LVAlert and perform sky localization.
`bayestar_localize_lvalert` supports two modes of operation. You can explicitly
......
#!@PYTHON@
#
# Copyright (C) 2011 Leo Singer
#
......@@ -15,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
__doc__ = """
Plot an all-sky map on a Mollweide projection.
By default, plot in celestial coordinates (RA, Dec).
......
#!@PYTHON@
#
# Copyright (C) 2013 Leo Singer
#
......@@ -17,7 +16,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
from __future__ import division
"""
__doc__ = """
Create summary plots for sky maps of found injections, binned cumulatively by
false alarm rate.
"""
......
#!@PYTHON@
#
# Copyright (C) 2011 Leo Singer
#
......@@ -15,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
__doc__ = """
Overplot contours for a large number of sky maps, in geographical coordinates.
This can reveal patterns due to the priors (i.e., the network antenna pattern).
"""
......
#!@PYTHON@
#
# Copyright (C) 2013 Leo Singer
#
......@@ -16,7 +15,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
"""
__doc__ = """
Remove all entries from a template bank except those that lie within a 1-sigma
error ellipse of a (mass1, mass2, chi=0) at a given SNR. Uses
TaylorF2ReducedSpin metric.
......
#!@PYTHON@
#
# Copyright (C) 2013 Leo Singer
#
......@@ -17,7 +16,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
from __future__ import division
"""
__doc__ = """
Synthesize triggers for simulated sources by realizing Gaussian measurement
errors in SNR and time of arrival. The input file (or stdin if the input file
is omitted) should be an optionally gzip-compressed LIGO-LW XML file of the form
......
#!@PYTHON@
#
# Copyright (C) 2014 Leo Singer
#
......@@ -16,7 +15,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
"""Construct a LIGO-LW XML power spectral density file for a network of
__doc__ = """Construct a LIGO-LW XML power spectral density file for a network of
detectors by evaluating a model power noise sensitivity curve."""
import glue.ligolw.utils
......
#!@PYTHON@
#
# Copyright (C) 2013 Leo Singer
#
......
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
pymoduledir = $(pkgpythondir)/bayestar
......
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/lalinspiral-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = lalinspiral
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
pymoduledir = $(pkgpythondir)/sbank
......
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/lalmetaio-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = lalmetaio
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/lalpulsar-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = lalpulsar
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/lalsimulation-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = lalsimulation
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/lalstochastic-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = lalstochastic
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
......@@ -7,6 +7,7 @@
*.pyo
.deps
.libs
.pybin
/_build/
/_inst/
/lalxml-*/
......
../../gnuscripts/lalsuite_python_install_script
\ No newline at end of file
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
SUBDIRS = lalxml
BUILT_SOURCES =
MOSTLYCLEANFILES =
EXTRA_DIST =
include $(top_srcdir)/gnuscripts/lalsuite_python.am
include $(top_srcdir)/gnuscripts/lalsuite_vcs_info.am
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment