Skip to content

Commit

Permalink
docs/: added page about packaging for Linux distributions.
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-smith-artifex-com committed Jan 4, 2024
1 parent ed6a47d commit a0d536b
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ not generally supported:
command line.


Packaging
---------

See :doc:`packaging`.


Enabling Integrated OCR Support
---------------------------------------------------------

Expand Down
97 changes: 97 additions & 0 deletions docs/packaging.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
.. include:: header.rst


Packaging for Linux distributions
=================================


Requirements
------------

* Python
* MuPDF checkout (including submodules).
* PyMuPDF checkout.
* System packages listed in `scripts/sysinstall.py:g_sys_packages`.
* Python packages listed in `pyproject.toml`.

Extra requirements for running tests:

* Python packages listed in `scripts/gh_release.py:test_packages`.


General steps
-------------

* Build and install MuPDF:

* Install required system packages.
* Run `make install-shared-python` on MuPDF's `Makefile` with at least
these make variables:

* `DESTDIR` set to the install directory, e.g. `/`.
*
`prefix` set to location relative to DESTDIR, such as `/usr/local` or
`/usr`. Must start with `/`.
* `USE_SYSTEM_LIBS=yes`.
* `HAVE_LEPTONICA=yes`.
* `HAVE_TESSERACT=yes`.

* Build and install PyMuPDF:

*
Run `pip install ./PyMuPDF` or `pip wheel ./PyMuPDF` with at least these
environment variables:

*
`PYMUPDF_SETUP_MUPDF_BUILD=` (empty string) to prevent download and build
of hard-coded MuPDF release.
*
`CFLAGS`, `CXXFLAGS` and `LDFLAGS` set to allow visibility of the
installed MuPDF headers and shared libraries.
*
`PYMUPDF_SETUP_IMPLEMENTATIONS=b` to build only the rebased
implementation. [This will become the default in a future release.]

* Run PyMuPDF tests:

* Ensure required Python packages are available.
*
Run `pytest -k "not test_color_count" PyMuPDF` (test `test_color_count` is
known fail if MuPDF is not built with PyMuPDF's custom config.h).


Use of scripts/sysinstall.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`scripts/sysinstall.py` provides a useful example of build commands
that are known to to work, because it does a build, install and test
using a local fake root director and is run regularly by Github action
`.github/workflows/test_sysinstall.yml`.

* Run with `-h` or look at the doc-string to see detailed usage information.
* It uses Debian-style `apt` commands to install system packages.
* By default it assumes local git checkouts `mupdf/` and `PyMuPDF/`.
*
It currently installs only into a fake root directory because `pip` cannot do
a system install; the commands will need to be modified to install into /usr
or /usr/local.

To run a full build, install and test in a local fake root:

.. code-block:: shell
./PyMuPDF/scripts/sysinstall.py
To see what commands would be run without actually running them:

.. code-block:: shell
./PyMuPDF/scripts/sysinstall.py -m 0 -p 0 -t 0
See also
--------

*
`setup.py`'s initial doc-comment has detailed information about the
environment variables used when building PyMuPDF.

0 comments on commit a0d536b

Please sign in to comment.