Closed mckib2 closed 5 years ago
Looks like official documentation suggests "Microsoft Visual C++ Build Tools" is the correct answer, but I'm going to try with MinGW to see if it'll work
The computer I had access to that had Windows 10 did not give me admin rights. So all steps below assume no admin rights (part of the reason I couldn't go with VS C++ 14.0 option, requires admin rights to install...)
First try...
Download Python 3.7.3 64-bit
Download official MinGW, only comes in 32-bit flavor
Add to PATH
Find vcruntime140.dll
online, download it and put in pythonpath/libs
Modify cygwinccompiler.py according to https://github.com/tgalal/yowsup/issues/2494 :
@cesardmoro edit your cygwinccompiler.py and download vcruntime140.dll and paste into pythonpath/libs
def get_msvcr(): """Include the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. """ msc_pos = sys.version.find('MSC v.') if msc_pos != -1: msc_ver = sys.version[msc_pos+6:msc_pos+10] if msc_ver == '1300': # MSVC 7.0 return ['msvcr70'] elif msc_ver == '1310': # MSVC 7.1 return ['msvcr71'] elif msc_ver == '1400': # VS2005 / MSVC 8.0 return ['msvcr80'] elif msc_ver == '1500': # VS2008 / MSVC 9.0 return ['msvcr90'] elif msc_ver == '1600': # VS2010 / MSVC 10.0 return ['msvcr100'] elif msc_ver == '1700': # Visual Studio 2012 / Visual C++ 11.0 return ['msvcr110'] elif msc_ver == '1800': # Visual Studio 2013 / Visual C++ 12.0 return ['msvcr120'] elif msc_ver == '1900': # Visual Studio 2015 / Visual C++ 14.0 # "msvcr140.dll no longer exists" http://blogs.msdn.com/b/vcblog/archive/2014/06/03/visual-studio-14-ctp.aspx return ['vcruntime140'] else: raise ValueError("Unknown MS Compiler version %s " % msc_ver)
run pip install --global-option build_ext --global-option --compiler=mingw32 pygrappa
(see https://github.com/pypa/pip/issues/18#issuecomment-73703672)
Unfortunately this leads to an error stemming from a mismatch between MinGW and Python, 32 bit and 64 bit respectively (see https://github.com/kivy/cymunk/issues/52#issuecomment-455525698).
Let's try again, this time with 64 bit MinGW...
If you have a 32-bit development machine, change every occurrence of C:\dev\msys64 with C:\dev\msys32 below. However, it's
<current year>
, get a 64-bit machine.Download msys2-x86_64-latest.exe and run it. If your development machine is 32-bit, download msys2-i686-latest.exe instead. Make sure to set the install directory to C:\dev\msys64 (C:\dev\msys32 for 32-bit). Choose to run MSYS2 right now.
In the MSYS2 shell, execute the following. Hint: if you right click the title bar, go to Options -> Keys and tick "Ctrl+Shift+letter shortcuts" you can use Ctrl+Shift+V to paste in the MSYS shell.
pacman -Syuu Close the MSYS2 shell once you're asked to. There are now 3 MSYS subsystems installed: MSYS2, MinGW32 and MinGW64. They can respectively be launched from C:\dev\msys64\msys2.exe, C:\dev\msys64\mingw32.exe and C:\dev\msys64\mingw64.exe. If the installer created any shortcuts to open shells for these subsystems, you can update them to these locations to get pretty icons. Each subsystem provides an environment to build Windows applications. The MSYS2 environment is for building POSIX compliant software on Windows using an emulation layer. The MinGW32/64 subsystems are for building native Windows applications using a linux toolchain (gcc, bash, etc), targetting respectively 32 and 64 bit Windows. We will install our PATH such that these tools can be called from regular cmd.exe as well, and we need only use the MinGW subsystem to install/update MSYS2 packages or if our build setup requires a *nix shell. Hint: after starting up MSYS2, the prompt will say which version you launched.
Reopen MSYS2 (doesn't matter which version, since we're merely installing packages). Repeatedly run the following command until it says there are no further updates. You might have to restart your shell again.
pacman -Syuu Now that MSYS2 is fully up-to-date we will install GCC and common build tools. When you are queried to select packages and confirm the installation just press enter:
pacman -S --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain \ git subversion mercurial \ mingw-w64-i686-cmake mingw-w64-x86_64-cmake Add C:\dev\msys64\mingw64\bin and C:\dev\msys64\mingw32\bin, in that order, to your PATH. Note that MSYS2 also puts a lot of other tools in this directory, most notably Python. So put these entries below any other tools you might have installed in your PATH.
def get_msvcr(): """Include the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. """ msc_pos = sys.version.find('MSC v.') if msc_pos != -1: msc_ver = sys.version[msc_pos+6:msc_pos+10] if msc_ver == '1300': # MSVC 7.0 return ['msvcr70'] elif msc_ver == '1310': # MSVC 7.1 return ['msvcr71'] elif msc_ver == '1400': # VS2005 / MSVC 8.0 return ['msvcr80'] elif msc_ver == '1500': # VS2008 / MSVC 9.0 return ['msvcr90'] elif msc_ver == '1600': # VS2010 / MSVC 10.0 return ['msvcr100'] elif msc_ver == '1916': # Visual Studio 2015 / Visual C++ 14.0 # "msvcr140.dll no longer exists" http://blogs.msdn.com/b/vcblog/archive/2014/06/03/visual-studio-14-ctp.aspx return ['vcruntime140'] else: raise ValueError("Unknown MS Compiler version %s " % msc_ver)
pip install --global-option build_ext --global-option --compiler=mingw32 --global-option -DMS_WIN64 pygrappa
. We need to explicitly give option -DMS_WIN64
as in https://github.com/cython/cython/issues/2670#issuecomment-432212671:
@gui36 I have a similar issue with my code and had a discussion in the cython-users Google group. The problem is in the header
pyport.h
, in whichSIZEOF_VOID_P
is defined based on whetherMS_WIN64
is defined or not. The solution is to pass-DMS_WIN64
when compiling with MinGW.
Summary:
Running basic_cgrappa.py needs scipy.
Windows 10, python 3.7.3, pygrappa v0.4.0.
In clean virtual environment command:
pip install pygrappa
Output: