Skip to content

Commit 6ec8f54

Browse files
Add support for linking against zlib-rs and libbzip2-rs
1 parent 5918085 commit 6ec8f54

5 files changed

Lines changed: 416 additions & 100 deletions

File tree

Doc/using/configure.rst

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ Dependencies to build optional modules are:
7171
* - Dependency
7272
- Minimum version
7373
- Python module
74-
* - `libbz2 <https://sourceware.org/bzip2/>`_
74+
* - `libbz2 <https://sourceware.org/bzip2/>`_ or
75+
`libbzip2-rs <https://github.com/trifectatechfoundation/libbzip2-rs>`_ [1]_
7576
-
7677
- :mod:`bz2`
7778
* - `libffi <https://sourceware.org/libffi/>`_
@@ -82,47 +83,54 @@ Dependencies to build optional modules are:
8283
- :mod:`lzma`
8384
* - `libmpdec <https://www.bytereef.org/mpdecimal/doc/libmpdec/>`_
8485
- 2.5.0
85-
- :mod:`decimal` [1]_
86+
- :mod:`decimal` [2]_
8687
* - `libreadline <https://tiswww.case.edu/php/chet/readline/rltop.html>`_ or
87-
`libedit <https://www.thrysoee.dk/editline/>`_ [2]_
88+
`libedit <https://www.thrysoee.dk/editline/>`_ [3]_
8889
-
8990
- :mod:`readline`
9091
* - `libuuid <https://linux.die.net/man/3/libuuid>`_
9192
-
92-
- ``_uuid`` [3]_
93-
* - `ncurses <https://gnu.org/software/ncurses/ncurses.html>`_ [4]_
93+
- ``_uuid`` [4]_
94+
* - `ncurses <https://gnu.org/software/ncurses/ncurses.html>`_ [5]_
9495
-
9596
- :mod:`curses`
9697
* - `OpenSSL <https://openssl-library.org/>`_
9798
- | 3.0.18 recommended
9899
| (1.1.1 minimum)
99-
- :mod:`ssl`, :mod:`hashlib` [5]_
100+
- :mod:`ssl`, :mod:`hashlib` [6]_
100101
* - `SQLite <https://sqlite.org/>`_
101102
- 3.15.2
102103
- :mod:`sqlite3`
103104
* - `Tcl/Tk <https://www.tcl-lang.org/>`_
104105
- 8.5.12
105106
- :mod:`tkinter`, :ref:`IDLE <idle>`, :mod:`turtle`
106-
* - `zlib <https://www.zlib.net>`_
107-
- 1.2.2.1
107+
* - `zlib <https://www.zlib.net>`_,
108+
`zlib-ng <https://github.com/zlib-ng/zlib-ng>`_, or
109+
`zlib-rs <https://github.com/trifectatechfoundation/zlib-rs/>`_ [7]_
110+
- | 1.2.2.1 (zlib, zlib-ng)
111+
| 0.6.0 (zlib-rs)
108112
- :mod:`zlib`, :mod:`gzip`, :mod:`ensurepip`
109113
* - `zstd <https://facebook.github.io/zstd/>`_
110114
- 1.4.5
111115
- :mod:`compression.zstd`
112116

113-
.. [1] If *libmpdec* is not available, the :mod:`decimal` module will use
117+
.. [1] See :option:`--with-bzip2` for choosing the backend for the
118+
:mod:`bz2` module.
119+
.. [2] If *libmpdec* is not available, the :mod:`decimal` module will use
114120
a pure-Python implementation.
115-
.. [2] See :option:`--with-readline` for choosing the backend for the
121+
.. [3] See :option:`--with-readline` for choosing the backend for the
116122
:mod:`readline` module.
117-
.. [3] The :mod:`uuid` module uses ``_uuid`` to generate "safe" UUIDs.
123+
.. [4] The :mod:`uuid` module uses ``_uuid`` to generate "safe" UUIDs.
118124
See the module documentation for details.
119-
.. [4] The :mod:`curses` module requires the ``libncurses`` or ``libncursesw``
125+
.. [5] The :mod:`curses` module requires the ``libncurses`` or ``libncursesw``
120126
library.
121127
The :mod:`curses.panel` module additionally requires the ``libpanel`` or
122128
``libpanelw`` library.
123-
.. [5] If OpenSSL is not available, the :mod:`hashlib` module will use
129+
.. [6] If OpenSSL is not available, the :mod:`hashlib` module will use
124130
bundled implementations of several hash functions.
125131
See :option:`--with-builtin-hashlib-hashes` for *forcing* usage of OpenSSL.
132+
.. [7] See :option:`--with-zlib` for choosing the backend for the
133+
:mod:`zlib` module.
126134
127135
Note that the table does not include all optional modules; in particular,
128136
platform-specific modules like :mod:`winreg` are not listed here.
@@ -1113,6 +1121,54 @@ Libraries options
11131121

