Skip to content

Windows Binaries Generation

Jorj X. McKie edited this page Jun 17, 2020 · 9 revisions

This is a "How To" install PyMuPDF and MuPDF from sources on Windows.

You need a Visual Studio 2019 installation to do this. The community edition is sufficient. Starting with version 1.17.0, MuPDF is prepared for builds using VS 2019.

Download PyMuPDF

Go to https://github.com/pymupdf/PyMuPDF/releases and select the desired release. Download Source code (zip) or Source code (tar.gz) and decompress to get a folder named PyMuPDF-1.17.0 (depending on the selected release).

Select your version as appropriate.

Then decompress mupdf-x.xx.x-source.tar.gz (e.g. using 7zip) repeatedly until you get a folder named mupdf-x.xx.x-source.

Go to file /include/mupdf/fitz/config.h and apply the changes recommended in our installation chapter, or replace it with file PyMuPDF-1.17.0\fitz\_config.h of the downloaded PyMuPDF. This is an optional step, which will however reduce your final binary very (!) significantly - from over 30 MB to below 10 MB. But PyMuPDF will also work without this.

At this time, please also apply any other modifications to the MuPDF source that PyMuPDF may require for this specific version.

Now go to folder \platform\win32.

Generate MuPDF

Double click on mupdf.sln in this folder to open with Visual Studio.

In the VS menu select Release and Win32 and build mupdf.sln. This will generate the 32bit version of MuPDF and also build some objects required for the 64bit version.

If you also need a 64bit version, select Release again, but now select x64 and again build mupdf.sln.

Generate PyMuPDF

Confirm that PyMuPDF-1.17.0\setup.py points to the correct MuPDF folders from above, e.g.

    include_dirs=[  # we need the path of the MuPDF's headers
        "./mupdf-x.xx.x-source/include",
        "./mupdf-x.xx.x-source/include/mupdf",

And

    # 32bit
    library_dirs=["./mupdf-x.xx.x-source/platform/win32/Release"],

    # or in case 64bit
    library_dirs=['./mupdf-x.xx.x-source/platform/win32/x64/Release'],

Now generate by invoking python setup.py install.

Done.

Clone this wiki locally