commit a3f93c2335c22ed5002a6e4825d35e6c7055e89b Author: Alexandre Allaire alexandre.allaire@mail.mcgill.ca Date: Tue Mar 12 20:00:54 2013 -0700
Use sys.executable to get script directory when frozen.
py2exe overwrites sys.path[0], and the paths to the registration helpers end up wrong. If we are frozen, use dirname(sys.executable) instead of sys.path[0]. --- flashproxy-client | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/flashproxy-client b/flashproxy-client index e9795fa..22ce072 100755 --- a/flashproxy-client +++ b/flashproxy-client @@ -945,8 +945,12 @@ def proxy_loop(): report_pending()
def build_register_command(method): - # sys.path[0] is initialized to the directory containing the Python script file. - script_dir = sys.path[0] + # sys.path[0] usually contains the directory the script is located in. + # py2exe overwrites this for bundled executables. + if getattr(sys, "frozen", False): + script_dir = os.path.dirname(sys.executable) + else: + script_dir = sys.path[0] if not script_dir: # Maybe the script was read from stdin; in any case don't guess at the directory. raise ValueError("Can't find executable directory for registration helpers")