[diffoscope] 04/04: bin/diffoscope: Ensure that running from Git always uses that checkout's modules.

Chris Lamb chris at chris-lamb.co.uk
Thu Dec 22 10:36:11 CET 2016


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit cd1cd41fdce1f39674462381eb152bcb7f70ce9b
Author: Chris Lamb <lamby at debian.org>
Date:   Thu Dec 22 09:25:30 2016 +0000

    bin/diffoscope: Ensure that running from Git always uses that checkout's modules.
    
    We prefer local modules over any system-installed ones to ensure that running a
    Git version from any current working directory does not have unexpected
    behaviour. Avoids setting PYTHONPATH, etc.
---
 bin/diffoscope | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/bin/diffoscope b/bin/diffoscope
index 1afc9b5..624bf3b 100755
--- a/bin/diffoscope
+++ b/bin/diffoscope
@@ -22,10 +22,13 @@
 import os
 import sys
 
-for root in ('.', '..'):
-    if os.path.exists(os.path.join(root, 'diffoscope', '__init__.py')):
-        sys.path.insert(0, root)
-        break
+
+# Prefer local modules over any system-installed ones to ensure that running a
+# Git version from any current working directory does not have unexpected
+# behaviour.
+parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+if os.path.exists(os.path.join(parent, 'diffoscope', '__init__.py')):
+    sys.path.insert(0, parent)
 
 from diffoscope.main import main
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list