Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
e59b7332
Commit
e59b7332
authored
Jan 25, 2009
by
Tarek Ziadé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #1885: --formats=tar,gztar was not working properly in the sdist command
parent
f95cd9c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
11 deletions
+70
-11
command/sdist.py
command/sdist.py
+4
-0
tests/test_sdist.py
tests/test_sdist.py
+66
-11
No files found.
command/sdist.py
View file @
e59b7332
...
@@ -456,6 +456,10 @@ class sdist (Command):
...
@@ -456,6 +456,10 @@ class sdist (Command):
self.make_release_tree(base_dir, self.filelist.files)
self.make_release_tree(base_dir, self.filelist.files)
archive_files = [] # remember names of files we create
archive_files = [] # remember names of files we create
# tar archive must be created last to avoid overwrite and remove
if 'tar' in self.formats:
self.formats.append(self.formats.pop(self.formats.index('tar')))
for fmt in self.formats:
for fmt in self.formats:
file = self.make_archive(base_name, fmt, base_dir=base_dir)
file = self.make_archive(base_name, fmt, base_dir=base_dir)
archive_files.append(file)
archive_files.append(file)
...
...
tests/test_sdist.py
View file @
e59b7332
...
@@ -4,10 +4,13 @@ import unittest
...
@@ -4,10 +4,13 @@ import unittest
import
shutil
import
shutil
import
zipfile
import
zipfile
from
os.path
import
join
from
os.path
import
join
import
sys
from
distutils.command.sdist
import
sdist
from
distutils.command.sdist
import
sdist
from
distutils.core
import
Distribution
from
distutils.core
import
Distribution
from
distutils.tests.test_config
import
PyPIRCCommandTestCase
from
distutils.tests.test_config
import
PyPIRCCommandTestCase
from
distutils.errors
import
DistutilsExecError
from
distutils.spawn
import
spawn
CURDIR
=
os
.
path
.
dirname
(
__file__
)
CURDIR
=
os
.
path
.
dirname
(
__file__
)
TEMP_PKG
=
join
(
CURDIR
,
'temppkg'
)
TEMP_PKG
=
join
(
CURDIR
,
'temppkg'
)
...
@@ -35,6 +38,19 @@ class sdistTestCase(PyPIRCCommandTestCase):
...
@@ -35,6 +38,19 @@ class sdistTestCase(PyPIRCCommandTestCase):
shutil
.
rmtree
(
TEMP_PKG
)
shutil
.
rmtree
(
TEMP_PKG
)
PyPIRCCommandTestCase
.
tearDown
(
self
)
PyPIRCCommandTestCase
.
tearDown
(
self
)
def
_init_tmp_pkg
(
self
):
if
os
.
path
.
exists
(
TEMP_PKG
):
shutil
.
rmtree
(
TEMP_PKG
)
os
.
mkdir
(
TEMP_PKG
)
os
.
mkdir
(
join
(
TEMP_PKG
,
'somecode'
))
os
.
mkdir
(
join
(
TEMP_PKG
,
'dist'
))
# 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
)
os
.
chdir
(
TEMP_PKG
)
def
_write
(
self
,
path
,
content
):
def
_write
(
self
,
path
,
content
):
f
=
open
(
path
,
'w'
)
f
=
open
(
path
,
'w'
)
try
:
try
:
...
@@ -46,15 +62,7 @@ class sdistTestCase(PyPIRCCommandTestCase):
...
@@ -46,15 +62,7 @@ class sdistTestCase(PyPIRCCommandTestCase):
# this test creates a package with some vcs dirs in it
# this test creates a package with some vcs dirs in it
# and launch sdist to make sure they get pruned
# and launch sdist to make sure they get pruned
# on all systems
# on all systems
if
not
os
.
path
.
exists
(
TEMP_PKG
):
self
.
_init_tmp_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
# creating VCS directories with some files in them
os
.
mkdir
(
join
(
TEMP_PKG
,
'somecode'
,
'.svn'
))
os
.
mkdir
(
join
(
TEMP_PKG
,
'somecode'
,
'.svn'
))
...
@@ -68,8 +76,6 @@ class sdistTestCase(PyPIRCCommandTestCase):
...
@@ -68,8 +76,6 @@ class sdistTestCase(PyPIRCCommandTestCase):
self
.
_write
(
join
(
TEMP_PKG
,
'somecode'
,
'.git'
,
self
.
_write
(
join
(
TEMP_PKG
,
'somecode'
,
'.git'
,
'ok'
),
'xxx'
)
'ok'
),
'xxx'
)
os
.
chdir
(
TEMP_PKG
)
# now building a sdist
# now building a sdist
dist
=
Distribution
()
dist
=
Distribution
()
dist
.
script_name
=
'setup.py'
dist
.
script_name
=
'setup.py'
...
@@ -103,6 +109,55 @@ class sdistTestCase(PyPIRCCommandTestCase):
...
@@ -103,6 +109,55 @@ class sdistTestCase(PyPIRCCommandTestCase):
# making sure everything has been pruned correctly
# making sure everything has been pruned correctly
self
.
assertEquals
(
len
(
content
),
4
)
self
.
assertEquals
(
len
(
content
),
4
)
def
test_make_distribution
(
self
):
self
.
_init_tmp_pkg
()
# check if tar is installed under win32
if
sys
.
platform
==
'win32'
:
try
:
spawn
(
'tar --help'
)
except
DistutilsExecError
:
# let's return, no need to go further
return
# 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'
# creating a gztar then a tar
cmd
.
formats
=
[
'gztar'
,
'tar'
]
cmd
.
run
()
# making sure we have two files
dist_folder
=
join
(
TEMP_PKG
,
'dist'
)
result
=
os
.
listdir
(
dist_folder
)
result
.
sort
()
self
.
assertEquals
(
result
,
[
'fake-1.0.tar'
,
'fake-1.0.tar.gz'
]
)
os
.
remove
(
join
(
dist_folder
,
'fake-1.0.tar'
))
os
.
remove
(
join
(
dist_folder
,
'fake-1.0.tar.gz'
))
# now trying a tar then a gztar
cmd
.
formats
=
[
'tar'
,
'gztar'
]
cmd
.
run
()
result
=
os
.
listdir
(
dist_folder
)
result
.
sort
()
self
.
assertEquals
(
result
,
[
'fake-1.0.tar'
,
'fake-1.0.tar.gz'
])
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
sdistTestCase
)
return
unittest
.
makeSuite
(
sdistTestCase
)
...
...
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