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
85d6fb50
Commit
85d6fb50
authored
Jan 04, 2009
by
Tarek Ziadé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed #1702551: distutils sdist was not pruning VCS directories under win32
parent
e54aea78
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
1 deletion
+120
-1
Lib/distutils/command/sdist.py
Lib/distutils/command/sdist.py
+7
-1
Lib/distutils/tests/test_sdist.py
Lib/distutils/tests/test_sdist.py
+110
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/distutils/command/sdist.py
View file @
85d6fb50
...
...
@@ -7,6 +7,7 @@ Implements the Distutils 'sdist' command (create a source distribution)."""
__revision__
=
"$Id$"
import
os
,
string
import
sys
from
types
import
*
from
glob
import
glob
from
distutils.core
import
Command
...
...
@@ -354,8 +355,13 @@ class sdist (Command):
self
.
filelist
.
exclude_pattern
(
None
,
prefix
=
build
.
build_base
)
self
.
filelist
.
exclude_pattern
(
None
,
prefix
=
base_dir
)
self
.
filelist
.
exclude_pattern
(
r'(^|/)(RCS|CVS|\
.s
vn|\
.hg|
\.git|\
.
bzr|_darcs)/.*'
,
is_regex
=
1
)
# pruning out vcs directories
# both separators are used under win32
seps
=
sys
.
platform
==
'win32'
and
r'/|\\'
or
'/'
vcs_dirs
=
[
'RCS'
,
'CVS'
,
'
\
.s
v
n'
,
'
\
.hg
'
, '
\
.
git
', '
\
.
bzr
', '
_darcs
']
vcs_ptrn = r'
(
^|%
s
)(
%
s
)(
%
s
).
*
' % (seps, '
|
'.join(vcs_dirs), seps)
self.filelist.exclude_pattern(vcs_ptrn, is_regex=1)
def write_manifest (self):
"""Write the file list in '
self
.
filelist
' (presumably as filled in
...
...
Lib/distutils/tests/test_sdist.py
0 → 100644
View file @
85d6fb50
"""Tests for distutils.command.sdist."""
import
os
import
unittest
import
shutil
import
zipfile
from
os.path
import
join
from
distutils.command.sdist
import
sdist
from
distutils.core
import
Distribution
from
distutils.tests.test_config
import
PyPIRCCommandTestCase
CURDIR
=
os
.
path
.
dirname
(
__file__
)
TEMP_PKG
=
join
(
CURDIR
,
'temppkg'
)
SETUP_PY
=
"""
from distutils.core import setup
import somecode
setup(name='fake')
"""
MANIFEST_IN
=
"""
recursive-include somecode *
"""
class
sdistTestCase
(
PyPIRCCommandTestCase
):
def
setUp
(
self
):
PyPIRCCommandTestCase
.
setUp
(
self
)
self
.
old_path
=
os
.
getcwd
()
def
tearDown
(
self
):
os
.
chdir
(
self
.
old_path
)
if
os
.
path
.
exists
(
TEMP_PKG
):
shutil
.
rmtree
(
TEMP_PKG
)
PyPIRCCommandTestCase
.
tearDown
(
self
)
def
_write
(
self
,
path
,
content
):
f
=
open
(
path
,
'w'
)
try
:
f
.
write
(
content
)
finally
:
f
.
close
()
def
test_prune_file_list
(
self
):
# this test creates a package with some vcs dirs in it
# and launch sdist to make sure they get pruned
# on all systems
if
not
os
.
path
.
exists
(
TEMP_PKG
):
os
.
mkdir
(
TEMP_PKG
)
os
.
mkdir
(
join
(
TEMP_PKG
,
'somecode'
))
# creating a MANIFEST, a package, and a README
self
.
_write
(
join
(
TEMP_PKG
,
'MANIFEST.in'
),
MANIFEST_IN
)
self
.
_write
(
join
(
TEMP_PKG
,
'README'
),
'xxx'
)
self
.
_write
(
join
(
TEMP_PKG
,
'somecode'
,
'__init__.py'
),
'#'
)
self
.
_write
(
join
(
TEMP_PKG
,
'setup.py'
),
SETUP_PY
)
# creating VCS directories with some files in them
os
.
mkdir
(
join
(
TEMP_PKG
,
'somecode'
,
'.svn'
))
self
.
_write
(
join
(
TEMP_PKG
,
'somecode'
,
'.svn'
,
'ok.py'
),
'xxx'
)
os
.
mkdir
(
join
(
TEMP_PKG
,
'somecode'
,
'.hg'
))
self
.
_write
(
join
(
TEMP_PKG
,
'somecode'
,
'.hg'
,
'ok'
),
'xxx'
)
os
.
mkdir
(
join
(
TEMP_PKG
,
'somecode'
,
'.git'
))
self
.
_write
(
join
(
TEMP_PKG
,
'somecode'
,
'.git'
,
'ok'
),
'xxx'
)
os
.
chdir
(
TEMP_PKG
)
# now building a sdist
dist
=
Distribution
()
dist
.
script_name
=
'setup.py'
dist
.
metadata
.
name
=
'fake'
dist
.
metadata
.
version
=
'1.0'
dist
.
metadata
.
url
=
'http://xxx'
dist
.
metadata
.
author
=
dist
.
metadata
.
author_email
=
'xxx'
dist
.
packages
=
[
'somecode'
]
dist
.
include_package_data
=
True
cmd
=
sdist
(
dist
)
cmd
.
manifest
=
'MANIFEST'
cmd
.
template
=
'MANIFEST.in'
cmd
.
dist_dir
=
'dist'
# zip is available universally
# (tar might not be installed under win32)
cmd
.
formats
=
[
'zip'
]
cmd
.
run
()
# now let's check what we have
dist_folder
=
join
(
TEMP_PKG
,
'dist'
)
files
=
os
.
listdir
(
dist_folder
)
self
.
assertEquals
(
files
,
[
'fake-1.0.zip'
])
zip_file
=
zipfile
.
ZipFile
(
join
(
dist_folder
,
'fake-1.0.zip'
))
try
:
content
=
zip_file
.
namelist
()
finally
:
zip_file
.
close
()
# making sure everything has been pruned correctly
self
.
assertEquals
(
len
(
content
),
4
)
def
test_suite
():
return
unittest
.
makeSuite
(
sdistTestCase
)
if
__name__
==
"__main__"
:
unittest
.
main
(
defaultTest
=
"test_suite"
)
Misc/NEWS
View file @
85d6fb50
...
...
@@ -108,6 +108,9 @@ Core and Builtins
Library
-------
- Issue #1702551: distutils sdist was not excluding VCS directories under
Windows. Inital solution by Guy Dalberto.
- The _tkinter module functions "createfilehandler", "deletefilehandler",
"createtimerhandler", "mainloop", "dooneevent" and "quit" have been
deprecated for removal in 3.x
...
...
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