From 1e025b834b7f5cdd677d29a6c78e3edbecc839a4 Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Sat, 13 Nov 2010 16:34:57 +0100 Subject: Use python discovered through env instead of hardcoding a path This is more flexible regarding the location of the python binary but doesn't allow to pass the -u flag. The -i flag can be passed from inside the script using the PYTHONINSPECT env variable. This fixes a problem with the esx_vi_generator.py on FreeBSD. --- generator.py | 2 +- libvirt-override.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/generator.py b/generator.py index 68009b9..15751bd 100755 --- a/generator.py +++ b/generator.py @@ -1010,7 +1010,7 @@ def buildWrappers(): classes = open("libvirt.py", "w") extra = open(os.path.join(srcPref,"libvirt-override.py"), "r") - classes.write("#!/usr/bin/python -i\n") + classes.write("#!/usr/bin/env python\n") classes.write("#\n") classes.write("# WARNING WARNING WARNING WARNING\n") classes.write("#\n") diff --git a/libvirt-override.py b/libvirt-override.py index d544a0e..909ebe3 100644 --- a/libvirt-override.py +++ b/libvirt-override.py @@ -2,6 +2,11 @@ # Manually written part of python bindings for libvirt # +# Specify -i commandline option after python was started +if __name__ == "__main__": + import os + os.environ["PYTHONINSPECT"] = "1" + # On cygwin, the DLL is called cygvirtmod.dll try: import libvirtmod -- cgit