Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Doc/library/bz2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,36 @@ One-shot (de)compression
.. versionchanged:: 3.3
Support for multi-stream inputs was added.


Miscellaneous
Comment thread
StanFromIreland marked this conversation as resolved.
-------------

Information about the version of the bzip2 compression library
actually loaded by the interpreter is available through the following
constants.
The version used for building the module is not available,
because the bzip2 library does not provide it.


.. data:: bzlib_version

The version string of the bzip2 compression library
actually loaded by the interpreter.

.. versionadded:: next


.. data:: bzlib_version_info

A named tuple containing the three components of the bzip2 compression
library version actually loaded by the interpreter:
*major*, *minor*, and *patch*. All values are integers.
The components can also be accessed by name, so ``bz2.bzlib_version_info[0]``
is equivalent to ``bz2.bzlib_version_info.major`` and so on.

.. versionadded:: next


.. _bz2-usage-examples:

Examples of usage
Expand Down
41 changes: 38 additions & 3 deletions Doc/library/compression.zstd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -827,10 +827,45 @@ Miscellaneous
The default compression level for Zstandard: ``3``.


.. attribute:: zstd_version_info
Information about the version of the zstd library in use is available through
the following constants:

Version number of the runtime zstd library as a tuple of integers
(major, minor, release).

.. data:: ZSTD_VERSION

The version string of the zstd library that was used for building the module.
This may be different from the zstd library actually used at runtime, which
is available as :const:`zstd_version`.

.. versionadded:: next


.. data:: zstd_version

The version string of the zstd library actually loaded by the interpreter.


.. data:: ZSTD_VERSION_INFO
Comment thread
StanFromIreland marked this conversation as resolved.

A named tuple containing the three components of the zstd library
version that was used for building the module:
*major*, *minor*, and *patch*. All values are integers.
Comment thread
StanFromIreland marked this conversation as resolved.
The components can also be accessed by name, so ``zstd.ZSTD_VERSION_INFO[0]``
is equivalent to ``zstd.ZSTD_VERSION_INFO.major`` and so on.
This may be different from the zstd library actually used at runtime, which
is available as :const:`zstd_version_info`.

.. versionadded:: next


.. data:: zstd_version_info

A named tuple containing the version of the zstd library
actually loaded by the interpreter,
with the same fields as :const:`ZSTD_VERSION_INFO`.

.. versionchanged:: next
It is now a named tuple.


Examples
Expand Down
44 changes: 44 additions & 0 deletions Doc/library/lzma.rst
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,50 @@ Miscellaneous
feature set.


Information about the version of the lzma library in use is available through
the following constants:


.. data:: LZMA_VERSION

The version string of the lzma library that was used for building the module.
This may be different from the lzma library actually used at runtime, which
is available as :const:`lzma_version`.

.. versionadded:: next


.. data:: lzma_version

The version string of the lzma library actually loaded by the interpreter.

.. versionadded:: next


.. data:: LZMA_VERSION_INFO

A named tuple containing the four components of the lzma library
version that was used for building the module:
*major*, *minor*, *patch*, and *stability*.
All values except *stability* are integers; *stability* is ``'alpha'``,
``'beta'``, or ``'stable'``.
The components can also be accessed by name, so ``lzma.LZMA_VERSION_INFO[0]``
is equivalent to ``lzma.LZMA_VERSION_INFO.major`` and so on.
This may be different from the lzma library actually used at runtime, which
is available as :const:`lzma_version_info`.

.. versionadded:: next


.. data:: lzma_version_info

A named tuple containing the version of the lzma library
actually loaded by the interpreter,
with the same fields as :const:`LZMA_VERSION_INFO`.

.. versionadded:: next


.. _filter-chain-specs:

Specifying custom filter chains
Expand Down
48 changes: 43 additions & 5 deletions Doc/library/zlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -479,27 +479,65 @@ the following constants:

The version string of the zlib library that was used for building the module.
This may be different from the zlib library actually used at runtime, which
is available as :const:`ZLIB_RUNTIME_VERSION`.
is available as :const:`zlib_version`.


