From 923587036c75cccb6764cabd368ddca9d29521ad Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 13 Mar 2013 16:30:59 -0400 Subject: [PATCH] Manage shipped CL components using pkg_resources. --- pyopencl/__init__.py | 36 +++++------------------ {src => pyopencl}/cl/pyopencl-airy.cl | 0 {src => pyopencl}/cl/pyopencl-bessel-j.cl | 0 {src => pyopencl}/cl/pyopencl-bessel-y.cl | 0 {src => pyopencl}/cl/pyopencl-complex.h | 0 {src => pyopencl}/cl/pyopencl-eval-tbl.cl | 0 {src => pyopencl}/cl/pyopencl-ranluxcl.cl | 0 setup.py | 11 ++++--- 8 files changed, 14 insertions(+), 33 deletions(-) rename {src => pyopencl}/cl/pyopencl-airy.cl (100%) rename {src => pyopencl}/cl/pyopencl-bessel-j.cl (100%) rename {src => pyopencl}/cl/pyopencl-bessel-y.cl (100%) rename {src => pyopencl}/cl/pyopencl-complex.h (100%) rename {src => pyopencl}/cl/pyopencl-eval-tbl.cl (100%) rename {src => pyopencl}/cl/pyopencl-ranluxcl.cl (100%) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index e5560c0a..1f4b4984 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -166,7 +166,11 @@ class Program(object): finally: srcfile.close() - what = e.what + "\n(source saved as %s)" % srcfile.name + what = e.what + if options: + what = what + "\n(options: %s)" % " ".join(options) + what = what + "\n(source saved as %s)" % srcfile.name + code = e.code routine = e.routine @@ -628,34 +632,8 @@ _add_functionality() # {{{ find pyopencl shipped source code def _find_pyopencl_include_path(): - from imp import find_module - import sys - file, pathname, descr = find_module("pyopencl") - - # Who knew Python installation is so uniform and predictable? - from os.path import join, exists - possible_include_paths = [ - join(pathname, "..", "include", "pyopencl"), - join(pathname, "..", "src", "cl"), - join(pathname, "..", "..", "..", "src", "cl"), - join(pathname, "..", "..", "..", "..", "include", "pyopencl"), - join(pathname, "..", "..", "..", "include", "pyopencl"), - ] - - if sys.platform in ("linux2", "darwin"): - possible_include_paths.extend([ - join(sys.prefix, "include" , "pyopencl"), - "/usr/include/pyopencl", - "/usr/local/include/pyopencl" - ]) - - for inc_path in possible_include_paths: - if exists(inc_path): - return inc_path - - raise RuntimeError("could not find path to PyOpenCL's CL" - " header files, searched in : %s" - % '\n'.join(possible_include_paths)) + from pkg_resources import Requirement, resource_filename + return resource_filename(Requirement.parse("pyopencl"), "pyopencl/cl") # }}} diff --git a/src/cl/pyopencl-airy.cl b/pyopencl/cl/pyopencl-airy.cl similarity index 100% rename from src/cl/pyopencl-airy.cl rename to pyopencl/cl/pyopencl-airy.cl diff --git a/src/cl/pyopencl-bessel-j.cl b/pyopencl/cl/pyopencl-bessel-j.cl similarity index 100% rename from src/cl/pyopencl-bessel-j.cl rename to pyopencl/cl/pyopencl-bessel-j.cl diff --git a/src/cl/pyopencl-bessel-y.cl b/pyopencl/cl/pyopencl-bessel-y.cl similarity index 100% rename from src/cl/pyopencl-bessel-y.cl rename to pyopencl/cl/pyopencl-bessel-y.cl diff --git a/src/cl/pyopencl-complex.h b/pyopencl/cl/pyopencl-complex.h similarity index 100% rename from src/cl/pyopencl-complex.h rename to pyopencl/cl/pyopencl-complex.h diff --git a/src/cl/pyopencl-eval-tbl.cl b/pyopencl/cl/pyopencl-eval-tbl.cl similarity index 100% rename from src/cl/pyopencl-eval-tbl.cl rename to pyopencl/cl/pyopencl-eval-tbl.cl diff --git a/src/cl/pyopencl-ranluxcl.cl b/pyopencl/cl/pyopencl-ranluxcl.cl similarity index 100% rename from src/cl/pyopencl-ranluxcl.cl rename to pyopencl/cl/pyopencl-ranluxcl.cl diff --git a/setup.py b/setup.py index a5361c9e..00438f1e 100644 --- a/setup.py +++ b/setup.py @@ -219,10 +219,13 @@ def main(): ), ], - data_files=[ - ("include/pyopencl", - glob.glob("src/cl/*.cl") + glob.glob("src/cl/*.h")) - ], + include_package_data=True, + package_data={ + "pyopencl": [ + "cl/*.cl", + "cl/*.h", + ] + }, # 2to3 invocation cmdclass={'build_py': build_py}) -- GitLab