Skip to content
Snippets Groups Projects
Commit 8a55b19f authored by Jacob McDonald's avatar Jacob McDonald
Browse files

Made include path __file__ method a fallback

Updated the include path generation function to use Distutils first and
fallback to parsing the __file__ string, if necessary
parent 12999015
No related branches found
No related tags found
No related merge requests found
...@@ -232,13 +232,21 @@ del _size_t_char ...@@ -232,13 +232,21 @@ del _size_t_char
# {{{ find pyopencl shipped source code # {{{ find pyopencl shipped source code
def _find_pyopencl_include_path(): def _find_pyopencl_include_path():
from os.path import join, abspath, dirname, exists from pkg_resources import Requirement, resource_filename, DistributionNotFound
try:
# Try to find the resource with pkg_resources (the recommended setuptools approach)
return resource_filename(Requirement.parse("pyopencl2"), "pyopencl/cl")
except DistributionNotFound:
# If pkg_resources can't find it (e.g. if the module is part of a frozen application),
# try to find the include path in the same directory as this file
from os.path import join, abspath, dirname, exists
include_path = join(abspath(dirname(__file__)), "cl") include_path = join(abspath(dirname(__file__)), "cl")
if not exists(include_path): # If that doesn't exist, just re-raise the exception caught from resource_filename
raise RuntimeError("Could not located PyOpenCL include path") if not exists(include_path):
raise
return include_path
return include_path
# }}} # }}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment