Open oleksis opened 2 years ago
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)
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"
https://github.com/oleksis/Phoenix/blob/d85cb0e6ea4fe5ea6862d083550f549d6baa3132/build.py#L791-L804
Copy of the output from the script:
I am going to download wxPython and install python 3.10 and tinker about with it for a bit.
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.
Work with the changes
See you working in the package pyMSVC and i will like integrate to build.py
.
pyMSVC is in PyPI ?
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
pyMSVC
which minimum version of Python works ?setup.py
you can add 'python_requires' and 'classifiers'@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"
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.
my question is this.. does wxPython compile properly??
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"
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
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.
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.
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.
Great, of course you're right. Thank you for your work.
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.
Oh nice. Thanks. It works.
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)
```pwsh 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) ```