Commit e3e11159 authored by Matt Harbison's avatar Matt Harbison

packaging: search for MSVC 2015 when building a 32-bit PyQt5 installation

Now everything can be built from one window (except the MSI itself).  It doesn't
fall back to 2015 when doing 64-bit builds for simplicity.

--HG--
branch : stable
parent 9e3bf37dd711
......@@ -555,7 +555,7 @@ def _get_msvc2017_env(vc_x64):
If the current environment is a modern MSVC, a copy of it is returned to
allow MSVC 2015 to be used. Otherwise, an MSVC 2017 amd64 environment is
returned.
returned for 64-bit python, and MSVC 2015 for 32-bit python.
"""
# The 32-bit Qt5 install only has an MSVC 2015, while there are 64-bit
......@@ -579,9 +579,31 @@ def _get_msvc2017_env(vc_x64):
return os.environ.copy()
if not vc_x64:
raise Exception(
'32-bit Qt5 builds must be run from an MSVC 2015 environment'
)
# 32-bit builds require MSVC 2015
print()
print('Searching for MSVC 2015')
vcvarsall_bat = None
vs140_comn_tools = os.environ.get('VS140COMNTOOLS')
if vs140_comn_tools:
vs140_comn_tools = pathlib.Path(vs140_comn_tools)
vcvarsall_bat = (
vs140_comn_tools.parent.parent / 'VC' / 'vcvarsall.bat'
)
if vcvarsall_bat and not vcvarsall_bat.exists():
raise Exception(
'unable to load Visual C++ build environment; '
'execute the "Visual C++ 2015 Command Prompt" '
'application shortcut or a vcsvars64.bat file'
)
msvc_env = _get_msvc_env(vcvarsall_bat, ['amd64' if vc_x64 else 'x86'])
return _validate_legacy_msvc_env(msvc_env, vc_x64, "2015")
print()
print('Searching for MSVC 2017')
vsdevcmd_bat = None
vswhere = (
......@@ -664,7 +686,10 @@ def _get_msvc2008_env(vc_x64):
raise Exception('Unable to locate MSVC 2008 or Visual C++ for Python')
msvc_env = _get_msvc_env(vcvarsall_bat, ['amd64' if vc_x64 else 'x86'])
return _validate_legacy_msvc_env(msvc_env, vc_x64, "2008")
def _validate_legacy_msvc_env(msvc_env: dict, vc_x64: bool, msvc_ver: str):
# The vcvarsall.bat file (at least for the MS python package) always exits
# with 0, whether or not it errored out. So do some basic sanity checking
# that it printed the proper environment. The bat file for MSVC 2017 looks
......@@ -676,12 +701,12 @@ def _get_msvc2008_env(vc_x64):
or (not vc_x64 and ('x64' in libpath or 'amd64' in libpath))
or (vc_x64 and 'x64' not in libpath and 'amd64' not in libpath)
):
raise Exception('Unable to determine MSVC 2008 environment')
raise Exception('Unable to determine MSVC %s environment' % msvc_ver)
# Visual C++ for Python has '\9.0\', but MSVC 2008 has
# '\Microsoft Visual Studio 9.0\'.
if '9.0\\' not in libpath:
raise Exception('Unable to determine MSVC 2008 environment')
# '\Microsoft Visual Studio 9.0\'. MSVC 2015 is 14.0.
if '9.0\\' not in libpath and '14.0\\' not in libpath:
raise Exception('Unable to determine MSVC %s environment' % msvc_ver)
return msvc_env
......
......@@ -30,9 +30,9 @@ Python packages), and building PyQt5 from source.
If the script is run without an activated ``Visual C++`` command prompt,
it will search for and use the appropriate compiler. This allows it to
be run from an MSYS shell. Currently, it only searches for VC++ 14.1
to build PyQt5, which limits it to a 64 bit build. To use another
compiler, simply run from an activated ``Visual C++`` command prompt
be run from an MSYS shell. It searches for VC++ 14.1 for 64-bit PyQt5
builds, and VC++14.0 for 32-bit builds. To use another compiler, simply
run from an activated ``Visual C++`` command prompt
(e.g ``Visual C++ 2015 Command Prompt``).
From the prompt, change to the root of this repository. e.g.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment