2014-03-22 03:52:05 +04:00
|
|
|
Building Pillow on Windows
|
|
|
|
==========================
|
|
|
|
|
2018-02-09 12:56:10 +03:00
|
|
|
.. note:: For most people, the `installation instructions
|
|
|
|
<../docs/installation.rst#windows-installation>`_ should
|
|
|
|
be sufficient.
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2020-01-01 23:08:51 +03:00
|
|
|
This page describes the steps necessary to build Pillow using the same
|
|
|
|
scripts used on GitHub Actions and AppVeyor CIs.
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2015-06-17 02:02:32 +03:00
|
|
|
Prerequisites
|
2015-12-02 07:40:16 +03:00
|
|
|
-------------
|
2014-03-22 03:52:05 +04:00
|
|
|
|
|
|
|
|
2020-01-01 23:08:51 +03:00
|
|
|
Compilers
|
|
|
|
^^^^^^^^^
|
2014-04-05 04:05:42 +04:00
|
|
|
|
2020-01-01 23:08:51 +03:00
|
|
|
Download and install:
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2020-02-25 02:00:57 +03:00
|
|
|
* `Microsoft Visual Studio 2017 or newer or Build Tools for Visual Studio 2017 or newer
|
|
|
|
<https://visualstudio.microsoft.com/downloads/>`_
|
|
|
|
(MSVC C++ build tools, and any Windows SDK version required)
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2023-03-06 05:24:00 +03:00
|
|
|
* `CMake 3.15 or newer <https://cmake.org/download/>`_
|
2020-02-25 02:00:57 +03:00
|
|
|
(also available as Visual Studio component C++ CMake tools for Windows)
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2020-04-12 14:50:31 +03:00
|
|
|
* `Ninja <https://ninja-build.org/>`_
|
|
|
|
(optional, use ``--nmake`` if not available; bundled in Visual Studio CMake component)
|
|
|
|
|
2023-06-23 14:52:00 +03:00
|
|
|
* x64: `Netwide Assembler (NASM) <https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D>`_
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2020-01-01 23:08:51 +03:00
|
|
|
Any version of Visual Studio 2017 or newer should be supported,
|
2020-02-25 02:00:57 +03:00
|
|
|
including Visual Studio 2017 Community, or Build Tools for Visual Studio 2019.
|
2014-03-25 20:00:41 +04:00
|
|
|
|
2020-02-25 02:00:57 +03:00
|
|
|
Paths to CMake (if standalone) and NASM must be added to the ``PATH`` environment variable.
|
|
|
|
Visual Studio is found automatically with ``vswhere.exe``.
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2020-01-01 23:08:51 +03:00
|
|
|
Build configuration
|
|
|
|
-------------------
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2023-02-13 06:16:04 +03:00
|
|
|
Run ``build_prepare.py`` to configure the build::
|
|
|
|
|
|
|
|
usage: winbuild\build_prepare.py [-h] [-v] [-d PILLOW_BUILD]
|
|
|
|
[--depends PILLOW_DEPS]
|
2023-06-23 14:52:00 +03:00
|
|
|
[--architecture {x64,ARM64}]
|
2023-02-13 06:16:04 +03:00
|
|
|
[--python PYTHON] [--executable EXECUTABLE]
|
|
|
|
[--nmake] [--no-imagequant] [--no-fribidi]
|
|
|
|
|
|
|
|
Download dependencies and generate build scripts for Pillow.
|
|
|
|
|
|
|
|
options:
|
|
|
|
-h, --help show this help message and exit
|
|
|
|
-v, --verbose print generated scripts
|
|
|
|
-d PILLOW_BUILD, --dir PILLOW_BUILD, --build-dir PILLOW_BUILD
|
|
|
|
build directory (default: 'winbuild\build')
|
|
|
|
--depends PILLOW_DEPS
|
|
|
|
directory used to store cached dependencies (default:
|
|
|
|
'winbuild\depends')
|
2023-06-23 14:52:00 +03:00
|
|
|
--architecture {x64,ARM64}
|
2023-02-13 18:26:00 +03:00
|
|
|
build architecture (default: same as host Python)
|
|
|
|
--python PYTHON Python install directory (default: use host Python)
|
2023-02-13 06:16:04 +03:00
|
|
|
--executable EXECUTABLE
|
2023-02-13 18:26:00 +03:00
|
|
|
Python executable (default: use host Python)
|
2023-02-13 06:16:04 +03:00
|
|
|
--nmake build dependencies using NMake instead of Ninja
|
|
|
|
--no-imagequant skip GPL-licensed optional dependency libimagequant
|
|
|
|
--no-fribidi, --no-raqm
|
|
|
|
skip LGPL-licensed optional dependency FriBiDi
|
|
|
|
|
|
|
|
Arguments can also be supplied using the environment variables PILLOW_BUILD,
|
|
|
|
PILLOW_DEPS, ARCHITECTURE, PYTHON, EXECUTABLE. See winbuild\build.rst for more
|
|
|
|
information.
|
|
|
|
|
|
|
|
**Warning:** The build directory is wiped when ``build_prepare.py`` is run.
|
2020-02-25 02:00:57 +03:00
|
|
|
|
2014-03-22 03:52:05 +04:00
|
|
|
Dependencies
|
|
|
|
------------
|
|
|
|
|
2020-01-01 23:08:51 +03:00
|
|
|
Dependencies will be automatically downloaded by ``build_prepare.py``.
|
|
|
|
By default, downloaded dependencies are stored in ``winbuild\depends``;
|
2023-02-13 06:16:04 +03:00
|
|
|
use the ``--depends`` argument or ``PILLOW_DEPS`` environment variable
|
|
|
|
to override this location.
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2020-01-01 23:08:51 +03:00
|
|
|
To build all dependencies, run ``winbuild\build\build_dep_all.cmd``,
|
2023-02-13 06:16:04 +03:00
|
|
|
or run the individual scripts in order to build each dependency separately.
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2014-04-05 04:05:42 +04:00
|
|
|
Building Pillow
|
|
|
|
---------------
|
|
|
|
|
2020-01-01 23:08:51 +03:00
|
|
|
Once the dependencies are built, run
|
|
|
|
``winbuild\build\build_pillow.cmd install`` to build and install
|
|
|
|
Pillow for the selected version of Python.
|
|
|
|
``winbuild\build\build_pillow.cmd bdist_wheel`` will build wheels
|
|
|
|
instead of installing Pillow.
|
2014-04-05 04:05:42 +04:00
|
|
|
|
2020-08-02 23:14:38 +03:00
|
|
|
You can also use ``winbuild\build\build_pillow.cmd --inplace develop`` to build
|
2020-10-29 14:41:29 +03:00
|
|
|
and install Pillow in develop mode (instead of ``python3 -m pip install --editable``).
|
2020-08-02 23:14:38 +03:00
|
|
|
|
2014-04-05 04:05:42 +04:00
|
|
|
Testing Pillow
|
2014-03-22 03:52:05 +04:00
|
|
|
--------------
|
|
|
|
|
2021-03-29 18:45:12 +03:00
|
|
|
Some binary dependencies (e.g. ``fribidi.dll``) will be stored in the
|
2020-01-01 23:08:51 +03:00
|
|
|
``winbuild\build\bin`` directory; this directory should be added to ``PATH``
|
|
|
|
before running tests.
|
|
|
|
|
2022-04-18 05:28:41 +03:00
|
|
|
Build and install Pillow, then run ``python3 -m pytest`` from the root Pillow
|
|
|
|
directory.
|
2020-01-01 23:08:51 +03:00
|
|
|
|
|
|
|
Example
|
|
|
|
-------
|
|
|
|
|
2023-02-18 12:34:52 +03:00
|
|
|
The following is a simplified version of the script used on AppVeyor::
|
2014-03-22 03:52:05 +04:00
|
|
|
|
2020-06-27 14:39:44 +03:00
|
|
|
set PYTHON=C:\Python38\bin
|
2020-01-01 23:08:51 +03:00
|
|
|
cd /D C:\Pillow\winbuild
|
2023-04-03 00:39:31 +03:00
|
|
|
C:\Python39\bin\python.exe build_prepare.py -v --depends C:\pillow-depends
|
2020-01-01 23:08:51 +03:00
|
|
|
build\build_dep_all.cmd
|
|
|
|
build\build_pillow.cmd install
|
|
|
|
cd ..
|
|
|
|
path C:\Pillow\winbuild\build\bin;%PATH%
|
|
|
|
%PYTHON%\python.exe selftest.py
|
|
|
|
%PYTHON%\python.exe -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests
|
|
|
|
build\build_pillow.cmd bdist_wheel
|