anaconda, no goal expansion within call

This commit is contained in:
Vitor Santos Costa
2017-12-13 16:56:10 +00:00
parent 85f444cc94
commit 6b03c96a78
27 changed files with 134 additions and 206 deletions

View File

@@ -2,12 +2,11 @@
#CHECK: PythonLibs, changed to work in WIN32
set (PYTHON_SOURCES python.c pl2py.c pybips.c py2pl.c pl2pl.c pypreds.c)
set (PYTHON_HEADERS py4yap.h)
set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
message( ${GMP_INCLUDE_DIRS} )
include_directories( ${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/os ${GMP_INCLUDE_DIRS} )
include_directories( ${CMAKE_BINARY_DIR} ${PYTHON_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/os )
#talk to python.pl
add_lib(YAPPython pyload.c ${PYTHON_HEADERS} )

View File

@@ -41,13 +41,15 @@ StreamDesc *st = YAP_RepStreamFromId(sno);
if (stream == Py_None)
return NULL;
Py_INCREF(stream);
st->vfs_handle = stream;
st->u.private_data = stream;
st->vfs = me;
st->status = Append_Stream_f | Output_Stream_f;
Yap_DefaultStreamOps(st);
return stream;
}
static bool py_close(int sno) {
return true;
StreamDesc *s = YAP_GetStreamFromId(sno);
PyObject *fclose = PyObject_GetAttrString(s->u.private_data, "close");
PyObject *rc = PyObject_CallObject(fclose, NULL);
@@ -67,7 +69,7 @@ static int py_put(int sno, int ch) {
PyObject *fput = PyObject_GetAttrString(st->u.private_data, "write");
s[0] = ch;
s[1] = '\0';
PyObject_CallFunctionObjArgs(fput, PyBytes_FromString(s), NULL);
PyObject_CallFunctionObjArgs(fput, PyUnicode_FromString(s), NULL);
return ch;
}

View File

@@ -1,31 +0,0 @@
import imp
import os
import ctypes
import glob
import os.path
import sys
import platform
global yap_lib_path
yap_lib_path = os.path.dirname(__file__)
if @CONDA_BUILD@ == "1":
# do not do nothing
if platform.system() == 'Windows':
def load( dll ):
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
dll = os.path.abspath(dll)
ctypes.WinDLL(dll)
load('libYap*')
else:
def load( dll ):
dll = os.path.join(yap_lib_path,dll)
dll = os.path.abspath(dll)
ctypes.CDLL(dll, mode=ctypes.RTLD_GLOBAL)
if platform.system() == 'Apple':
load('libYap.dylib')
load('libPy4YAP.dylib' )
else:
load('libYap.os')
load('libPy4YAP.os' )

View File

@@ -1,31 +0,0 @@
import imp
import os
import ctypes
import glob
import os.path
import platform
import sys
global yap_lib_path
yap_lib_path = os.path.dirname(__file__)
if platform.system() == 'Windows':
def load( dll ):
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
dll = os.path.abspath(dll)
ctypes.WinDLL(dll)
elseif platform.system() == 'Apple':
def load( dll ):
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
dll = os.path.abspath(dll)
ctypes.CDLL(dll)
load('libYap.dylib')
load('libPy4YAP.dylib')
else:
def load( dll ):
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
dll = os.path.abspath(dll)
ctypes.CDLL(dll)
load('libYap.so')
load('libPy4YAP.so')

View File

@@ -14,7 +14,7 @@ if platform.system() == 'Windows':
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
dll = os.path.abspath(dll)
ctypes.WinDLL(dll)
elif platform.system() == 'Apple':
elif platform.system() == 'Darwin':
def load( dll ):
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
dll = os.path.abspath(dll)
@@ -28,4 +28,4 @@ else:
ctypes.CDLL(dll)
load('libYap.so')
load('libPy4YAP.so')

View File

@@ -183,6 +183,7 @@ class YAPShell:
self.port = "call"
# launch the query
while self.answer(q):
print( self.port )
if self.port == "exit":
# done
q.close()

View File

@@ -15,13 +15,13 @@ jupyter_query(Self, Cell) :-
enter_cell(_Self) :-
open('//python/sys.stdout', append, _Output, [alias(jupo)]),
open('//python/sys.stdout', append, _, [alias(jupe)]),
set_prolog_flag(user_output, jupo),
set_prolog_flag(user_error, jupe).
open('//python/sys.stdout', append, _Error, [alias(jupe)]),
set_prolog_flag(user_output, _Output),
set_prolog_flag(user_error, _Error).
exit_cell(_Self) :-
close( jupo),
close( jupe).
close( user_output),
close( user_error).
completions(S, Self) :-
@@ -83,20 +83,20 @@ arg([l|_]).
file_or_library(F,C) :-
libsym(C0),
atom_cooncat(F,C,Co).
atom_cooncat(F,C,C0).
file_or_library(F,C) :-
check_file(F0,C).
check_file(F,C).
check_file(F0,C) :-
atom_concat('\'',F,F0),
!,
absolute_file_name( F, FF, [access(none)] ),
atom_concat( F, '*' , Pat),
atom_concat( FF, '*' , Pat),
absolute_file_name( Pat, C0, [glob(true)] ),
atom_concat(Pat,C00,C0),
atom_conct(C00,'\'',C).
check_file(F0,C) :-
atom_concat( F, '*' , Pat),
atom_concat( F0, '*' , Pat),
absolute_file_name( Pat, C0, [glob(true)] ),
atom_concat(Pat,C,C0).
@@ -117,7 +117,7 @@ predicate(N,P,A) :-
current_predicate(P0/A),
atom_concat(N,P,P0).
cont(0, F, P, P0)- :-
cont(0, F, P, P0) :-
atom_concat( F, P, P0 ).
cont( _, F, P, PB ):-
atom_concat( [F, P, '('], PB ).