summaryrefslogtreecommitdiff
path: root/docs/installation.rst
blob: a8f9a5be81793229ad44fcc898703fb6a17991e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
Installation
============

.. figure:: images/pike-tree.jpg
    :scale: 50%
    :alt: Picture of pike fish impaled on tree branch
    :align: right

    A pike installation failure.

As a Python package
-------------------

.. |latest| image:: https://img.shields.io/pypi/v/pikepdf.svg
    :alt: pikepdf latest released version on PyPI

|latest|

Most users on Linux, macOS or Windows with x64 systems should take advantage of
the binary wheels to install the Python package.

.. code-block:: bash

    pip install pikepdf

64-bit wheels are available for Windows, Linux and macOS.

32-bit wheels are available for Windows, for use with the 32-bit version of
Python (regardless of the bitness  of Windows). 32-bit wheels for Linux will be
added if anyone uses them.

Binary wheels should work on most systems work on Linux distributions 2007
and newer, macOS 10.11 and newer (for Homebrew), Windows 7 and newer.

Use ``pip install --user pikepdf`` to install the package for the current user
only. Use ``pip install pikepdf`` to install to a virtual environment.

Managed Linux distributions
---------------------------

**Debian, Ubuntu and other APT distributions**

.. |apt| image:: https://repology.org/badge/vertical-allrepos/pikepdf.svg
    :alt: Package status in apt world

|apt|

.. code-block:: bash

    apt install pikepdf

**Fedora 29**

.. |fedora| image:: https://repology.org/badge/version-for-repo/fedora_29/python:pikepdf.svg
    :alt: Fedora 29

.. |rawhide| image:: https://repology.org/badge/version-for-repo/fedora_rawhide/python:pikepdf.svg
    :alt: Fedora Rawhide

|fedora| |rawhide|

.. code-block:: bash

    dnf install python-pikepdf

**ArchLinux**

.. |aur| image:: https://repology.org/badge/version-for-repo/aur/python:pikepdf.svg

|aur|

Available in `ArchLinux User Repository <https://aur.archlinux.org/packages/python-pikepdf/>`_.

.. code-block:: bash

    pacman -S pikepdf

Installing on FreeBSD 11.2
--------------------------

No FreeBSD ports exist, but all of the dependencies are currently available. You can try
something like:

.. code-block:: bash

    pkg install python3 lang/python3
    pkg install py36-lxml qpdf
    pip install --user pikepdf

Building from source
--------------------

**Requirements**

.. |qpdf-version| replace:: 8.4.0

pikepdf requires:

-   a C++11 compliant compiler - GCC (4.8 and up) and clang (3.3 and up); C++14
    is recommended and will produced smaller binaries
-   `pybind11 <https://github.com/pybind/pybind11>`_
-   libqpdf |qpdf-version| or higher from the
    `QPDF <https://github.com/qpdf/qpdf>`_ project.
-   defusedxml - Python package

On Linux the library and headers for libqpdf must be installed because pikepdf
compiles code against it and links to it.

Check `Repology for QPDF <https://repology.org/metapackage/qpdf/badges>`_ to
see if a recent version of QPDF is available for your platform. Otherwise you
must
`build QPDF from source <https://github.com/qpdf/qpdf/blob/master/INSTALL>`_.
(Consider using the binary wheels, which bundle the required version of
libqpdf.)

**Compiling with GCC or Clang**

-  clone this repository
-  install libjpeg, zlib and libqpdf on your platform, including headers
-  ``pip install .``

.. note::

    pikepdf should be built with the same compiler and linker as libqpdf; to be
    precise both **must** use the same C++ ABI. On some platforms, setup.py may
    not pick the correct compiler so one may need to set environment variables
    ``CC`` and ``CXX`` to redirect it. If the wrong compiler is selected,
    ``import pikepdf._qpdf`` will throw an ``ImportError`` about a missing
    symbol.

**On Windows (requires Visual Studio 2015)**

.. |msvc-zip| replace:: qpdf-|qpdf-version|-bin-msvc64.zip

pikepdf requires a C++11 compliant compiler (i.e. Visual Studio 2015 on
Windows). See our continuous integration build script in ``.appveyor.yml``
for detailed and current instructions. Or use the wheels which save this pain.

These instructions require the precompiled binary ``qpdf.dll``. See the QPDF
documentation if you also need to build this DLL from source. Both should be
built with the same compiler. You may not mix and match MinGW and Visual C++
for example.

Running a regular ``pip install`` command will detect the
version of the compiler used to build Python and attempt to build the
extension with it. We must force the use of Visual Studio 2015.

#. Clone this repository.
#. In a command prompt, run:

    .. code-block:: bat

        %VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x64
        set DISTUTILS_USE_SDK=1
        set MSSdk=1

#. Download |msvc-zip| from the `QPDF releases page <https://github.com/qpdf/qpdf/releases>`_.
#. Extract ``bin\qpdfXX.dll`` from the zip file above, where XX is the version
   of the ABI, and copy it to the ``src/pikepdf`` folder in the repository.
#. Run ``pip install .`` in the root directory of the repository.

.. note::

    The user compiling ``pikepdf`` to must have registry editing rights on the
    machine to be able to run the ``vcvarsall.bat`` script.

.. note::

    If you are attempting to build pikepdf because you want to use OCRmyPDF,
    **OCRmyPDF is not supported on Windows** at this time.

Windows runtime requirements
----------------------------

On Windows, the Visual C++ 2015 redistributable packages are a runtime
requirement for this project. It can be found
`here <https://www.microsoft.com/en-us/download/details.aspx?id=48145>`__.

Building the documentation
--------------------------

Documentation is generated using Sphinx and you are currently reading it. To
regenerate it:

.. code-block:: bash

    pip install -r requirements/docs.txt
    cd pikepdf/docs
    make html