From fca8768d6382b2b73deb1c9c18fe52b611e8c88e Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Mon, 26 Aug 2019 11:54:01 +0200
Subject: [PATCH] Add --interpreter argument

---
 apa | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/apa b/apa
index e7dffe9..cc9ca8d 100755
--- a/apa
+++ b/apa
@@ -2,7 +2,7 @@
 """
 Anders Python Archiver
 
-Copyright (C) 2004-2009 Anders Blomdell <anders.blomdell@control.lth.se>
+Copyright (C) 2004-2019 Anders Blomdell <anders.blomdell@control.lth.se>
 
   A small utility program to join a number of python modules
   into a single executable python program.
@@ -54,6 +54,10 @@ if __name__ == '__main__':
     optParser.add_option('-d','--documentation',
                          action='store_true', 
                          help='Show documentation')
+    optParser.add_option('--interpreter',
+                         default=None,
+                         action='store', 
+                         help='Interpreter to use')
     optParser.add_option('-o','--output',
                          action='store', 
                          help='Name of archive')
@@ -98,13 +102,15 @@ if __name__ == '__main__':
 
     # Emit code
     interpreter = code[0][2].splitlines()[0]
-    if interpreter.find("python") >= 0:
+    if options.interpreter != None:
+        print >> apa, "#!%s" % options.interpreter        
+    elif interpreter.find("python") >= 0:
         # Take interpreter version from main file
         print >> apa, interpreter
     else:
         # Default interpreter
-        print >> sys.stderr, "Interpreter defaulting to '#!/usr/bin/python'"
-        print >> apa, "#!/usr/bin/python"
+        print >> sys.stderr, "Interpreter defaulting to '#!/usr/bin/python3'"
+        print >> apa, "#!/usr/bin/python3"
     print >> apa, "\"\"\""
     print >> apa, "Executable archive of '%s'" % code[0][0]
     print >> apa, "\nThe following modules are archived:"
-- 
GitLab