[pypy-svn] r76622 - in pypy/trunk/pypy/tool/release: . test
arigo at codespeak.net
arigo at codespeak.net
Sat Aug 14 10:46:40 CEST 2010
Author: arigo
Date: Sat Aug 14 10:46:38 2010
New Revision: 76622
Modified:
pypy/trunk/pypy/tool/release/package.py
pypy/trunk/pypy/tool/release/test/test_package.py
Log:
On Windows, don't rely on the presence of the 'tar' tool.
Add a test (that also runs on linux) checking compression
with the tarfile module.
Modified: pypy/trunk/pypy/tool/release/package.py
==============================================================================
--- pypy/trunk/pypy/tool/release/package.py (original)
+++ pypy/trunk/pypy/tool/release/package.py Sat Aug 14 10:46:38 2010
@@ -11,11 +11,12 @@
import py
import os
import fnmatch
-import tarfile
from pypy.tool.udir import udir
if sys.version_info < (2,6): py.test.skip("requires 2.6 so far")
+USE_TARFILE_MODULE = sys.platform == 'win32'
+
def ignore_patterns(*patterns):
"""Function that can be used as copytree() ignore parameter.
@@ -69,9 +70,17 @@
old_dir = os.getcwd()
try:
os.chdir(str(builddir))
- os.system("strip " + str(archive_pypy_c))
- os.system('tar cvjf ' + str(builddir.join(name + '.tar.bz2')) +
- " " + name)
+ os.system("strip " + str(archive_pypy_c)) # ignore errors
+ if USE_TARFILE_MODULE:
+ import tarfile
+ tf = tarfile.open(str(builddir.join(name + '.tar.bz2')), 'w:bz2')
+ tf.add(name)
+ tf.close()
+ else:
+ e = os.system('tar cvjf ' + str(builddir.join(name + '.tar.bz2')) +
+ " " + name)
+ if e:
+ raise OSError('"tar" returned exit status %r' % e)
finally:
os.chdir(old_dir)
if copy_to_dir is not None:
Modified: pypy/trunk/pypy/tool/release/test/test_package.py
==============================================================================
--- pypy/trunk/pypy/tool/release/test/test_package.py (original)
+++ pypy/trunk/pypy/tool/release/test/test_package.py Sat Aug 14 10:46:38 2010
@@ -5,7 +5,7 @@
from pypy.module.sys.version import CPYTHON_VERSION
import tarfile, os
-def test_dir_structure():
+def test_dir_structure(test='test'):
# make sure we have sort of pypy-c
pypy_c = py.path.local(pypydir).join('translator', 'goal', 'pypy-c')
if not pypy_c.check():
@@ -14,8 +14,8 @@
else:
fake_pypy_c = False
try:
- builddir = package(py.path.local(pypydir).dirpath(), 'test')
- prefix = builddir.join('test')
+ builddir = package(py.path.local(pypydir).dirpath(), test)
+ prefix = builddir.join(test)
cpyver = '%d.%d.%d' % CPYTHON_VERSION[:3]
assert prefix.join('lib-python', cpyver, 'test').check()
assert prefix.join('bin', 'pypy-c').check()
@@ -24,18 +24,27 @@
assert not prefix.join('lib_pypy', 'ctypes_configure').check()
assert prefix.join('LICENSE').check()
assert prefix.join('README').check()
- th = tarfile.open(str(builddir.join('test.tar.bz2')))
- assert th.getmember('test/lib_pypy/syslog.py')
+ th = tarfile.open(str(builddir.join('%s.tar.bz2' % test)))
+ assert th.getmember('%s/lib_pypy/syslog.py' % test)
# the headers file could be not there, because they are copied into
# trunk/include only during translation
includedir = py.path.local(pypydir).dirpath().join('include')
def check_include(name):
if includedir.join(name).check(file=True):
- assert th.getmember('test/include/%s' % name)
+ assert th.getmember('%s/include/%s' % (test, name))
check_include('Python.h')
check_include('modsupport.inl')
check_include('pypy_decl.h')
finally:
if fake_pypy_c:
pypy_c.remove()
+
+def test_with_tarfile_module():
+ from pypy.tool.release import package
+ prev = package.USE_TARFILE_MODULE
+ try:
+ package.USE_TARFILE_MODULE = True
+ test_dir_structure(test='testtarfile')
+ finally:
+ package.USE_TARFILE_MODULE = prev
More information about the Pypy-commit
mailing list