mckib2 / pygrappa

Python implementations of GRAPPA-like algorithms.
https://pygrappa.readthedocs.io/en/latest/
MIT License
62 stars 13 forks source link

Windows installation #17

Closed mckib2 closed 5 years ago

mckib2 commented 5 years ago

Windows 10, python 3.7.3, pygrappa v0.4.0.

In clean virtual environment command: pip install pygrappa

Output:

... building 'pygrappa.cgrappa' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

mckib2 commented 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

mckib2 commented 5 years ago

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...

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.

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 which SIZEOF_VOID_P is defined based on whether MS_WIN64 is defined or not. The solution is to pass -DMS_WIN64 when compiling with MinGW.

Summary:

mckib2 commented 5 years ago

Running basic_cgrappa.py needs scipy.