git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Gernhardt <brian@gernhardtsoftware.com>
To: Git List <git@vger.kernel.org>
Cc: Sverre Rabbelier <srabbelier@gmail.com>
Subject: [PATCH v2] Makefile: Simplify handling of python scripts
Date: Fri,  9 Apr 2010 11:57:45 -0400	[thread overview]
Message-ID: <1270828665-29373-1-git-send-email-brian@gernhardtsoftware.com> (raw)
In-Reply-To: <i2ifabb9a1e1004090839hd55a81bfid820180815c8d94d@mail.gmail.com>

The sed script intended to add a standard opening to python scripts
was non-compatible and overly complex.  Simplifying it down to a set
of one-liners removes the compatibility issues of newlines.  Moving
the environment alterations from the Makefile to the python scripts
makes also makes the scripts easier to run in-place.

Specifically, the new sed script:

 - Alters the shebang line to use the configured Python.
 - Alters any os.getenv("GITPYTHONLIB") calls to use @@INSTLIBDIR@@ as the
   default.  This will replace any existing default or add a default if
   none is provided.
 - Replaces the @@INSTLIBDIR@@ placeholder with the directory git installs
   its python libraries to.

The last two steps could be combined into a single step, but is left
separate in case someone has another need for @@INSTLIBDIR@@ in their
script.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
---

  On Apr 9, 2010, at 11:39 AM, Sverre Rabbelier wrote:

  > My sed foo is not that great, can you explain (in the commit message)
  > what exactly the new sed script does?
  
  Certainly.  (And the commit message is the only change from v1.)

 Makefile              |    9 ++-------
 git-remote-testgit.py |    2 ++
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index f0fe351..87c90d6 100644
--- a/Makefile
+++ b/Makefile
@@ -1629,13 +1629,8 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
 	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
 		--no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \
 		instlibdir` && \
-	sed -e '1{' \
-	    -e '	s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
-	    -e '}' \
-	    -e 's|^import sys.*|&; \\\
-	           import os; \\\
-	           sys.path.insert(0, os.getenv("GITPYTHONLIB",\
-	                                        "@@INSTLIBDIR@@"));|' \
+	sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
+	    -e 's|\(os\.getenv("GITPYTHONLIB"\)[^)]*)|\1,"@@INSTLIBDIR@@")|' \
 	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
 	    $@.py >$@+ && \
 	chmod +x $@+ && \
diff --git a/git-remote-testgit.py b/git-remote-testgit.py
index f61624e..9253922 100644
--- a/git-remote-testgit.py
+++ b/git-remote-testgit.py
@@ -2,6 +2,8 @@
 
 import hashlib
 import sys
+import os
+sys.path.insert(0, os.getenv("GITPYTHONLIB","."))
 
 from git_remote_helpers.util import die, debug, warn
 from git_remote_helpers.git.repo import GitRepo
-- 
1.7.1.rc0.243.g2ce66

  reply	other threads:[~2010-04-09 15:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09 15:34 [PATCH v2 0/3] *** SUBJECT HERE *** Brian Gernhardt
2010-04-09 15:34 ` [PATCH] Makefile: Simplify handling of python scripts Brian Gernhardt
2010-04-09 15:39   ` Sverre Rabbelier
2010-04-09 15:57     ` Brian Gernhardt [this message]
2010-04-09 16:05       ` [PATCH v2] " Sverre Rabbelier
2010-04-09 15:34 ` [PATCH v2 2/3] Document send-email --smtp-domain Brian Gernhardt
2010-04-09 15:34 ` [PATCH v2 3/3] send-email: Add sendemail.smtpdomain Brian Gernhardt
2010-04-09 18:40   ` Jakub Narebski
2010-04-10 13:51     ` Brian Gernhardt
2010-04-09 15:42 ` [PATCH v2 1/3] send-email: Don't use FQDNs without a '.' Brian Gernhardt
2010-04-09 16:31   ` Jakub Narebski
2010-04-10 13:44     ` Brian Gernhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1270828665-29373-1-git-send-email-brian@gernhardtsoftware.com \
    --to=brian@gernhardtsoftware.com \
    --cc=git@vger.kernel.org \
    --cc=srabbelier@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).