tcflush
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
|
||||
:- use_module( library(python) ).
|
||||
|
||||
:- := import( collections ).
|
||||
:- := import( yap ).
|
||||
:- e := yap.'YAPEngine'().
|
||||
|
||||
main :-
|
||||
system_predicate(N/A),
|
||||
args(0,A,L),
|
||||
N := namedtuple( N, L),
|
||||
fail.
|
||||
main :-
|
||||
:= e.call( writeln( 1 ) ).
|
||||
|
||||
args(N, N, []) :- !.
|
||||
args(I0,IF,[AI|Ais]) :-
|
||||
I is I0+1,
|
||||
number_string(I, IS),
|
||||
string_concat("A", IS, AI),
|
||||
args(I, IF, Ais).
|
@@ -53,7 +53,7 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
|
||||
*/
|
||||
} else
|
||||
{
|
||||
PyObject *o = PythonLookupSpecial(s);
|
||||
o = PythonLookupSpecial(s);
|
||||
}
|
||||
if (o) {
|
||||
Py_INCREF( o );
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -115,8 +115,6 @@ PyObject *PythonLookup(const char *s, PyObject *oo) {
|
||||
|
||||
PyObject *find_obj(PyObject *ob, term_t l, bool eval) {
|
||||
YAP_Term hd, yt;
|
||||
bool may_be_package = true;
|
||||
|
||||
|
||||
py_Context = NULL;
|
||||
yt = YAP_GetFromSlot(l);
|
||||
@@ -582,7 +580,7 @@ static long get_len_of_range(long lo, long hi, long step) {
|
||||
return n;
|
||||
}
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
#if PY_MAJOR_VERSION >= 3 && defined(USE_NAMEDTUPLES)
|
||||
static PyStructSequence_Field pnull[] = {
|
||||
{"A1", NULL}, {"A2", NULL}, {"A3", NULL}, {"A4", NULL},
|
||||
{"A5", NULL}, {"A6", NULL}, {"A7", NULL}, {"A8", NULL},
|
||||
|
@@ -77,7 +77,8 @@ static void install_py_constants(void) {
|
||||
Py_INCREF(py_Builtin);
|
||||
py_ModDict = PyObject_GetAttrString(py_Sys, "modules");
|
||||
py_Yapex = PyImport_ImportModule("yapex");
|
||||
PyObject *py_Yap = PyImport_ImportModule("yap");
|
||||
// PyObject *py_Yap =
|
||||
PyImport_ImportModule("yap");
|
||||
Py_INCREF(py_Yapex);
|
||||
//py_F2P = PyObject_GetAttrString(py_Yap, "globals");
|
||||
py_F2P = NULL;
|
||||
|
@@ -1,44 +0,0 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
from jupyter_client.kernelspec import install_kernel_spec
|
||||
except ImportError:
|
||||
from IPython.kernel.kernelspec import install_kernel_spec
|
||||
from IPython.utils.tempdir import TemporaryDirectory
|
||||
|
||||
|
||||
kernel_json = {
|
||||
"argv": [sys.executable,
|
||||
"-m", "yap_kernel",
|
||||
"-f", "{connection_file}"],
|
||||
"display_name": "yap",
|
||||
"mimetype": "text/x-prolog",
|
||||
"language": "prolog",
|
||||
"name": "yap",
|
||||
}
|
||||
|
||||
def install_my_kernel_spec(user=False):
|
||||
with TemporaryDirectory() as td:
|
||||
os.chmod(td, 0o755) # Starts off as 700, not user readable
|
||||
with open(os.path.join(td, 'kernel.json'), 'w') as f:
|
||||
json.dump(kernel_json, f, sort_keys=True)
|
||||
# TODO: Copy resources once they're specified
|
||||
|
||||
print('Installing IPython kernel spec')
|
||||
install_kernel_spec(td, 'yap', user=False, replace=True)
|
||||
|
||||
def _is_root():
|
||||
return True
|
||||
try:
|
||||
return os.geteuid() == 0
|
||||
except AttributeError:
|
||||
return False # assume not an admin on non-Unix platforms
|
||||
|
||||
def main(argv=[]):
|
||||
user = '--user' in argv or not _is_root()
|
||||
install_my_kernel_spec(user=user)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(argv=sys.argv)
|
Reference in New Issue
Block a user