Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in installing wxPython on windows #1

Open
oleksis opened this issue Jan 14, 2022 · 21 comments
Open

Error in installing wxPython on windows #1

oleksis opened this issue Jan 14, 2022 · 21 comments

Comments

@oleksis
Copy link
Owner

oleksis commented Jan 14, 2022

Operating system: Windows 11
wxPython version & source: self-built
Python version & source: Python 3.10.1

Description of the problem:

Code Example (click to expand)
pip install -r .\requirements.txt
python build.py dox etg --nodoc sip build
C:\Users\user\PYTHON\wxPython\Phoenix\build.py:42: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.dep_util import newer, newer_group
Will build using: "C:\Users\user\PYTHON\wxPython\Phoenix\venv\Scripts\python.exe"
3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]
Python's architecture is 64bit
cfg.VERSION: 4.1.2a1

Running command: dox
Checking for C:\Users\user\PYTHON\wxPython\Phoenix\bin\doxygen-1.8.8-win32.exe...
/mnt/c/Users/user/PYTHON/wxPython/Phoenix/bin/doxygen-1.8.8-win32.exe
"C:\WINDOWS\system32\bash.exe" -l -c "cd C:/Users/user/PYTHON/wxPython/Phoenix/ext/wxWidgets/docs/doxygen && ./regen.sh xml"
/bin/bash: line 0: cd: C:/Users/user/PYTHON/wxPython/Phoenix/ext/wxWidgets/docs/doxygen: No such file or directory
Command '"C:\WINDOWS\system32\bash.exe" -l -c "cd C:/Users/user/PYTHON/wxPython/Phoenix/ext/wxWidgets/docs/doxygen && ./regen.sh xml"' failed with exit code 1.
Finished command: dox (0m58.8s)
@oleksis
Copy link
Owner Author

oleksis commented Jan 14, 2022

Try-pyMSVC branch commit without using the hard links

Can see the build_wx command setuptools.msvc not found "Microsoft C++ Build Tools" (Fix the issue in creating the hard links)

git checkout try-pyMSVC
python -m pip install -r .\requirements.txt
# Apply [build.py.patch](https://github.com/oleksis/Phoenix/commit/8c97512543a48c75a43a683fb962fb17d937c245.patch)
Write-Output $(Invoke-WebRequest -URI https://github.com/oleksis/Phoenix/commit/8c97512543a48c75a43a683fb962fb17d937c245.patch -UseBasicParsing).RawContent | git apply -
python build.py dox etg --nodoc sip build
C:\Users\user\PYTHON\wxPython\Phoenix\build.py:42: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.dep_util import newer, newer_group
Will build using: "C:\Users\user\PYTHON\wxPython\Phoenix\venv\Scripts\python.exe"
3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]
Python's architecture is 64bit
cfg.VERSION: 4.1.2a1

Running command: dox
Checking for C:\Users\user\PYTHON\wxPython\Phoenix\bin\doxygen-1.8.8-win32.exe...
/mnt/c/Users/user/PYTHON/wxPython/Phoenix/bin/doxygen-1.8.8-win32.exe
"C:\WINDOWS\system32\bash.exe" -l -c "cd /mnt/c/Users/user/PYTHON/wxPython/Phoenix/ext/wxWidgets/docs/doxygen && WX_SKIP_DOXYGEN_VERSION_CHECK=1 ./regen.sh xml"
warning: Tag 'PERL_PATH' at line 542 of file 'Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: Tag 'MSCGEN_PATH' at line 550 of file 'Doxyfile' has become obsolete.
         To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"


