From: David Aguilar Date: Fri, 09 Apr 2010 08:42:39 GMT Subject: [PATCH] Makefile: Avoid multi-line sed when building python scripts Message-ID: <1270802559-14791-1-git-send-email-davvid@gmail.com> In-Reply-To: <20100409080256.GA12527@gmail.com> Instead of requiring scripts to start with "import sys", install the sys.path initialization code immediately after each script's new shebang line. This works around portability issues with multi-line sed and simplifies the work for contributors. There is no longer the requirement that every script must "import sys" before importing git-provided modules. Signed-off-by: David Aguilar --- Makefile | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 956e781..b763947 100644 --- a/Makefile +++ b/Makefile @@ -1608,12 +1608,10 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \ instlibdir` && \ sed -e '1{' \ - -e ' s|#!.*python|#!$(PYTHON_PATH_SQ)|' \ + -e ' s|#!.*python|#!$(PYTHON_PATH_SQ)\n@@STARTUP@@|' \ -e '}' \ - -e 's|^import sys.*|&; \\\ - import os; \\\ - sys.path.insert(0, os.getenv("GITPYTHONLIB",\ - "@@INSTLIBDIR@@"));|' \ + -e 's|@@STARTUP@@|import os, sys; sys.path.insert(0, @@ENV@@)|' \ + -e 's|@@ENV@@|os.getenv("GITPYTHONLIB", "@@INSTLIBDIR@@")|' \ -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \ $@.py >$@+ && \ chmod +x $@+ && \ -- 1.7.0.3.313.g87b3c