Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0fdce850
Commit
0fdce850
authored
May 16, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16314: Added support for the LZMA compression in distutils.
parent
76c1452f
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
181 additions
and
94 deletions
+181
-94
Doc/distutils/apiref.rst
Doc/distutils/apiref.rst
+20
-12
Doc/distutils/builtdist.rst
Doc/distutils/builtdist.rst
+28
-19
Doc/distutils/sourcedist.rst
Doc/distutils/sourcedist.rst
+7
-1
Doc/whatsnew/3.5.rst
Doc/whatsnew/3.5.rst
+3
-0
Lib/distutils/archive_util.py
Lib/distutils/archive_util.py
+12
-9
Lib/distutils/command/bdist.py
Lib/distutils/command/bdist.py
+2
-1
Lib/distutils/command/bdist_dumb.py
Lib/distutils/command/bdist_dumb.py
+2
-1
Lib/distutils/tests/test_archive_util.py
Lib/distutils/tests/test_archive_util.py
+104
-50
Lib/distutils/tests/test_bdist.py
Lib/distutils/tests/test_bdist.py
+1
-1
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Doc/distutils/apiref.rst
View file @
0fdce850
...
...
@@ -868,23 +868,31 @@ tarballs or zipfiles.
Create an archive file (eg. ``zip`` or ``tar``). *base_name* is the name of
the file to create, minus any format-specific extension; *format* is the
archive format: one of ``zip``, ``tar``, ``ztar``, or ``gztar``. *root_dir* is
a directory that will be the root directory of the archive; ie. we typically
``chdir`` into *root_dir* before creating the archive. *base_dir* is the
directory where we start archiving from; ie. *base_dir* will be the common
prefix of all files and directories in the archive. *root_dir* and *base_dir*
both default to the current directory. Returns the name of the archive file.
archive format: one of ``zip``, ``tar``, ``gztar``, ``bztar``, ``xztar``, or
``ztar``. *root_dir* is a directory that will be the root directory of the
archive; ie. we typically ``chdir`` into *root_dir* before creating the
archive. *base_dir* is the directory where we start archiving from; ie.
*base_dir* will be the common prefix of all files and directories in the
archive. *root_dir* and *base_dir* both default to the current directory.
Returns the name of the archive file.
.. versionchanged: 3.5
Added support for the ``xztar`` format.
.. function:: make_tarball(base_name, base_dir[, compress='gzip', verbose=0, dry_run=0])
'Create an (optional compressed) archive as a tar file from all files in and
under *base_dir*. *compress* must be ``'gzip'`` (the default), ``'compress'``,
``'bzip2'``, or ``None``. Both :program:`tar` and the compression utility named
by *compress* must be on the default program search path, so this is probably
Unix-specific. The output tar file will be named :file:`base_dir.tar`,
possibly plus the appropriate compression extension (:file:`.gz`, :file:`.bz2`
or :file:`.Z`). Return the output filename.
under *base_dir*. *compress* must be ``'gzip'`` (the default),
``'bzip2'``, ``'xz'``, ``'compress'``, or ``None``. For the ``'compress'``
method the compression utility named by :program:`compress` must be on the
default program search path, so this is probably Unix-specific. The output
tar file will be named :file:`base_dir.tar`, possibly plus the appropriate
compression extension (``.gz``, ``.bz2``, ``.xz`` or ``.Z``). Return the
output filename.
.. versionchanged: 3.5
Added support for the ``xz`` compression.
.. function:: make_zipfile(base_name, base_dir[, verbose=0, dry_run=0])
...
...
Doc/distutils/builtdist.rst
View file @
0fdce850
...
...
@@ -72,13 +72,19 @@ The available formats for built distributions are:
+-------------+------------------------------+---------+
| Format | Description | Notes |
+=============+==============================+=========+
| ``gztar`` | gzipped tar file |
(1),(3)
|
| ``gztar`` | gzipped tar file |
\(1)
|
| | (:file:`.tar.gz`) | |
+-------------+------------------------------+---------+
| ``bztar`` | bzipped tar file | |
| | (:file:`.tar.bz2`) | |
+-------------+------------------------------+---------+
| ``xztar`` | xzipped tar file | |
| | (:file:`.tar.xz`) | |
+-------------+------------------------------+---------+
| ``ztar`` | compressed tar file | \(3) |
| | (:file:`.tar.Z`) | |
+-------------+------------------------------+---------+
| ``tar`` | tar file (:file:`.tar`) |
\(3)
|
| ``tar`` | tar file (:file:`.tar`) |
|
+-------------+------------------------------+---------+
| ``zip`` | zip file (:file:`.zip`) | (2),(4) |
+-------------+------------------------------+---------+
...
...
@@ -94,6 +100,9 @@ The available formats for built distributions are:
| ``msi`` | Microsoft Installer. | |
+-------------+------------------------------+---------+
.. versionchanged: 3.5
Added support for the ``xztar`` format.
Notes:
...
...
@@ -104,8 +113,7 @@ Notes:
default on Windows
(3)
requires external utilities: :program:`tar` and possibly one of :program:`gzip`,
:program:`bzip2`, or :program:`compress`
requires external :program:`compress` utility.
(4)
requires either external :program:`zip` utility or :mod:`zipfile` module (part
...
...
@@ -119,21 +127,22 @@ You don't have to use the :command:`bdist` command with the :option:`--formats`
option; you can also use the command that directly implements the format you're
interested in. Some of these :command:`bdist` "sub-commands" actually generate
several similar formats; for instance, the :command:`bdist_dumb` command
generates all the "dumb" archive formats (``tar``, ``ztar``, ``gztar``, and
``zip``), and :command:`bdist_rpm` generates both binary and source RPMs. The
:command:`bdist` sub-commands, and the formats generated by each, are:
+--------------------------+-----------------------+
| Command | Formats |
+==========================+=======================+
| :command:`bdist_dumb` | tar, ztar, gztar, zip |
+--------------------------+-----------------------+
| :command:`bdist_rpm` | rpm, srpm |
+--------------------------+-----------------------+
| :command:`bdist_wininst` | wininst |
+--------------------------+-----------------------+
| :command:`bdist_msi` | msi |
+--------------------------+-----------------------+
generates all the "dumb" archive formats (``tar``, ``gztar``, ``bztar``,
``xztar``, ``ztar``, and ``zip``), and :command:`bdist_rpm` generates both
binary and source RPMs. The :command:`bdist` sub-commands, and the formats
generated by each, are:
+--------------------------+-------------------------------------+
| Command | Formats |
+==========================+=====================================+
| :command:`bdist_dumb` | tar, gztar, bztar, xztar, ztar, zip |
+--------------------------+-------------------------------------+
| :command:`bdist_rpm` | rpm, srpm |
+--------------------------+-------------------------------------+
| :command:`bdist_wininst` | wininst |
+--------------------------+-------------------------------------+
| :command:`bdist_msi` | msi |
+--------------------------+-------------------------------------+
The following sections give details on the individual :command:`bdist_\*`
commands.
...
...
Doc/distutils/sourcedist.rst
View file @
0fdce850
...
...
@@ -32,12 +32,18 @@ to create a gzipped tarball and a zip file. The available formats are:
| ``bztar`` | bzip2'ed tar file | |
| | (:file:`.tar.bz2`) | |
+-----------+-------------------------+---------+
| ``xztar`` | xz'ed tar file | |
| | (:file:`.tar.xz`) | |
+-----------+-------------------------+---------+
| ``ztar`` | compressed tar file | \(4) |
| | (:file:`.tar.Z`) | |
+-----------+-------------------------+---------+
| ``tar`` | tar file (:file:`.tar`) | |
+-----------+-------------------------+---------+
.. versionchanged: 3.5
Added support for the ``xztar`` format.
Notes:
(1)
...
...
@@ -54,7 +60,7 @@ Notes:
requires the :program:`compress` program. Notice that this format is now
pending for deprecation and will be removed in the future versions of Python.
When using any ``tar`` format (``gztar``, ``bztar``, ``ztar`` or
When using any ``tar`` format (``gztar``, ``bztar``, ``
xztar``, ``
ztar`` or
``tar``), under Unix you can specify the ``owner`` and ``group`` names
that will be set for each member of the archive.
...
...
Doc/whatsnew/3.5.rst
View file @
0fdce850
...
...
@@ -338,6 +338,9 @@ distutils
option to enable parallel building of extension modules.
(Contributed by Antoine Pitrou in :issue:`5309`.)
* Added support for the LZMA compression.
(Contributed by Serhiy Storchaka in :issue:`16314`.)
doctest
-------
...
...
Lib/distutils/archive_util.py
View file @
0fdce850
...
...
@@ -57,26 +57,28 @@ def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
"""Create a (possibly compressed) tar file from all the files under
'base_dir'.
'compress' must be "gzip" (the default), "
compress", "bzip2", or None.
(compress
will be deprecated in Python 3.2)
'compress' must be "gzip" (the default), "
bzip2", "xz", "compress", or
None. ("compress"
will be deprecated in Python 3.2)
'owner' and 'group' can be used to define an owner and a group for the
archive that is being built. If not provided, the current owner and group
will be used.
The output tar file will be named 'base_dir' + ".tar", possibly plus
the appropriate compression extension (".gz", ".bz2" or ".Z").
the appropriate compression extension (".gz", ".bz2"
, ".xz"
or ".Z").
Returns the output filename.
"""
tar_compression
=
{
'gzip'
:
'gz'
,
'bzip2'
:
'bz2'
,
None
:
''
,
'compress'
:
''
}
compress_ext
=
{
'gzip'
:
'.gz'
,
'bzip2'
:
'.bz2'
,
'compress'
:
'.Z'
}
tar_compression
=
{
'gzip'
:
'gz'
,
'bzip2'
:
'bz2'
,
'xz'
:
'xz'
,
None
:
''
,
'compress'
:
''
}
compress_ext
=
{
'gzip'
:
'.gz'
,
'bzip2'
:
'.bz2'
,
'xz'
:
'.xz'
,
'compress'
:
'.Z'
}
# flags for compression program, each element of list will be an argument
if
compress
is
not
None
and
compress
not
in
compress_ext
.
keys
():
raise
ValueError
(
"bad value for 'compress': must be None, 'gzip', 'bzip2' "
"or 'compress'"
)
"bad value for 'compress': must be None, 'gzip', 'bzip2'
,
"
"
'xz'
or 'compress'"
)
archive_name
=
base_name
+
'.tar'
if
compress
!=
'compress'
:
...
...
@@ -177,6 +179,7 @@ def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
ARCHIVE_FORMATS
=
{
'gztar'
:
(
make_tarball
,
[(
'compress'
,
'gzip'
)],
"gzip'ed tar-file"
),
'bztar'
:
(
make_tarball
,
[(
'compress'
,
'bzip2'
)],
"bzip2'ed tar-file"
),
'xztar'
:
(
make_tarball
,
[(
'compress'
,
'xz'
)],
"xz'ed tar-file"
),
'ztar'
:
(
make_tarball
,
[(
'compress'
,
'compress'
)],
"compressed tar file"
),
'tar'
:
(
make_tarball
,
[(
'compress'
,
None
)],
"uncompressed tar file"
),
'zip'
:
(
make_zipfile
,
[],
"ZIP file"
)
...
...
@@ -197,8 +200,8 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
"""Create an archive file (eg. zip or tar).
'base_name' is the name of the file to create, minus any format-specific
extension; 'format' is the archive format: one of "zip", "tar", "ztar",
or "g
ztar".
extension; 'format' is the archive format: one of "zip", "tar", "
g
ztar",
"bztar", "xztar", or "
ztar".
'root_dir' is a directory that will be the root directory of the
archive; ie. we typically chdir into 'root_dir' before creating the
...
...
Lib/distutils/command/bdist.py
View file @
0fdce850
...
...
@@ -61,13 +61,14 @@ class bdist(Command):
'nt'
:
'zip'
}
# Establish the preferred order (for the --help-formats option).
format_commands
=
[
'rpm'
,
'gztar'
,
'bztar'
,
'ztar'
,
'tar'
,
format_commands
=
[
'rpm'
,
'gztar'
,
'bztar'
,
'
xztar'
,
'
ztar'
,
'tar'
,
'wininst'
,
'zip'
,
'msi'
]
# And the real information.
format_command
=
{
'rpm'
:
(
'bdist_rpm'
,
"RPM distribution"
),
'gztar'
:
(
'bdist_dumb'
,
"gzip'ed tar file"
),
'bztar'
:
(
'bdist_dumb'
,
"bzip2'ed tar file"
),
'xztar'
:
(
'bdist_dumb'
,
"xz'ed tar file"
),
'ztar'
:
(
'bdist_dumb'
,
"compressed tar file"
),
'tar'
:
(
'bdist_dumb'
,
"tar file"
),
'wininst'
:
(
'bdist_wininst'
,
...
...
Lib/distutils/command/bdist_dumb.py
View file @
0fdce850
...
...
@@ -22,7 +22,8 @@ class bdist_dumb(Command):
"platform name to embed in generated filenames "
"(default: %s)"
%
get_platform
()),
(
'format='
,
'f'
,
"archive format to create (tar, ztar, gztar, zip)"
),
"archive format to create (tar, gztar, bztar, xztar, "
"ztar, zip)"
),
(
'keep-temp'
,
'k'
,
"keep the pseudo-installation tree around after "
+
"creating the distribution archive"
),
...
...
Lib/distutils/tests/test_archive_util.py
View file @
0fdce850
This diff is collapsed.
Click to expand it.
Lib/distutils/tests/test_bdist.py
View file @
0fdce850
...
...
@@ -21,7 +21,7 @@ class BuildTestCase(support.TempdirManager,
# what formats does bdist offer?
formats
=
[
'bztar'
,
'gztar'
,
'msi'
,
'rpm'
,
'tar'
,
'wininst'
,
'zip'
,
'ztar'
]
'wininst'
,
'
xztar'
,
'
zip'
,
'ztar'
]
found
=
sorted
(
cmd
.
format_command
)
self
.
assertEqual
(
found
,
formats
)
...
...
Misc/NEWS
View file @
0fdce850
...
...
@@ -47,6 +47,8 @@ Core and Builtins
Library
-------
- Issue #16314: Added support for the LZMA compression in distutils.
- Issue #21804: poplib now supports RFC 6856 (UTF8).
- Issue #18682: Optimized pprint functions for builtin scalar types.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment