Produce both versions x32 and x64 under PyInstaller

2.3k views Asked by At

I have installed Python 2.7.xx x64 and trying to build executables with PyInstaller.

Do I have any chance to build both artifacts x32 and x64 with my existing Python x64?

Current PyInstaller script shown below in app.spec file:

pyinstaller src/app.spec

# -*- mode: python -*-
import os
import platform

from PySide import QtCore


onefile = False
console = False

platform_name = platform.system().lower()
app_name = {'linux': 'app',
            'darwin': 'app',
            'windows': 'app.exe'}[platform_name]

# Include imageformats plugins
plugins=os.path.join(os.path.dirname(QtCore.__file__), "plugins\\imageformats")
static_files = Tree(plugins, 'plugins\\imageformats')
static_files += [('app.ico', 'src\\app.ico', 'DATA')]

# Analyze sources
a = Analysis(['src\\app.py'],
             hiddenimports=['pkg_resources'],
             hookspath=None,
             runtime_hooks=None)

pyz = PYZ(a.pure)

if onefile:
    exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, name=app_name,
        debug=False, strip=None, upx=True, console=console, icon='src/app.ico', version='src/app.ver')
else:
    exe = EXE(pyz, a.scripts, exclude_binaries=True, name=app_name, debug=False,
        strip=None, upx=True, console=console, icon='src/app.ico', version='src/app.ver')
    coll = COLLECT(exe, a.binaries, static_files, a.zipfiles, a.datas, strip=None, upx=True, name='app')
1

There are 1 answers

0
Anthon On BEST ANSWER

No, that won't work. What you should do is install the 32 bit python as well and create the "other" installer starting the creation process with that.

It is possible to have both the 32 and the 64 bit version of the same Python major.minor version on the same machine. I have a virtual machine with 32 and 64 bit versions of 2.7/2.6/3.3/3.4 for development. Only one python (the 64 bit version of 2.7) is in my PATH and it runs all the other stuff (tox, py.test, mercurial) that is Python based. I specify the full path (like C:\python\2.7-32\python.exe to use the 32 bit version). My batch file to generate the .whl files for ruamel.yaml is:

c:\python\2.7\python.exe setup.py bdist_wheel
c:\python\2.6\python.exe setup.py bdist_wheel
c:\python\2.7-32\python.exe setup.py bdist_wheel
c:\python\2.6-32\python.exe setup.py bdist_wheel
c:\python\3.4\python.exe setup.py bdist_wheel
c:\python\3.3\python.exe setup.py bdist_wheel
c:\python\3.4-32\python.exe setup.py bdist_wheel
c:\python\3.3-32\python.exe setup.py bdist_wheel
c:\pypy2\2.5\pypy-2.5.1-win32\pypy.exe setup.py bdist_wheel

Of course the exact paths depend on where you install the interpreters.