File: installing.rst

package info (click to toggle)
python-zstandard 0.23.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,936 kB
  • sloc: ansic: 41,411; python: 8,665; makefile: 22; sh: 14
file content (131 lines) | stat: -rw-r--r-- 4,845 bytes parent folder | download | duplicates (2)
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
.. _installing:

==========
Installing
==========

This package is uploaded to PyPI at https://pypi.python.org/pypi/zstandard.
So, to install this package::

   $ pip install zstandard

Binary wheels are made available for some platforms. If you need to
install from a source distribution, all you should need is a working C
compiler and the Python development headers/libraries. On many Linux
distributions, you can install a ``python-dev`` or ``python-devel``
package to provide these dependencies.

Packages are also uploaded to Anaconda Cloud at
https://anaconda.org/indygreg/zstandard. See that URL for how to install
this package with ``conda``.

Requirements
============

This package is designed to run with Python 3.8, 3.9, 3.10, and 3.11
on common platforms (Linux, Windows, and OS X). On PyPy (both PyPy2 and PyPy3)
we support version 6.0.0 and above. x86 and x86_64 are well-tested on Windows.
Only x86_64 is well-tested on Linux and macOS.

CFFI Backend
============

In order to build/run the CFFI backend/bindings (as opposed to the C/Rust
backend/bindings), you will need the ``cffi`` package installed. The
``cffi`` package is listed as an optional dependency in ``setup.py`` and
may not get picked up by your packaging tools.

If you wish to use the CFFI backend (or have to use it since your Python
distribution doesn't support compiled extensions using the Python C API -
this is the case for PyPy for example), be sure you have the ``cffi``
package installed.

One way to do this is to depend on the ``zstandard[cffi]`` dependency.
e.g. ``pip install 'zstandard[cffi]'`` or add ``zstandard[cffi]`` to your
pip requirements file.

Legacy Format Support
=====================

To enable legacy zstd format support which is needed to handle files compressed
with zstd < 1.0 you need to provide an installation option::

   $ pip install zstandard --install-option="--legacy"

and since pip 7.0 it is possible to have the following line in your
requirements.txt::

   zstandard --install-option="--legacy"

All Install Arguments
=====================

``setup.py`` accepts the following arguments for influencing behavior:

``--legacy``
   Enable legacy zstd format support in order to read files produced with
   zstd < 1.0.

``--system-zstd``
   Attempt to link against the zstd library present on the system instead
   of the version distributed with the extension.

   The Python extension only supports linking against a specific version of
   zstd. So if the system version differs from what is expected, a build
   or runtime error will result.

``--warning-as-errors``
   Treat all compiler warnings as errors.

``--no-c-backend``
   Do not compile the C-based backend.

``--no-cffi-backend``
   Do not compile the CFFI-based backend.

``--rust-backend``
   Compile the Rust backend (not yet feature complete).

If you invoke ``setup.py``, simply pass the aforementioned arguments. e.g.
``python3.9 setup.py --no-cffi-backend``. If using ``pip``, use the
``--install-option`` argument. e.g.
``python3.9 -m pip install zstandard --install-option --warning-as-errors``.
Or in a pip requirements file: ``zstandard --install-option="--rust-backend"``.

In addition, the following environment variables are recognized:

``ZSTD_EXTRA_COMPILER_ARGS``
   Extra compiler arguments to compile the C backend with.

``ZSTD_WARNINGS_AS_ERRORS``
   Equivalent to ``setup.py --warnings-as-errors``.

Building Against External libzstd
=================================

By default, this package builds and links against a single file ``libzstd``
bundled as part of the package distribution. This copy of ``libzstd`` is
statically linked into the extension.

It is possible to point ``setup.py`` at an external (typically system provided)
``libzstd``. To do this, simply pass ``--system-zstd`` to ``setup.py``. e.g.

``python3.9 setup.py --system-zstd`` or ``python3.9 -m pip install zstandard
--install-option="--system-zstd"``.

When building against a system libzstd, you may need to specify extra compiler
arguments to help Python's build system find the external library. These can
be specified via the ``ZSTD_EXTRA_COMPILER_ARGS`` environment variable. e.g.
``ZSTD_EXTRA_COMPILER_ARGS="-I/usr/local/include" python3.9 setup.py
--system-zstd``.

``python-zstandard`` can be sensitive about what version of ``libzstd`` it links
against. For best results, point this package at the exact same version of
``libzstd`` that it bundles. See the bundled ``zstd/zstd.h`` or
``zstd/zstd.c`` for which version that is.

When linking against an external ``libzstd``, not all package features may be
available. Notably, the ``multi_compress_to_buffer()`` and
``multi_decompress_to_buffer()`` APIs are not available, as these rely on private
symbols in the ``libzstd`` C source code, which require building against private
header files to use.