[SCM] Packaging for cctbx branch, master, updated. upstream/2012.05.08.2305-77-g0435369

Baptiste Carvello devel at baptiste-carvello.net
Tue Aug 21 14:44:19 UTC 2012


The following commit has been merged in the master branch:
commit 04353697aacf98f3238868dda2d0cb7f5941c091
Author: Baptiste Carvello <devel at baptiste-carvello.net>
Date:   Tue Aug 21 16:33:40 2012 +0200

    Standalone test runner in setup.py (unfinished, tests still fail)

diff --git a/debian/patches/0010-adding-setup_py.patch b/debian/patches/0010-adding-setup_py.patch
index 30e3297..f0373f4 100644
--- a/debian/patches/0010-adding-setup_py.patch
+++ b/debian/patches/0010-adding-setup_py.patch
@@ -1,12 +1,12 @@
 From: Baptiste Carvello <devel at baptiste-carvello.net>
-Date: Thu, 26 Jul 2012 21:55:12 +0200
+Date: Tue, 21 Aug 2012 16:10:19 +0200
 Subject: adding-setup_py
 
 ---
  cctbx_sources/stdlib.py |    4 +
- sconsutils.py           |  409 +++++++++++++++++++++++++++++++++++++++++++++++
- setup.py                |  135 ++++++++++++++++
- 3 files changed, 548 insertions(+)
+ sconsutils.py           |  485 +++++++++++++++++++++++++++++++++++++++++++++++
+ setup.py                |  136 +++++++++++++
+ 3 files changed, 625 insertions(+)
  create mode 100755 cctbx_sources/stdlib.py
  create mode 100644 sconsutils.py
  create mode 100755 setup.py
@@ -23,10 +23,10 @@ index 0000000..759f689
 +random = stdlib_import("random")
 diff --git a/sconsutils.py b/sconsutils.py
 new file mode 100644
-index 0000000..d118004
+index 0000000..322585b
 --- /dev/null
 +++ b/sconsutils.py
-@@ -0,0 +1,409 @@
+@@ -0,0 +1,485 @@
 +from distutils.sysconfig import get_python_lib, get_config_var
 +from distutils.command.build_ext import build_ext as _build_ext
 +from distutils.command.build_py import build_py as _build_py
@@ -36,12 +36,15 @@ index 0000000..d118004
 +from distutils.cmd import Command as _Command
 +from distutils.dir_util import remove_tree
 +from distutils.util import change_root, convert_path
++from distutils.errors import DistutilsExecError
 +from distutils import log
 +import sys, os
 +import SCons.Script
 +import libtbx
 +import libtbx.env_config
 +from libtbx.path import relocatable_path, absolute_path
++from libtbx.path import relpath    # don't use relpath from os.path, introduced in 2.6
++from libtbx.utils import import_python_object
 +import threading
 +import pickle
 +
@@ -206,17 +209,79 @@ index 0000000..d118004
 +        libdir = os.path.abspath(os.path.abspath(self.build_lib))
 +        builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build')
 +        testdir = opj(os.path.abspath(self.build_temp), 'cctbx-test')
-+        os.environ["LIBTBX_BUILD"] = builddir
++        self.setup_test_env(builddir, libdir, testdir)
++        os.environ["LIBTBX_BUILD"] = testdir
 +        env = libtbx.env_config.unpickle()
-+        scripts = [opj(libdir, s.relocatable.partition('cctbx_sources'+os.sep)[2])
-+            for s in env.collect_test_scripts()
-+            ]
 +        os.environ['PYTHONPATH'] = ':'.join([libdir] + sys.path[5:])
 +        llp = os.environ.get('LD_LIBRARY_PATH')
 +        if llp is not None:
 +            os.environ['LD_LIBRARY_PATH'] = ':'.join([opj(builddir, 'lib', '.libs'), llp])
 +        else:
 +            os.environ['LD_LIBRARY_PATH'] = opj(builddir, 'lib', '.libs')
