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
67a93b3a
Commit
67a93b3a
authored
Dec 05, 2018
by
Serhiy Storchaka
Committed by
GitHub
Dec 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-34738: Add directory entries in ZIP files created by distutils. (GH-9419)
parent
55f41e45
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
10 deletions
+27
-10
Lib/distutils/archive_util.py
Lib/distutils/archive_util.py
+8
-0
Lib/distutils/tests/test_archive_util.py
Lib/distutils/tests/test_archive_util.py
+6
-7
Lib/distutils/tests/test_bdist_dumb.py
Lib/distutils/tests/test_bdist_dumb.py
+1
-1
Lib/distutils/tests/test_sdist.py
Lib/distutils/tests/test_sdist.py
+10
-2
Misc/NEWS.d/next/Library/2018-09-19-16-51-04.bpo-34738.Pr3-iG.rst
...S.d/next/Library/2018-09-19-16-51-04.bpo-34738.Pr3-iG.rst
+2
-0
No files found.
Lib/distutils/archive_util.py
View file @
67a93b3a
...
@@ -166,7 +166,15 @@ def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
...
@@ -166,7 +166,15 @@ def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
zip
=
zipfile
.
ZipFile
(
zip_filename
,
"w"
,
zip
=
zipfile
.
ZipFile
(
zip_filename
,
"w"
,
compression
=
zipfile
.
ZIP_STORED
)
compression
=
zipfile
.
ZIP_STORED
)
if
base_dir
!=
os
.
curdir
:
path
=
os
.
path
.
normpath
(
os
.
path
.
join
(
base_dir
,
''
))
zip
.
write
(
path
,
path
)
log
.
info
(
"adding '%s'"
,
path
)
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
base_dir
):
for
dirpath
,
dirnames
,
filenames
in
os
.
walk
(
base_dir
):
for
name
in
dirnames
:
path
=
os
.
path
.
normpath
(
os
.
path
.
join
(
dirpath
,
name
,
''
))
zip
.
write
(
path
,
path
)
log
.
info
(
"adding '%s'"
,
path
)
for
name
in
filenames
:
for
name
in
filenames
:
path
=
os
.
path
.
normpath
(
os
.
path
.
join
(
dirpath
,
name
))
path
=
os
.
path
.
normpath
(
os
.
path
.
join
(
dirpath
,
name
))
if
os
.
path
.
isfile
(
path
):
if
os
.
path
.
isfile
(
path
):
...
...
Lib/distutils/tests/test_archive_util.py
View file @
67a93b3a
...
@@ -122,12 +122,13 @@ class ArchiveUtilTestCase(support.TempdirManager,
...
@@ -122,12 +122,13 @@ class ArchiveUtilTestCase(support.TempdirManager,
try
:
try
:
names
=
tar
.
getnames
()
names
=
tar
.
getnames
()
names
.
sort
()
names
.
sort
()
return
tuple
(
names
)
return
names
finally
:
finally
:
tar
.
close
()
tar
.
close
()
_created_files
=
(
'dist'
,
'dist/file1'
,
'dist/file2'
,
_zip_created_files
=
[
'dist/'
,
'dist/file1'
,
'dist/file2'
,
'dist/sub'
,
'dist/sub/file3'
,
'dist/sub2'
)
'dist/sub/'
,
'dist/sub/file3'
,
'dist/sub2/'
]
_created_files
=
[
p
.
rstrip
(
'/'
)
for
p
in
_zip_created_files
]
def
_create_files
(
self
):
def
_create_files
(
self
):
# creating something to tar
# creating something to tar
...
@@ -244,8 +245,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
...
@@ -244,8 +245,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
tarball
=
base_name
+
'.zip'
tarball
=
base_name
+
'.zip'
self
.
assertTrue
(
os
.
path
.
exists
(
tarball
))
self
.
assertTrue
(
os
.
path
.
exists
(
tarball
))
with
zipfile
.
ZipFile
(
tarball
)
as
zf
:
with
zipfile
.
ZipFile
(
tarball
)
as
zf
:
self
.
assertEqual
(
sorted
(
zf
.
namelist
()),
self
.
assertEqual
(
sorted
(
zf
.
namelist
()),
self
.
_zip_created_files
)
[
'dist/file1'
,
'dist/file2'
,
'dist/sub/file3'
])
@
unittest
.
skipUnless
(
ZIP_SUPPORT
,
'Need zip support to run'
)
@
unittest
.
skipUnless
(
ZIP_SUPPORT
,
'Need zip support to run'
)
def
test_make_zipfile_no_zlib
(
self
):
def
test_make_zipfile_no_zlib
(
self
):
...
@@ -271,8 +271,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
...
@@ -271,8 +271,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
[((
tarball
,
"w"
),
{
'compression'
:
zipfile
.
ZIP_STORED
})])
[((
tarball
,
"w"
),
{
'compression'
:
zipfile
.
ZIP_STORED
})])
self
.
assertTrue
(
os
.
path
.
exists
(
tarball
))
self
.
assertTrue
(
os
.
path
.
exists
(
tarball
))
with
zipfile
.
ZipFile
(
tarball
)
as
zf
:
with
zipfile
.
ZipFile
(
tarball
)
as
zf
:
self
.
assertEqual
(
sorted
(
zf
.
namelist
()),
self
.
assertEqual
(
sorted
(
zf
.
namelist
()),
self
.
_zip_created_files
)
[
'dist/file1'
,
'dist/file2'
,
'dist/sub/file3'
])
def
test_check_archive_formats
(
self
):
def
test_check_archive_formats
(
self
):
self
.
assertEqual
(
check_archive_formats
([
'gztar'
,
'xxx'
,
'zip'
]),
self
.
assertEqual
(
check_archive_formats
([
'gztar'
,
'xxx'
,
'zip'
]),
...
...
Lib/distutils/tests/test_bdist_dumb.py
View file @
67a93b3a
...
@@ -84,7 +84,7 @@ class BuildDumbTestCase(support.TempdirManager,
...
@@ -84,7 +84,7 @@ class BuildDumbTestCase(support.TempdirManager,
finally
:
finally
:
fp
.
close
()
fp
.
close
()
contents
=
sorted
(
os
.
path
.
basename
(
fn
)
for
fn
in
contents
)
contents
=
sorted
(
filter
(
None
,
map
(
os
.
path
.
basename
,
contents
))
)
wanted
=
[
'foo-0.1-py%s.%s.egg-info'
%
sys
.
version_info
[:
2
],
'foo.py'
]
wanted
=
[
'foo-0.1-py%s.%s.egg-info'
%
sys
.
version_info
[:
2
],
'foo.py'
]
if
not
sys
.
dont_write_bytecode
:
if
not
sys
.
dont_write_bytecode
:
wanted
.
append
(
'foo.%s.pyc'
%
sys
.
implementation
.
cache_tag
)
wanted
.
append
(
'foo.%s.pyc'
%
sys
.
implementation
.
cache_tag
)
...
...
Lib/distutils/tests/test_sdist.py
View file @
67a93b3a
...
@@ -128,7 +128,9 @@ class SDistTestCase(BasePyPIRCCommandTestCase):
...
@@ -128,7 +128,9 @@ class SDistTestCase(BasePyPIRCCommandTestCase):
zip_file
.
close
()
zip_file
.
close
()
# making sure everything has been pruned correctly
# making sure everything has been pruned correctly
self
.
assertEqual
(
len
(
content
),
4
)
expected
=
[
''
,
'PKG-INFO'
,
'README'
,
'setup.py'
,
'somecode/'
,
'somecode/__init__.py'
]
self
.
assertEqual
(
sorted
(
content
),
[
'fake-1.0/'
+
x
for
x
in
expected
])
@
unittest
.
skipUnless
(
ZLIB_SUPPORT
,
'Need zlib support to run'
)
@
unittest
.
skipUnless
(
ZLIB_SUPPORT
,
'Need zlib support to run'
)
@
unittest
.
skipIf
(
find_executable
(
'tar'
)
is
None
,
@
unittest
.
skipIf
(
find_executable
(
'tar'
)
is
None
,
...
@@ -226,7 +228,13 @@ class SDistTestCase(BasePyPIRCCommandTestCase):
...
@@ -226,7 +228,13 @@ class SDistTestCase(BasePyPIRCCommandTestCase):
zip_file
.
close
()
zip_file
.
close
()
# making sure everything was added
# making sure everything was added
self
.
assertEqual
(
len
(
content
),
12
)
expected
=
[
''
,
'PKG-INFO'
,
'README'
,
'buildout.cfg'
,
'data/'
,
'data/data.dt'
,
'inroot.txt'
,
'scripts/'
,
'scripts/script.py'
,
'setup.py'
,
'some/'
,
'some/file.txt'
,
'some/other_file.txt'
,
'somecode/'
,
'somecode/__init__.py'
,
'somecode/doc.dat'
,
'somecode/doc.txt'
]
self
.
assertEqual
(
sorted
(
content
),
[
'fake-1.0/'
+
x
for
x
in
expected
])
# checking the MANIFEST
# checking the MANIFEST
f
=
open
(
join
(
self
.
tmp_dir
,
'MANIFEST'
))
f
=
open
(
join
(
self
.
tmp_dir
,
'MANIFEST'
))
...
...
Misc/NEWS.d/next/Library/2018-09-19-16-51-04.bpo-34738.Pr3-iG.rst
0 → 100644
View file @
67a93b3a
ZIP files created by :mod:`distutils` will now include entries for
directories.
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