.. data:: ZLIB_RUNTIME_VERSION
zlib_version

The version string of the zlib library actually loaded by the interpreter.

.. versionadded:: 3.3
Comment thread
StanFromIreland marked this conversation as resolved.
The :const:`!ZLIB_RUNTIME_VERSION` constant.

.. versionadded:: next
The :const:`!zlib_version` alias.


.. data:: ZLIB_VERSION_INFO

A named tuple containing the four components of the zlib library
version that was used for building the module:
*major*, *minor*, *revision*, and *subversion*.
All values are integers.
The components can also be accessed by name, so ``zlib.ZLIB_VERSION_INFO[0]``
is equivalent to ``zlib.ZLIB_VERSION_INFO.major`` and so on.
This may be different from the zlib library actually used at runtime, which
is available as :const:`zlib_version_info`.

.. versionadded:: next


.. data:: zlib_version_info

A named tuple containing the version of the zlib library
actually loaded by the interpreter,
with the same fields as :const:`ZLIB_VERSION_INFO`.

.. versionadded:: next


The following constants are only present if zlib-ng was used to build
the module:


.. data:: ZLIBNG_VERSION

The version string of the zlib-ng library that was used for building the
module if zlib-ng was used. When present, the :data:`ZLIB_VERSION` and
:data:`ZLIB_RUNTIME_VERSION` constants reflect the version of the zlib API
module if zlib-ng was used. When present, the :const:`ZLIB_VERSION` and
:const:`zlib_version` constants reflect the version of the zlib API
provided by zlib-ng.

If zlib-ng was not used to build the module, this constant will be absent.

.. versionadded:: 3.14

.. data:: ZLIBNG_VERSION_INFO

A named tuple containing the three components of the zlib-ng library
version that was used for building the module:
*major*, *minor*, and *revision*. All values are integers.

.. versionadded:: next


.. seealso::

Expand Down
31 changes: 31 additions & 0 deletions Doc/whatsnew/3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ asyncio
socket file created for *path*.
(Contributed by Sam Bull in :gh:`94984`.)

bz2
---

* Added constants :const:`~bz2.bzlib_version` and
:const:`~bz2.bzlib_version_info` which provide information about
the version of the bzip2 compression library in use.
(Contributed by Serhiy Storchaka in :gh:`117404`.)

codecs
------
Expand All @@ -127,6 +134,14 @@ codecs
even when a built-in codec of the same name exists.
(Contributed by Serhiy Storchaka in :gh:`152997`.)

compression.zstd
----------------

* Added constants :const:`~compression.zstd.ZSTD_VERSION` and
:const:`~compression.zstd.ZSTD_VERSION_INFO` which provide information
about the version of the zstd library that was used for building the module.
:const:`~compression.zstd.zstd_version_info` is now a named tuple.
(Contributed by Serhiy Storchaka in :gh:`117404`.)

concurrent.futures
------------------
Expand Down Expand Up @@ -408,6 +423,11 @@ lzma
requires ``lzma`` 5.4.0 or newer while RISC-V requires 5.6.0 or newer.
(Contributed by Chien Wong in :gh:`115988`.)

* Added constants :const:`~lzma.LZMA_VERSION`, :const:`~lzma.lzma_version`,
:const:`~lzma.LZMA_VERSION_INFO`, and :const:`~lzma.lzma_version_info`,
which provide information about the version of the lzma library in use.
(Contributed by Serhiy Storchaka in :gh:`117404`.)


math
----
Expand Down Expand Up @@ -669,6 +689,17 @@ zipfile
by the local file entries of removed members.
(Contributed by Danny Lin in :gh:`51067`.)

zlib
----

* Added constants :const:`~zlib.ZLIB_VERSION_INFO`,
:const:`~zlib.zlib_version_info`, and :const:`~zlib.ZLIBNG_VERSION_INFO`,
which provide information about the version of the zlib and the zlib-ng
libraries in use.
Added :const:`~zlib.zlib_version` as an alias of
:const:`~zlib.ZLIB_RUNTIME_VERSION`.
(Contributed by Serhiy Storchaka in :gh:`117404`.)