++        os.chdir(testdir)
++        failed = []
++        for m in env.module_list:
++            for (module_name,dist_path) in m.name_and_dist_path_pairs():
++                try:
++#                    tst_list = import_python_object(
++#                            import_path="%s.run_tests.tst_list" % module_name,    Does not work yet
++#                            error_prefix="",
++#                            target_must_be="",
++#                            where_str="").object 
++                    run_func = import_python_object(
++                            import_path="%s.run_tests.run" % module_name,
++                            error_prefix="",
++                            target_must_be="",
++                            where_str="").object
++                    tst_mod = file(opj(abs(dist_path), "run_tests.py"))    # Ugly, temporary
++                    tst_lines = [l.strip() for l in tst_mod]
++                    tst_mod.close()
++                    tst_code = " ".join(["("] +
++                                        tst_lines[(tst_lines.index("tst_list = (")+1)
++                                                 :(tst_lines.index(")")+1)]
++                                        )
++                    tst_list = eval(tst_code)
++
++                except Exception:
++                    continue
++                for tst in tst_list:    # adapted from libtbx.test_utils.iter_tests_cmd
++                    cmd_args = []
++                    if (type(tst) == type([])):
++#                        cmd_args = tst[1:]    FIXME why only in quick mode?
++                        tst = tst[0]
++                    if (tst.startswith("$B")):
++                        tst_path = tst.replace("$B", builddir)
++                    else:
++                        tst_path = tst.replace("$D", abs(dist_path))
++                    if "$" in tst_path or '"' in tst_path:
++                        log.warn("Could not run test '%s':\n%s", tst, "Unexpected '$' in test path")
++                        failed.append([module_name,tst,AssertionError("Unexpected '$' in test path")])
++                        continue
++                    if '"' in tst_path:
++                        log.warn("Could not run test '%s':\n%s", tst, "Unexpected '\"' in test path")
++                        failed.append([module_name,tst,AssertionError("Unexpected '\"' in test path")])
++                        continue
++                    tst_path = os.path.normpath(tst_path)
++                    if (tst_path.endswith(".py")):
++                        cmd = [sys.executable, tst_path] + cmd_args
++                    else:
++                        cmd = [tst_path] + cmd_args
++                    try:
++                        self.spawn(cmd)
++                    except DistutilsExecError, e:
++                        log.warn("Failure in test '%s':\n%s", tst, str(e))
++                        failed.append([module_name,tst,e])
++                    except Exception, e:
++                        log.warn("Exception in test '%s':\n%s", tst, str(e))
++                        failed.append([module_name,tst,e])
++        if failed:
++            log.warn("Some tests failed:")
++            for n,t,e in failed:
++                log.warn("    module %s, test %s" % (n,t))
++            raise RuntimeError("Test failures")
++
++    def setup_test_env(self, builddir, libdir, testdir):
++        """ Create the test directory and the temporary libtbx_env pickle object """
 +        if not os.path.exists(testdir):
 +            if not os.path.exists(os.path.abspath(self.build_temp)):
 +                os.mkdir(os.path.abspath(self.build_temp))
@@ -224,14 +289,26 @@ index 0000000..d118004
 +        elif not os.path.isdir(testdir):
 +            raise RuntimeError(("Test directory '%s' cannot be created "
 +                                "because of existing file") % testdir)
