You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2016/01/15 02:54:53 UTC
[5/8] lucy-clownfish git commit: Add Python site-packages dirs to CF
include.
Add Python site-packages dirs to CF include.
In CFCHierarchy's constructor, always add include dirs for each
site-packages dir.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/5f53f5a4
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/5f53f5a4
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/5f53f5a4
Branch: refs/heads/master
Commit: 5f53f5a4c0856c272abc5a202d392a7dd647d69c
Parents: a677d8c
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Wed Dec 17 15:49:23 2014 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Wed Jan 6 20:22:53 2016 -0800
----------------------------------------------------------------------
compiler/python/clownfish/_cfc.c | 25 +++++++++++++++++++++++++
compiler/python/clownfish/cfc/__init__.py | 12 ++++++++++++
2 files changed, 37 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5f53f5a4/compiler/python/clownfish/_cfc.c
----------------------------------------------------------------------
diff --git a/compiler/python/clownfish/_cfc.c b/compiler/python/clownfish/_cfc.c
index 204ee3e..209f174 100644
--- a/compiler/python/clownfish/_cfc.c
+++ b/compiler/python/clownfish/_cfc.c
@@ -84,7 +84,32 @@ S_CFCHierarchy_new(PyTypeObject *type, PyObject *args,
PyErr_SetString(PyExc_TypeError, "Missing required arg 'dest'");
return NULL;
}
+ PyObject *inc_func = PyObject_GetAttrString(cfc_module, "_get_inc_dirs");
+ PyObject *dirs = NULL;
+ if (PyCallable_Check(inc_func)) {
+ dirs = PyObject_CallObject(inc_func, NULL);
+ }
+ if (dirs == NULL || !PyList_Check(dirs)) {
+ Py_XDECREF(inc_func);
+ Py_XDECREF(dirs);
+ PyErr_SetString(PyExc_RuntimeError, "_get_inc_dirs failed");
+ return NULL;
+ }
CFCHierarchy *hierarchy = CFCHierarchy_new(dest);
+ for (Py_ssize_t i = 0, max = PyList_Size(dirs); i < max; i++) {
+ PyObject *dir = PyList_GetItem(dirs, i);
+ if (PyUnicode_Check(dir)) {
+ char *dir_utf8 = PyUnicode_AsUTF8(dir);
+ CFCHierarchy_add_include_dir(hierarchy, dir_utf8);
+ }
+ else {
+ PyErr_SetString(PyExc_RuntimeError, "not a string");
+ return NULL;
+ }
+ }
+
+ Py_XDECREF(inc_func);
+ Py_XDECREF(dirs);
return S_wrap_cfcbase(Hierarchy_pytype, hierarchy);
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5f53f5a4/compiler/python/clownfish/cfc/__init__.py
----------------------------------------------------------------------
diff --git a/compiler/python/clownfish/cfc/__init__.py b/compiler/python/clownfish/cfc/__init__.py
index 8ab5aaf..f7f3e0b 100644
--- a/compiler/python/clownfish/cfc/__init__.py
+++ b/compiler/python/clownfish/cfc/__init__.py
@@ -13,5 +13,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import clownfish._cfc
from clownfish._cfc import *
+import site
+import os.path
+
+def _get_inc_dirs():
+ dirs = []
+ for path in site.getsitepackages():
+ path = os.path.join(path, "clownfish/_include")
+ dirs.append(path)
+ return dirs
+
+clownfish._cfc._get_inc_dirs = _get_inc_dirs