Skip to content

Commit

Permalink
support for Python 3 on win32
Browse files Browse the repository at this point in the history
  • Loading branch information
rfk committed Jun 1, 2010
1 parent 4d4119a commit b1f7c7c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions esky/bdist_esky/f_cxfreeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ def _normalise_opt_name(nm):
# On Windows, execv is flaky and expensive. If the chainloader is the same
# python version as the target exe, we can munge sys.path to bootstrap it
# into the existing process.
if sys.version_info[0] < 3:
EXEC_STATEMENT = "exec code in globals()"
else:
EXEC_STATEMENT = "exec(code,globals())"
_CUSTOM_WIN32_CHAINLOADER = """
_orig_chainload = _chainload
def _chainload(target_dir):
Expand All @@ -151,7 +155,7 @@ def _chainload(target_dir):
sys.bootstrap_executable = sys.executable
sys.executable = pathjoin(target_dir,basename(sys.executable))
sys.argv[0] = sys.executable
for i in xrange(len(sys.path)):
for i in range(len(sys.path)):
sys.path[i] = sys.path[i].replace(mydir,target_dir)
import zipimport
for init_path in sys.path:
Expand All @@ -172,7 +176,7 @@ def _chainload(target_dir):
SHARED_ZIP_FILE_NAME = SHARED_ZIP_FILE_NAME.replace(mydir,target_dir)
INITSCRIPT_ZIP_FILE_NAME = init_path
try:
exec code in globals()
%s
except zipimport.ZipImportError:
e = sys.exc_info()[1]
# If it can't find the __main__{sys.executable} script,
Expand All @@ -184,6 +188,6 @@ def _chainload(target_dir):
sys.exit(0)
else:
_orig_chainload(target_dir)
""" % (INITNAME,)
""" % (INITNAME,EXEC_STATEMENT)


0 comments on commit b1f7c7c

Please sign in to comment.