-+        os.chdir(testdir)
-+        os.environ["LIBTBX_TEST_BUILDDIR"] = builddir
-+        os.environ["LIBTBX_TEST_DISTDIR"] = libdir
-+        for s in scripts:
-+            try:
-+                self.spawn([sys.executable, s])
-+            except Exception, e:
-+                log.warn("Could not run script '%s':\n%s", s, str(e))
++        os.environ["LIBTBX_BUILD"] = builddir
++        env = libtbx.env_config.unpickle()
++        module_dist_paths = {}
++        for key, value in env.module_dist_paths.items():
++            head, module = os.path.split(abs(value))
++            module_dist_paths[key] = relocatable_path(absolute_path(libdir), module)
++        env.module_dist_paths = module_dist_paths
++        for module in env.module_list:
++            paths = []
++            for path in module.dist_paths:
++                if path != None:
++                    head, tail = os.path.split(abs(path))
++                    rp = relocatable_path(absolute_path(libdir), tail)
++                    paths.append(rp)
++                else:
++                    paths.append(None)
++            module.dist_paths = paths
++        file_obj = open(opj(testdir,'libtbx_env'), 'wb')
++        pickle.dump(env, file_obj, 0)
++        file_obj.close()
 +
 +class install_lib(_install_lib, Command):
 +    user_options = _install_lib.user_options + [
@@ -302,7 +379,6 @@ index 0000000..d118004
 +
 +    def install_libtbx_env(self, libtbx_env_path):
 +        """ Modify libtbx_env pickle object to set the correct paths. """
-+        print libtbx_env_path
 +        builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build')
 +        os.environ["LIBTBX_BUILD"] = builddir
 +        env = libtbx.env_config.unpickle()
@@ -340,7 +416,7 @@ index 0000000..d118004
 +        for key, value in env._dispatcher_registry.items():
 +            new_key = relocatable_path(anchor=build_path,
 +                                       relocatable=key.relocatable)
-+            rel = os.path.relpath(abs(value), SRCDIR)
++            rel = relpath(abs(value), SRCDIR)
 +            new_val = relocatable_path(anchor=absolute_path(rel_path),
 +                                       relocatable=rel)
 +            _dispatcher_registry[new_key] = new_val
@@ -438,12 +514,11 @@ index 0000000..d118004
 +    return out, list(outext)
 diff --git a/setup.py b/setup.py
 new file mode 100755
-index 0000000..c64a639
+index 0000000..033dc9e
 --- /dev/null
 +++ b/setup.py
-@@ -0,0 +1,135 @@
+@@ -0,0 +1,136 @@
 +from distutils.core import setup, Extension
-+from distutils.util import convert_path
 +import sys, os, shutil
 +
 +# General settings
@@ -536,18 +611,20 @@ index 0000000..c64a639
 +SCRIPTS = []
 +PKG_DATA = {}
 +EXTRA_PATH = 'cctbx'
++
++MODS = ['stdlib']
++
 +PACKDIR = { 'boost' : 'cctbx_sources/boost_adaptbx/boost',    # in setup, paths must stay in unix syntax
 +            'clipper' : 'cctbx_sources/clipper_adaptbx/clipper',    # also, let's keep them relative
-+            'optik' : 'cctbx_sources/libtbx/pythonpath/optik',
++            'optik' : 'cctbx_sources/libtbx/pythonpath/optik',    # FIXME installs incompatible fork to global path
 +            'tntbx' : 'cctbx_sources/tntbx/tntbx',
 +            '' : 'cctbx_sources',
 +          }
 +
-+MODS = ['stdlib']
 +PACKS = []
 +EXT_MODULES = []
 +for key, value in PACKDIR.items():
-+    p, e = find_packages_and_extensions(convert_path(value))
++    p, e = find_packages_and_extensions(value)
 +    PACKS.extend(p)
 +    EXT_MODULES.extend(e)
 +    if key != '':
@@ -565,15 +642,15 @@ index 0000000..c64a639
 +      keywords = KEYWORDS,
 +      extra_path = EXTRA_PATH,
 +      scripts = SCRIPTS,
-+      packages = PACKS,
++      py_modules = MODS,
 +      package_dir = PACKDIR,
++      packages = PACKS,
 +      ext_modules = EXT_MODULES,
++      data_files = [('share/cctbx/%s'%(py_str), ['%LIBTBXENV%'])],    # special treatment from install_data
 +      cmdclass = {'build_ext': build_ext,
 +                  'build_py': build_py,
 +                  'test': test,
 +                  'install_lib': install_lib,
 +                  'install_data': install_data,
 +                  'clean': clean},
-+      py_modules = MODS,
-+      data_files = [('share/cctbx/%s'%(py_str), ['%LIBTBXENV%'])],    # special treatment from install_data
 +     )
