[pypy-svn] r70176 - in pypy/trunk/pypy/tool: . test

fijal at codespeak.net fijal at codespeak.net
Thu Dec 17 17:42:21 CET 2009


Author: fijal
Date: Thu Dec 17 17:42:20 2009
New Revision: 70176

Added:
   pypy/trunk/pypy/tool/package.py   (contents, props changed)
   pypy/trunk/pypy/tool/test/test_package.py   (contents, props changed)
Log:
A simple tool for packaging pypy, with a test


Added: pypy/trunk/pypy/tool/package.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/tool/package.py	Thu Dec 17 17:42:20 2009
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+""" A sample script that packages PyPy, provided that it's already built
+"""
+
+import autopath
+import shutil
+import sys
+import py
+import os
+import tarfile
+from pypy.tool.udir import udir
+
+class PyPyCNotFound(Exception):
+    pass
+
+def main(basedir, name='pypy-nightly'):
+    basedir = py.path.local(basedir)
+    pypy_c = basedir.join('pypy', 'translator', 'goal', 'pypy-c')
+    if not pypy_c.check():
+        raise PyPyCNotFound('Please compile pypy first, using translate.py')
+    builddir = udir.ensure("build", dir=True)
+    pypydir = builddir.ensure("pypy", dir=True)
+    shutil.copytree(str(basedir.join('lib-python')),
+                    str(pypydir.join('lib-python')),
+                    ignore=shutil.ignore_patterns('.svn'))
+    pypydir.ensure('pypy', dir=True)
+    shutil.copytree(str(basedir.join('pypy', 'lib')),
+                    str(pypydir.join('pypy', 'lib')),
+                    ignore=shutil.ignore_patterns('.svn'))
+    pypydir.ensure('bin', dir=True)
+    shutil.copy(str(pypy_c), str(pypydir.join('bin', 'pypy-c')))
+    old_dir = os.getcwd()
+    try:
+        os.chdir(str(builddir))
+        os.system('tar cvjf ' + str(builddir.join(name + '.tar.bz2')) +
+                  " pypy")
+    finally:
+        os.chdir(old_dir)
+    return builddir # for tests
+
+if __name__ == '__main__':
+    main(sys.argv[1])

Added: pypy/trunk/pypy/tool/test/test_package.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/tool/test/test_package.py	Thu Dec 17 17:42:20 2009
@@ -0,0 +1,24 @@
+
+import py
+from pypy.tool.autopath import pypydir
+from pypy.tool.package import main
+import tarfile
+
+def test_dir_structure():
+    # make sure we have sort of pypy-c
+    pypy_c = py.path.local(pypydir).join('translator', 'goal', 'pypy-c')
+    if not pypy_c.check():
+        pypy_c.write("xxx")
+        fake_pypy_c = True
+    else:
+        fake_pypy_c = False
+    try:
+        builddir = main(py.path.local(pypydir).dirpath(), 'test')
+        assert builddir.join('pypy', 'lib-python', '2.5.2', 'test').check()
+        assert builddir.join('pypy', 'bin', 'pypy-c').check()
+        assert builddir.join('pypy', 'pypy', 'lib', 'syslog.py').check()
+        th = tarfile.open(str(builddir.join('test.tar.bz2')))
+        assert th.getmember('pypy/pypy/lib/syslog.py')
+    finally:
+        if fake_pypy_c:
+            pypy_c.remove()



More information about the Pypy-commit mailing list