11141122
.. versionadded:: next
11151123

1124+
.. option:: --with-zlib=zlib|zlib-ng|zlib-rs
1125+
1126+
Designate the zlib implementation to build the :mod:`zlib` module against.
1127+
1128+
* ``zlib``: Use the system zlib library, found via ``pkg-config`` or as
1129+
``libz``.
1130+
* ``zlib-ng``: Same detection as ``zlib``, but fail unless the detected
1131+
library is `zlib-ng <https://github.com/zlib-ng/zlib-ng>`__.
1132+
* ``zlib-rs``: Use `zlib-rs
1133+
<https://github.com/trifectatechfoundation/zlib-rs/>`__, found via
1134+
``pkg-config`` as ``libz_rs``.
1135+
1136+
Without this option (or with ``--with-zlib=auto``, the default), the system
1137+
zlib is used when found; configure only fails when an implementation was
1138+
requested explicitly but cannot be found.
1139+
1140+
.. versionadded:: next
1141+
1142+
.. option:: --without-zlib
1143+
1144+
Don't build the :mod:`zlib` module, even when a zlib library is present
1145+
(built by default when one is found).
1146+
1147+
.. versionadded:: next
1148+
1149+
.. option:: --with-bzip2=bzip2|bzip2-rs
1150+
1151+
Designate the bzip2 implementation to build the :mod:`bz2` module against.
1152+
1153+
* ``bzip2``: Use the system bzip2 library, found via ``pkg-config`` or as
1154+
``libbz2``.
1155+
* ``bzip2-rs``: Use `libbzip2-rs
1156+
<https://github.com/trifectatechfoundation/libbzip2-rs>`__, found via
1157+
``pkg-config`` as ``libbz2_rs``.
1158+
1159+
Without this option (or with ``--with-bzip2=auto``, the default), the
1160+
system bzip2 is used when found; configure only fails when an
1161+
implementation was requested explicitly but cannot be found.
1162+
1163+
.. versionadded:: next
1164+
1165+
.. option:: --without-bzip2
1166+
1167+
Don't build the :mod:`bz2` module, even when a bzip2 library is present
1168+
(built by default when one is found).
1169+
1170+
.. versionadded:: next
1171+
11161172
.. option:: --with-libm=STRING
11171173

11181174
Override ``libm`` math library to *STRING* (default is system-dependent).

Doc/whatsnew/3.16.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,18 @@ Build changes
823823

824824
(Contributed by Serhiy Storchaka in :gh:`136687`.)
825825

826+
* Add the :option:`--with-zlib` and :option:`--with-bzip2` :program:`configure`
827+
options to select the zlib and bzip2 implementations used to build the
828+
:mod:`zlib` and :mod:`bz2` modules. In addition to the default system
829+
libraries, they can build against `zlib-rs
830+
<https://github.com/trifectatechfoundation/zlib-rs/>`__ and `libbzip2-rs
831+
<https://github.com/trifectatechfoundation/libbzip2-rs>`__, and
832+
``--with-zlib=zlib-ng`` verifies that the detected zlib is `zlib-ng
833+
<https://github.com/zlib-ng/zlib-ng>`__. :option:`--without-zlib` and
834+
:option:`--without-bzip2` exclude the modules from the build.
835+
836+
(Contributed by Stan Ulbrych in :gh:`139314`.)
837+
826838

827839
C API changes
828840
=============
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Add the :option:`--with-zlib` and :option:`--with-bzip2` :program:`configure`
2+
options to select the zlib and bzip2 implementations used to build the
3+
:mod:`zlib` and :mod:`bz2` modules. In addition to the default system
4+
libraries, they can build against `zlib-rs
5+
<https://github.com/trifectatechfoundation/zlib-rs/>`__ and `libbzip2-rs
6+
<https://github.com/trifectatechfoundation/libbzip2-rs>`__, and
7+
``--with-zlib=zlib-ng`` verifies that the detected zlib is `zlib-ng
8+
<https://github.com/zlib-ng/zlib-ng>`__. :option:`--without-zlib` and
9+
:option:`--without-bzip2` exclude the modules from the build.

0 commit comments

Comments
 (0)