diff --git a/debian/patches/0016-adapt-test_utils-in-libtbx-for-setup_py-test.patch b/debian/patches/0016-adapt-test_utils-in-libtbx-for-setup_py-test.patch
deleted file mode 100644
index 6e3b61d..0000000
--- a/debian/patches/0016-adapt-test_utils-in-libtbx-for-setup_py-test.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-From: Baptiste Carvello <devel at baptiste-carvello.net>
-Date: Thu, 26 Jul 2012 22:16:38 +0200
-Subject: adapt test_utils in libtbx for setup_py test
-
----
- cctbx_sources/libtbx/test_utils.py |   23 ++++++++++++++++++++++-
- 1 file changed, 22 insertions(+), 1 deletion(-)
-
-diff --git a/cctbx_sources/libtbx/test_utils.py b/cctbx_sources/libtbx/test_utils.py
-index 13b6e67..c93867f 100644
---- a/cctbx_sources/libtbx/test_utils.py
-+++ b/cctbx_sources/libtbx/test_utils.py
-@@ -157,6 +157,27 @@ def make_pick_and_run_tests(working_dir, interrupted,
-   return func
- 
- def iter_tests_cmd(co, build_dir, dist_dir, tst_list):
-+  if build_dir is not None and 'LIBTBX_TEST_BUILDDIR' in os.environ:
-+    build_path=abs(libtbx.env.build_path)
-+    if build_dir == build_path:
-+        build_dir = os.environ['LIBTBX_TEST_BUILDDIR']
-+    elif build_dir.startswith(build_path+os.sep):
-+      build_dir = build_dir.replace(build_path, os.environ['LIBTBX_TEST_BUILDDIR'])
-+    else:
-+      raise RuntimeError("Resource not in build dir: %s" % build_dir)
-+  if dist_dir is not None and 'LIBTBX_TEST_DISTDIR' in os.environ:
-+    for module, dist_path in libtbx.env.module_dist_paths.items():
-+      dist_path = abs(dist_path)
-+      if dist_dir == dist_path:
-+        dist_dir = os.path.join(os.environ['LIBTBX_TEST_DISTDIR'], module)
-+        break
-+      elif dist_dir.startswith(dist_path+os.sep):
-+        dist_dir = dist_dir.replace(dist_path,
-+          os.path.join(os.environ['LIBTBX_TEST_DISTDIR'], module)
-+          )
-+        break
-+    else:
-+      raise RuntimeError("Resource not in a dist dir: %s" % dist_dir)
-   for tst in tst_list:
-     cmd_args = ""
-     if (type(tst) == type([])):
-@@ -178,7 +199,7 @@ def iter_tests_cmd(co, build_dir, dist_dir, tst_list):
-     if (tst_path.endswith(".py")):
-       if (co.valgrind):
-         cmd = "libtbx.valgrind "
--      cmd += "libtbx.python "
-+      cmd += sys.executable + " "
-     else:
-       if (co.valgrind):
-         cmd = os.environ.get(
diff --git a/debian/patches/0017-autogenerate-pkgconfig-files.patch b/debian/patches/0016-autogenerate-pkgconfig-files.patch
similarity index 100%
rename from debian/patches/0017-autogenerate-pkgconfig-files.patch
rename to debian/patches/0016-autogenerate-pkgconfig-files.patch
diff --git a/debian/patches/0018-Fix-to-use-systems-include-path.patch b/debian/patches/0017-Fix-to-use-systems-include-path.patch
similarity index 87%
rename from debian/patches/0018-Fix-to-use-systems-include-path.patch
rename to debian/patches/0017-Fix-to-use-systems-include-path.patch
index 58b6afb..f19da17 100644
--- a/debian/patches/0018-Fix-to-use-systems-include-path.patch
+++ b/debian/patches/0017-Fix-to-use-systems-include-path.patch
@@ -3,14 +3,14 @@ Date: Tue, 7 Aug 2012 18:15:43 +0200
 Subject: Fix to use systems include path
 
 ---
- .../detectors/boost_python/cbf_binary_adaptor.h    |    4 ++--
- .../detectors/boost_python/general_cbf_write.h     |    4 ++--
- .../cbflib_adaptbx/detectors/cbf_adaptor.h         |    4 ++--
- .../detectors/cbf_byte_offset_optimized.cpp        |    6 +++---
- .../cbflib_adaptbx/detectors/tst_memory.cpp        |    4 ++--
- cctbx_sources/ccp4io_adaptbx/ext.cpp               |    2 +-
- cctbx_sources/iotbx/mtz/ext.cpp                    |    2 +-
- cctbx_sources/iotbx/mtz/object.h                   |    6 +++---
+ .../cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h   |    4 ++--
+ .../cbflib_adaptbx/detectors/boost_python/general_cbf_write.h    |    4 ++--
+ cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h             |    4 ++--
+ .../cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp       |    6 +++---
+ cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp            |    4 ++--
+ cctbx_sources/ccp4io_adaptbx/ext.cpp                             |    2 +-
+ cctbx_sources/iotbx/mtz/ext.cpp                                  |    2 +-
+ cctbx_sources/iotbx/mtz/object.h                                 |    6 +++---
  8 files changed, 16 insertions(+), 16 deletions(-)
 
 diff --git a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h
diff --git a/debian/patches/0019-Fix-to-skip-build-of-clipper-examples.patch b/debian/patches/0018-Fix-to-skip-build-of-clipper-examples.patch
similarity index 100%
rename from debian/patches/0019-Fix-to-skip-build-of-clipper-examples.patch
rename to debian/patches/0018-Fix-to-skip-build-of-clipper-examples.patch
diff --git a/debian/patches/series b/debian/patches/series
index 49c088b..451f739 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -13,7 +13,6 @@
 0013-fix-to-support-LDFLAGS-in-use_enviroment_flags.patch
 0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch
 0015-fix-cif-parser-to-work-with-antlr3c-3.2.patch
-0016-adapt-test_utils-in-libtbx-for-setup_py-test.patch
-0017-autogenerate-pkgconfig-files.patch
-0018-Fix-to-use-systems-include-path.patch
-0019-Fix-to-skip-build-of-clipper-examples.patch
+0016-autogenerate-pkgconfig-files.patch
+0017-Fix-to-use-systems-include-path.patch
+0018-Fix-to-skip-build-of-clipper-examples.patch

-- 
Packaging for cctbx



More information about the debian-science-commits mailing list