Finished command: dox (2m24.819s)
Running command: etg
"C:\Users\user\PYTHON\wxPython\Phoenix\venv\Scripts\python.exe" etg/taskbar.py --sip --nodoc
WARNING: Method wxTaskBarIcon::PopupMenu already exists in C++ class API, can not create a property.
"C:\Users\user\PYTHON\wxPython\Phoenix\venv\Scripts\python.exe" etg/notifmsg.py --sip --nodoc
"C:\Users\user\PYTHON\wxPython\Phoenix\venv\Scripts\python.exe" etg/grid.py --sip --nodoc
WARNING: Method wxGridActivationSource::Origin already exists in C++ class API, can not create a property.
Finished command: etg (0m13.115s)
Running command: sip
Running SIP code generator on: sip/gen/_adv.sip
sipAPI_adv.h is changed, copying...
sip_advcmodule.cpp is changed, copying...
sip_advwxANIDecoder.cpp is changed, copying...
sip_advwxAnimationCtrl.cpp is changed, copying...
sip_advwxAnimationDecoder.cpp is changed, copying...
sip_advwxBitmapComboBox.cpp is changed, copying...
sip_advwxGenericAnimationCtrl.cpp is changed, copying...
sip_advwxGIFDecoder.cpp is changed, copying...
sip_advwxNotificationMessage.cpp is changed, copying...
sip_advwxOwnerDrawnComboBox.cpp is changed, copying...
sip_advwxPropertySheetDialog.cpp is changed, copying...
sip_advwxSplashScreen.cpp is changed, copying...
sip_advwxTaskBarIcon.cpp is changed, copying...
sip_advwxWizard.cpp is changed, copying...
sip_advwxWizardPage.cpp is changed, copying...
sip_advwxWizardPageSimple.cpp is changed, copying...
Running SIP code generator on: sip/gen/_grid.sip
Finished command: sip (0m26.715s)
Running command: build
Running command: build_wx
Command '"C:\Users\user\PYTHON\wxPython\Phoenix\venv\Scripts\python.exe" -c "import setuptools, distutils.msvc9compiler as msvc; mc = msvc.MSVCCompiler(); mc.initialize(); print(mc.cc)"' failed with exit code 1.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\distutils\msvc9compiler.py", line 371, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Users\user\PYTHON\wxPython\Phoenix\venv\lib\site-packages\setuptools\msvc.py", line 140, in msvc9_query_vcvarsall
    return EnvironmentInfo(arch, ver).return_env()
  File "C:\Users\user\PYTHON\wxPython\Phoenix\venv\lib\site-packages\setuptools\msvc.py", line 1740, in return_env
    [self.VCIncludes,
  File "C:\Users\user\PYTHON\wxPython\Phoenix\venv\lib\site-packages\setuptools\msvc.py", line 1282, in VCIncludes
    return [join(self.si.VCInstallDir, 'Include'),
  File "C:\Users\user\PYTHON\wxPython\Phoenix\venv\lib\site-packages\setuptools\msvc.py", line 840, in VCInstallDir
    raise distutils.errors.DistutilsPlatformError(msg)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
Finished command: build_wx (0m1.31s)
Finished command: build (0m1.31s)

@oleksis
Copy link
Owner Author

oleksis commented Jan 14, 2022

How use pyMSVC with the same API like setuptools.msvc ?
Otherwise you would need to use the "x86_x64 Cross Tools Command Prompt for VS 2019"

Phoenix/build.py

Lines 791 to 804 in d85cb0e

cmd = "import setuptools, distutils.msvc9compiler as msvc; " \
"mc = msvc.MSVCCompiler(); " \
"mc.initialize(); " \
"print(mc.cc)"
CC = runcmd('"%s" -c "%s"' % (PYTHON, cmd), getOutput=True, echoCmd=False)
if not quiet:
msg("MSVC: %s" % CC)
# Now get the environment variables which that compiler needs from
# its vcvarsall.bat command and load them into this process's
# environment.
cmd = "import setuptools, distutils.msvc9compiler as msvc; " \
"arch = msvc.PLAT_TO_VCVARS[msvc.get_platform()]; " \
"env = msvc.query_vcvarsall(msvc.VERSION, arch); " \

@oleksis
Copy link
Owner Author

oleksis commented Jan 14, 2022

Copy of the output from the script:

Output `msvc.py` (click to expand)
python .\msvc.py
Machine architecture: x64
Build architecture: x64

== Windows SDK ================================================
   version:     10.0
   sdk version: 10.0.22000.0
   path:        C:\Program Files (x86)\Windows Kits\10\

   -- Universal CRT -------------------------------------------
      version: 10.0.22000.0
      path: C:\Program Files (x86)\Windows Kits\10\
      lib directory: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\ucrt\x64\
      headers directory: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\ucrt\
   -- ATLMFC --------------------------------------------------
      path:         None
      include path: None
      lib path:     None

== Extension SDK ==============================================
   path: None

== TypeScript =================================================
   path: C:\Program Files (x86)\Microsoft SDKs\TypeScript\4.3

== HTML Help ==================================================
   path: None

== .NET =======================================================
   version:    v4.0.30319.2

   -- x86 -----------------------------------------------------
      version: v4.0.30319.2
      path:
   -- x64 -----------------------------------------------------
      version: v4.0.30319.2
      path:    C:\WINDOWS\Microsoft.NET\Framework64
   -- NETFX ---------------------------------------------------
      path:         None
      x86 exe path: None
      x64 exe path: None

== Visual C ===================================================
   version: 14.29.30133
   path:    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC

   -- Tools ---------------------------------------------------
      version:     14.29.30133
      path:        C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133
      redist path: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Redist\MSVC\14.29.30133\
   -- F# ------------------------------------------------------
      path: None
   -- DLL -----------------------------------------------------
      version: v142-14.29.30139.0
      path:    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Redist\MSVC\14.29.30133\x64\Microsoft.VC142.CRT

== MSBuild ====================================================
   version: 16.11.2.50704
   path:    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe

== Python =====================================================
  version: 3.10.1.final.0
  architecture: x64
  library: Python310.lib
  libs: ['C:\\Users\\user\\PYTHON\\wxPython\\Phoenix\\venv\\Scripts\\libs']
  includes: ['C:\\Users\\user\\PYTHON\\wxPython\\Phoenix\\venv\\Scripts\\include']





__VSCMD_PREINIT_PATH:
    C:\Users\user\PYTHON\wxPython\Phoenix\venv\Scripts
    C:\Program Files\PowerShell\7
    C:\WINDOWS\system32
    C:\WINDOWS
    C:\WINDOWS\system32\wbem
    C:\ProgramData\Oracle\Java\javapath
    C:\Program Files (x86)\Intel\iCLS Client
    C:\Program Files\Intel\iCLS Client
    C:\WINDOWS\System32\WindowsPowerShell\v1.0
    C:\Program Files\Intel\WiFi\bin
    C:\Program Files\Common Files\Intel\WirelessCommon
    C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
    C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT
    C:\WINDOWS\System32\Wbem
    C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    C:\WINDOWS\System32\OpenSSH\
    C:\Program Files\Intel\WiFi\bin\
    C:\Program Files\Common Files\Intel\WirelessCommon\
    C:\Qt\5.15.2\msvc2019_64\bin\
    C:\Qt\vcpkg\
    C:\Qt\vcpkg\installed\x64-windows\tools\protobuf
    C:\Qt\vcpkg\installed\x64-windows\tools\openssl
    C:\Qt\Tools\CMake_64\bin\
    C:\Program Files\Microsoft VS Code\bin
    C:\Program Files\Python39
    C:\Program Files\Python39\Scripts
    C:\Users\user\AppData\Roaming\Python\Python39\Scripts
    C:\Program Files (x86)\GnuWin32\bin
    C:\Users\user\bin
    C:\Program Files\PostgreSQL\14\bin
    C:\Program Files\Vim\vim82
    C:\Program Files\Git\cmd
    C:\Program Files\dotnet\
    C:\Program Files\PowerShell\7\
    C:\Program Files\Docker\Docker\resources\bin
    C:\ProgramData\DockerDesktop\version-bin
    C:\WINDOWS\system32
    C:\WINDOWS
    C:\WINDOWS\System32\Wbem
    C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    C:\WINDOWS\System32\OpenSSH\
    C:\Program Files\nodejs\
    C:\Users\user\AppData\Local\Programs\Python\Python310\Scripts\
    C:\Users\user\AppData\Local\Programs\Python\Python310\
    C:\Users\user\AppData\Roaming\.dotnet
    C:\Users\user\AppData\Local\Microsoft\WindowsApps
    C:\Program Files (x86)\GitHub CLI\
    C:\Users\user\AppData\Local\GitHubDesktop\bin
    C:\Users\user\.dotnet\tools
    C:\Users\user\AppData\Local\Programs\Rancher Desktop\resources\resources\win32\bin
    C:\Users\user\AppData\Local\Programs\Rancher Desktop\resources\resources\linux\bin
    C:\Users\user\.dotnet\tools
    C:\Users\user\AppData\Local\Microsoft\WindowsApps
    C:\Users\user\AppData\Roaming\npm

Platform: x64

VSCMD_ARG_app_plat: Desktop

VSCMD_ARG_HOST_ARCH: x64

VSCMD_ARG_TGT_ARCH: x64

__VSCMD_script_err_count: 0

VCIDEInstallDir: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\VC\

VCToolsVersion: 14.29.30133

VCToolsInstallDir: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\

VCINSTALLDIR: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\

VCToolsRedistDir: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Redist\MSVC\14.29.30133\

Path:
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow
    C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64
    C:\Program Files (x86)\Microsoft SDKs\TypeScript\4.3
    C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319
    C:\Users\user\PYTHON\wxPython\Phoenix\venv\Scripts
    C:\Program Files\PowerShell\7
    C:\WINDOWS\system32
    C:\WINDOWS
    C:\WINDOWS\system32\wbem
    C:\ProgramData\Oracle\Java\javapath
    C:\Program Files (x86)\Intel\iCLS Client
    C:\Program Files\Intel\iCLS Client
    C:\WINDOWS\System32\WindowsPowerShell\v1.0
    C:\Program Files\Intel\WiFi\bin
    C:\Program Files\Common Files\Intel\WirelessCommon
    C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
    C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT
    C:\WINDOWS\System32\Wbem
    C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    C:\WINDOWS\System32\OpenSSH\
    C:\Program Files\Intel\WiFi\bin\
    C:\Program Files\Common Files\Intel\WirelessCommon\
    C:\Qt\5.15.2\msvc2019_64\bin\
    C:\Qt\vcpkg\
    C:\Qt\vcpkg\installed\x64-windows\tools\protobuf
    C:\Qt\vcpkg\installed\x64-windows\tools\openssl
    C:\Qt\Tools\CMake_64\bin\
    C:\Program Files\Microsoft VS Code\bin
    C:\Program Files\Python39
    C:\Program Files\Python39\Scripts
    C:\Users\user\AppData\Roaming\Python\Python39\Scripts
    C:\Program Files (x86)\GnuWin32\bin
    C:\Users\user\bin
    C:\Program Files\PostgreSQL\14\bin
    C:\Program Files\Vim\vim82
    C:\Program Files\Git\cmd
    C:\Program Files\dotnet\
    C:\Program Files\PowerShell\7\
    C:\Program Files\Docker\Docker\resources\bin
    C:\ProgramData\DockerDesktop\version-bin
    C:\WINDOWS\system32
    C:\WINDOWS
    C:\WINDOWS\System32\Wbem
    C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    C:\WINDOWS\System32\OpenSSH\
    C:\Program Files\nodejs\
    C:\Users\user\AppData\Local\Programs\Python\Python310\Scripts\
    C:\Users\user\AppData\Local\Programs\Python\Python310\
    C:\Users\user\AppData\Roaming\.dotnet
    C:\Users\user\AppData\Local\Microsoft\WindowsApps
    C:\Program Files (x86)\GitHub CLI\
    C:\Users\user\AppData\Local\GitHubDesktop\bin
    C:\Users\user\.dotnet\tools
    C:\Users\user\AppData\Local\Programs\Rancher Desktop\resources\resources\win32\bin
    C:\Users\user\AppData\Local\Programs\Rancher Desktop\resources\resources\linux\bin
    C:\Users\user\.dotnet\tools
    C:\Users\user\AppData\Local\Microsoft\WindowsApps
    C:\Users\user\AppData\Roaming\npm

LIB:
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x64
    C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x64
    C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64

Include:
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include
    C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0
    C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt
    C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\cppwinrt
    C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\shared
    C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\um
    C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\winrt

LIBPATH:
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x64
    C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.22000.0
    C:\Program Files (x86)\Windows Kits\10\References\10.0.22000.0
    C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319

VSCMD_VER: 16.11.9

__devinit_path: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\devinit\devinit.exe

VSINSTALLDIR: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\

DevEnvDir: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\

VisualStudioVersion: 16.0

VS160COMNTOOLS: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\

UniversalCRTSdkDir: C:\Program Files (x86)\Windows Kits\10\

WindowsSdkVerBinPath: C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\

UCRTVersion: 10.0.22000.0

WindowsSDKLibVersion: 10.0.22000.0\

WindowsSDKVersion: 10.0.22000.0\

WindowsSdkDir: C:\Program Files (x86)\Windows Kits\10\\

WindowsLibPath:
    C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.22000.0
    C:\Program Files (x86)\Windows Kits\10\References\10.0.22000.0

WindowsSdkBinPath: C:\Program Files (x86)\Windows Kits\10\bin\

DISTUTILS_USE_SDK: 1

MSSDK: C:\Program Files (x86)\Windows Kits\10\

__DOTNET_PREFERRED_BITNESS: 64

FrameworkDir: C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\

FrameworkVersion: v4.0.30319.2

__DOTNET_ADD_64BIT: 1

FrameworkDIR64: C:\WINDOWS\Microsoft.NET\Framework64\

FrameworkVersion64: v4.0.30319.2

Framework40Version: v4.0

@kdschlosser
Copy link

I am going to download wxPython and install python 3.10 and tinker about with it for a bit.

@kdschlosser
Copy link

ok replace this code in setup.py

def checkCompiler(quiet=False):
    if isWindows:
        # Make sure that the compiler that Python wants to use can be found.
        # It will terminate if the compiler is not found or other exceptions
        # are raised.

        cmd = "import setuptools, distutils.msvc9compiler as msvc; " \
              "mc = msvc.MSVCCompiler(); " \
              "mc.initialize(); " \
              "print(mc.cc)"
        CC = runcmd('"%s" -c "%s"' % (PYTHON, cmd), getOutput=True, echoCmd=False)
        if not quiet:
            msg("MSVC: %s" % CC)

        # Now get the environment variables which that compiler needs from
        # its vcvarsall.bat command and load them into this process's
        # environment.
        cmd = "import setuptools, distutils.msvc9compiler as msvc; " \
              "arch = msvc.PLAT_TO_VCVARS[msvc.get_platform()]; " \
              "env = msvc.query_vcvarsall(msvc.VERSION, arch); " \
              "print(env)"
        env = eval(runcmd('"%s" -c "%s"' % (PYTHON, cmd), getOutput=True, echoCmd=False))

        def _b(v):
            return str(v)
            #if PY2:
            #    return bytes(v)
            #else:
            #    return bytes(v, 'utf8')

        os.environ['PATH'] = _b(env['path'])
        os.environ['INCLUDE'] = _b(env['include'])
        os.environ['LIB'] = _b(env['lib'])
        os.environ['LIBPATH'] = _b(env['libpath'])

    # NOTE: SIP is now generating code with scoped-enums. Older linux
    # platforms like what we're using for builds, and also TravisCI for
    # example, are using GCC versions that are still defaulting to C++98,
    # so this flag is needed to turn on the C++11 mode. If this flag
    # causes problems with other non-Windows, non-Darwin compilers then
    # we'll need to make this a little smarter about what flag (if any)
    # needs to be used.
    #
    # NOTE 2: SIP changed its output such that this doesn't appear to be
    # needed anymore, but we'll leave the code in place to make it easy to
    # turn it back on again if/when needed.
    if False and not isWindows and not isDarwin:
        stdflag = '-std=c++11'
        curflags = os.environ.get('CXXFLAGS', '')
        if stdflag not in curflags:
            os.environ['CXXFLAGS'] = '{} {}'.format(stdflag, curflags)
    #print('**** Using CXXFLAGS:', os.environ.get('CXXFLAGS', ''))

with this code

def checkCompiler(quiet=False):
    if isWindows:
        import msvc
        if not msvc.environment.visual_c.version.startswith('14.2'):
            raise RuntimeError('MSVC compiler needs to be >= 14.2')

    # NOTE: SIP is now generating code with scoped-enums. Older linux
    # platforms like what we're using for builds, and also TravisCI for
    # example, are using GCC versions that are still defaulting to C++98,
    # so this flag is needed to turn on the C++11 mode. If this flag
    # causes problems with other non-Windows, non-Darwin compilers then
    # we'll need to make this a little smarter about what flag (if any)
    # needs to be used.
    #
    # NOTE 2: SIP changed its output such that this doesn't appear to be
    # needed anymore, but we'll leave the code in place to make it easy to
    # turn it back on again if/when needed.
    if False and not isWindows and not isDarwin:
        stdflag = '-std=c++11'
        curflags = os.environ.get('CXXFLAGS', '')
        if stdflag not in curflags:
            os.environ['CXXFLAGS'] = '{} {}'.format(stdflag, curflags)
    #print('**** Using CXXFLAGS:', os.environ.get('CXXFLAGS', ''))

and put the mscv.py and vswhere.py files into the same folder as build.py

if you want to use the pyMSVC library instead of adding files then change this code

        import msvc
        if not msvc.environment.visual_c.version.startswith('14.2'):
            raise RuntimeError('MSVC compiler needs to be >= 14.2')

to this

        import pyMSVC
        if not pyMSVC.environment.visual_c.version.startswith('14.2'):
            raise RuntimeError('MSVC compiler needs to be >= 14.2')

and you will be off and running.

Sooo easy to do isn't it?? That's why I made the library the way I did.

@oleksis
Copy link
Owner Author

oleksis commented Jan 14, 2022

Work with the changes

See you working in the package pyMSVC and i will like integrate to build.py.

pyMSVC is in PyPI ?

@oleksis
Copy link
Owner Author

oleksis commented Jan 14, 2022

I have integrated pyMSVC towards the build.py in this branch

If you can try that branch. I would like the output of 'pyMSVC.setup_environment()' to be optional or using logging. DEBUG=True for example

@oleksis
Copy link
Owner Author

oleksis commented Jan 14, 2022

  • pyMSVC which minimum version of Python works ?
  • in the pyMSVC setup.py you can add 'python_requires' and 'classifiers'

@oleksis
Copy link
Owner Author

oleksis commented Jan 14, 2022

@kdschlosser Here the output using pyMSVC package

Setting up Windows build environment, please wait.....
Machine architecture: x64
Build architecture: x64

== Windows SDK ================================================
   version:     10.0
   sdk version: 10.0.22000.0
   path:        C:\Program Files (x86)\Windows Kits\10\

   -- Universal CRT -------------------------------------------
      version: 10.0.22000.0
      path: C:\Program Files (x86)\Windows Kits\10\
      lib directory: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\ucrt\x64\
      headers directory: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\ucrt\
   -- ATLMFC --------------------------------------------------
      path:         C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\ATLMFC
      include path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\ATLMFC\include
      lib path:     C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\ATLMFC\lib\x64

== Extension SDK ==============================================
   path: None

== TypeScript =================================================
   path: C:\Program Files (x86)\Microsoft SDKs\TypeScript\4.3

== HTML Help ==================================================
   path: None

== .NET =======================================================
   version:    v4.8.3761.2

   -- x86 -----------------------------------------------------
      version: v4.8.3761.2
      path:
   -- x64 -----------------------------------------------------
      version: v4.8.3761.2
      path:    C:\WINDOWS\Microsoft.NET\Framework64
   -- NETFX ---------------------------------------------------
      path:         None
      x86 exe path: None
      x64 exe path: None

== Visual C ===================================================
   version: 14.30.30709
   path:    C:\Program Files\Microsoft Visual Studio\2022\Community\VC

   -- Tools ---------------------------------------------------
      version:     14.30.30705
      path:        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705
      redist path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.30.30704\
   -- F# ------------------------------------------------------
      path: None
   -- DLL -----------------------------------------------------
      version: v143-14.30.30708.0
      path:    C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.30.30704\x64\Microsoft.VC143.CRT

== MSBuild ====================================================
   version: 17.0.0.52104
   path:    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe

== Python =====================================================
  version: 3.10.1.final.0
  architecture: x64
  library: Python310.lib
  libs: ['C:\\Users\\user\\PYTHON\\wxPython\\Phoenix\\venv\\Scripts\\libs']
  includes: ['C:\\Users\\user\\PYTHON\\wxPython\\Phoenix\\venv\\Scripts\\include']

Now we don't need to use the "x86_x64 Cross Tools Command Prompt for VS 20xy"

@oleksis
Copy link
Owner Author

oleksis commented Jan 14, 2022

@kdschlosser
Copy link

If you can try that branch. I would like the output of 'pyMSVC.setup_environment()' to be optional or using logging. DEBUG=True for example

I plan on doing that. This is still a work in progress to see if we can get it compiling.

Now we don't need to use the "x86_x64 Cross Tools Command Prompt for VS 20xy"
Not sure what you mean.

pyMSVC which minimum version of Python works ?
I added type hinting so Ptyhon 3.4+. If I remove the type hinting python 2.7 and 3.4+

in the pyMSVC setup.py you can add 'python_requires' and 'classifiers'
They can be added.

As a note. If you build using build.py in wxPython you can have it download pyMSVC only for the purpose of building wxPython. You would need to use setuptools and when you call setup do it like this.

setup(
    name='dummy_build',
    script_args=['build'],
    setup_requires=['pyMSVC'],
    dependency_links = [
        'https://github.com/kdschlosser/python_msvc/tarball/master/#egg=pyMSVC'
    ],
)

doing that will download pyMSVC from github and place it into a folder called .eggs and that folder gets added to sys.path so the modules in it can be imported. This way pyMSVC will not get installed into the users library at all. calling setup is only for the purpose of using the mechanics to download and make available pyMSVC for the purpose of building wxPython.

@kdschlosser
Copy link

my question is this.. does wxPython compile properly??

@oleksis
Copy link
Owner Author

oleksis commented Jan 15, 2022

Now we don't need to use the "x86_x64 Cross Tools Command Prompt for VS 20xy"
Not sure what you mean.

In wxPython the build.py require distutils.msvc9compiler -> vcvarsall.bat therefore it must be compiled using "Visual Studio Tools VC - x86_x64 Cross Tools Command Prompt for VS 2019"

pyMSVC which minimum version of Python works ?
I added type hinting so Ptyhon 3.4+. If I remove the type hinting python 2.7 and 3.4+

I would recommend you to continue with typing, because Python 2 reached its final life cycle

As a note. If you build using build.py in wxPython you can have it download pyMSVC only for the purpose of building wxPython. You would need to use setuptools and when you call setup do it like this.

setup(
    name='dummy_build',
    script_args=['build'],
    setup_requires=['pyMSVC'],
    dependency_links = [
        'https://github.com/kdschlosser/python_msvc/tarball/master/#egg=pyMSVC'
    ],
)

I try that in the branch "try-pyMSVC" and send the PR to the repo with the changes for work pyMSVC from git repository. pyMSVC need define the install_requires if you planning public to PyPI

doing that will download pyMSVC from github and place it into a folder called .eggs and that folder gets added to sys.path so the modules in it can be imported. This way pyMSVC will not get installed into the users library at all. calling setup is only for the purpose of using the mechanics to download and make available pyMSVC for the purpose of building wxPython.

for wxPython only include for "requirements/devel.txt"

@oleksis
Copy link
Owner Author

oleksis commented Jan 15, 2022

my question is this.. does wxPython compile properly??

Compile successfully with the changes made to build.py in the wxPython repository and the PR towards python_msvc repository

@kdschlosser
Copy link

It's up to @RobinD42 if he wants to add a dependency or if he would rather add it directly to wxPython. I personally feel it would be better for him to add it directly to wxPython instead of relying on an external dependency.

I wasn't planning on adding it to pypi. I can if needs be. Because the library doesn't deal in absolute paths like distutils and setuptools there shouldn't be an issue with it working properly for several years. The single biggest mistake that setuptools and distutils makes it is calls the vcvars* batch files to set up the environment and those files do not always set up a proper build environment.

I did want to mention to you since you saw the setup_environment function.

You can remove the whole version checking portion of the code from build.py and all that needs to be added is this

import pyMSVC

environment = pyMSVC.setup_environment(minimum_c_version=14.2)

pyMSVC will handle collecting the proper compiler and if one is not found it will raise an exception.

@wschmid4711234
Copy link

I guess you're a genius, writing this! After fixing that error (see my issue here), I guess I could have used this, and I would have been very happy. But now I've found out, that installing Python 3.9 instead of Python 3.10 on Windows 10 solved that problem. Thought I'd share, and that you might be interested - fwiw.

@kdschlosser
Copy link

Yeah we know that downgrading the Python version will fix the issue. But that is a band-aide and all band-aides eventually fall off. We need to get everything up and running properly with Python 3.10 and since my MSVC library uses comtypes had to get comtypes fixed so it would work in > Python 3.6 and get a release done up. The goal is to remove the MSVC library from being included with wxPython and instead have it added to the requirements. This also poses it's own set of issues because setuptools deprecated the mechanism that installs build only requirements into a temporary build folder and not into the users site packages.

That pyMSVC library has taken a long time to develop. Microsoft has no consistency with installations of Visual Studio, Visual C any of the SDKs or build tools. it's a complete mess. I didn't want to use hard coded paths to look for thing and I didn't want to do recursive searches for things in the file system. I also didn't want to have to create a process to collect information either.

The current MSVC library is the result of that.

@wschmid4711234
Copy link

Great, of course you're right. Thank you for your work.

@Ctibor67
Copy link

Ctibor67 commented Dec 9, 2022

I have windows 11. I tried Python 3.11, 3.10, 3.7 and the corresponding wheels wxpython (all 64 bit). I haven't found any combination that doesn't cause the installation to crash. Can you advise me on specific functional packages for installation in Windows 11? I still get the error: whl is not a supported wheel on this platform.

@oleksis
Copy link
Owner Author

oleksis commented Dec 9, 2022

@Ctibor67
Copy link

Ctibor67 commented Dec 9, 2022

Oh nice. Thanks. It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants