From 2b2bbe962253b73fd1595a665458c91f7d8efc51 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Wed, 6 Apr 2016 12:14:54 -0500
Subject: [PATCH] Shell-split options if passed as single string (Fixes #122)

---
 pyopencl/__init__.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py
index 12af8f35..ded51a4d 100644
--- a/pyopencl/__init__.py
+++ b/pyopencl/__init__.py
@@ -390,7 +390,17 @@ class Program(object):
     @classmethod
     def _process_build_options(cls, context, options):
         if isinstance(options, six.string_types):
-            options = [options]
+            import shlex
+            if six.PY2:
+                # shlex.split takes bytes (py2 str) on py2
+                if isinstance(options, six.text_type):
+                    options = options.encode("utf-8")
+            else:
+                # shlex.split takes unicode (py3 str) on py3
+                if isinstance(options, six.binary_type):
+                    options = options.decode("utf-8")
+
+            options = shlex.split(options)
 
         def encode_if_necessary(s):
             if isinstance(s, six.text_type):
-- 
GitLab