.. Add improved modules above alphabetically, not here at the end.

Optimizations
Expand Down
6 changes: 4 additions & 2 deletions Lib/bz2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"""

__all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor",
"open", "compress", "decompress"]
"open", "compress", "decompress",
"bzlib_version", "bzlib_version_info"]

__author__ = "Nadeem Vawda <nadeem.vawda@gmail.com>"

Expand All @@ -14,7 +15,8 @@
import io
import os

from _bz2 import BZ2Compressor, BZ2Decompressor
from _bz2 import (BZ2Compressor, BZ2Decompressor,
bzlib_version, bzlib_version_info)


# Value 0 no longer used
Expand Down
9 changes: 4 additions & 5 deletions Lib/compression/zstd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
'get_frame_size',
'zstd_version',
'zstd_version_info',
'ZSTD_VERSION',
'ZSTD_VERSION_INFO',
'ZstdCompressor',
'ZstdDecompressor',
'ZstdDict',
Expand All @@ -29,13 +31,10 @@
import _zstd
import enum
from _zstd import (ZstdCompressor, ZstdDecompressor, ZstdDict, ZstdError,
get_frame_size, zstd_version)
get_frame_size, zstd_version, ZSTD_VERSION,
zstd_version_info, ZSTD_VERSION_INFO)
from compression.zstd._zstdfile import ZstdFile, open, _nbytes

# zstd_version_number is (MAJOR * 100 * 100 + MINOR * 100 + RELEASE)
zstd_version_info = (*divmod(_zstd.zstd_version_number // 100, 100),
_zstd.zstd_version_number % 100)
"""Version number of the runtime zstd library as a tuple of integers."""

COMPRESSION_LEVEL_DEFAULT = _zstd.ZSTD_CLEVEL_DEFAULT
"""The default compression level for Zstandard, currently '3'."""
Expand Down
1 change: 1 addition & 0 deletions Lib/lzma.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

"LZMACompressor", "LZMADecompressor", "LZMAFile", "LZMAError",
"open", "compress", "decompress", "is_check_supported",
"lzma_version", "lzma_version_info", "LZMA_VERSION", "LZMA_VERSION_INFO",
]

import builtins
Expand Down
26 changes: 24 additions & 2 deletions Lib/test/pythoninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,37 @@ def collect_zlib(info_add):
except ImportError:
return

attributes = ('ZLIB_VERSION', 'ZLIB_RUNTIME_VERSION', 'ZLIBNG_VERSION')
attributes = ('ZLIB_VERSION', 'zlib_version', 'ZLIBNG_VERSION')
copy_attributes(info_add, zlib, 'zlib.%s', attributes)


def collect_bz2(info_add):
Comment thread
StanFromIreland marked this conversation as resolved.
try:
import _bz2
except ImportError:
return

attributes = ('bzlib_version',)
copy_attributes(info_add, _bz2, 'bz2.%s', attributes)


def collect_lzma(info_add):
Comment thread
StanFromIreland marked this conversation as resolved.
try:
import _lzma
except ImportError:
return

attributes = ('LZMA_VERSION', 'lzma_version')
copy_attributes(info_add, _lzma, 'lzma.%s', attributes)


def collect_zstd(info_add):
try:
import _zstd
except ImportError:
return

attributes = ('zstd_version',)
attributes = ('ZSTD_VERSION', 'zstd_version')
copy_attributes(info_add, _zstd, 'zstd.%s', attributes)


Expand Down Expand Up @@ -1334,6 +1354,7 @@ def collect_info(info):
collect_urandom,

collect_builtins,
collect_bz2,
collect_cc,
collect_curses,
collect_datetime,
Expand All @@ -1344,6 +1365,7 @@ def collect_info(info):
collect_gdbm,
collect_get_config,
collect_locale,
collect_lzma,
collect_os,
collect_platform,
collect_pwd,
Expand Down
Loading
Loading