Skip to content

Using Visual C Build Tools instead of Visual Studio on Windows

Vibhakar Solanki edited this page Sep 19, 2021 · 5 revisions

MSVC

Environment

MSVC is used mainly to support Python 3.5 and higher versions. To compile for Python 3.5 there's more than one tool to use for compilation although the actually used compiler is basically the same. Visual C++ Build Tools is the smallest one among all of them. If you already have Visual Studio 2015 you do not need this guide and can instead compile normally.

  1. Get Visual C++ Build Tools (~5GB total size) and install the following components from the "visual c++ build tools" section: "Windows 10 SDK (version)", "Visual C++ tools for CMake", "C++/CLI support", "VC++ 2015.3 v14.00 (v140) toolset for desktop)".

  2. Open cmd.exe in <python.exe folder> (shift + right click)

  3. Upgrade pip and setuptools*

  4. Get sdl2 and glew DLLs and headers:

    python -m pip install kivy.deps.sdl2 kivy.deps.glew
    python -m pip install kivy.deps.sdl2_dev kivy.deps.glew_dev
    
    :: optionally install GStreamer + headers
    python -m pip install kivy.deps.gstreamer kivy.deps.gstreamer_dev
    
  5. Then Run

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"

    or for VS 2019

    "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat"

    Add you architecture as the first argument (find it using --help)

  6. Set environment variables for compiler:

    set MSSdk=1
    set DISTUTILS_USE_SDK=1
    set LIB=%cd%\libs;%LIB%
    set INCLUDE=%cd%\include;%INCLUDE%
    
  7. Set environment variables for Kivy:

    set USE_SDL2=1
    set USE_GSTREAMER=0
    
    :: optionally
    set USE_GSTREAMER=1
    
  8. git clone https://github.com/kivy/kivy

*The setuptools Python package version must be at least 24.0. according to Python's wiki

Clone this wiki locally