Check for existing libclingJupyter, not whether it's executable.
This commit is contained in:
parent
434d039331
commit
a558c4cf02
@ -62,7 +62,7 @@ class ClingKernel(Kernel):
|
||||
'codemirror_mode': 'text/x-c++src',
|
||||
'mimetype': ' text/x-c++src',
|
||||
'file_extension': '.c++'}
|
||||
|
||||
|
||||
flush_interval = Float(0.25, config=True)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
@ -80,12 +80,12 @@ class ClingKernel(Kernel):
|
||||
|
||||
for ext in ['so', 'dylib', 'dll']:
|
||||
libFilename = clingInstDir + "/lib/libclingJupyter." + ext
|
||||
if os.access(libFilename, os.X_OK):
|
||||
if os.access(libFilename, os.R_OK):
|
||||
self.libclingJupyter = ctypes.CDLL(clingInstDir + "/lib/libclingJupyter." + ext,
|
||||
mode = ctypes.RTLD_GLOBAL)
|
||||
break
|
||||
|
||||
if not self.libclingJupyter:
|
||||
if not getattr(self, 'libclingJupyter', None):
|
||||
raise RuntimeError('Cannot find ' + clingInstDir + '/lib/libclingJupyter.{so,dylib,dll}')
|
||||
|
||||
self.libclingJupyter.cling_create.restype = my_void_p
|
||||
@ -101,10 +101,10 @@ class ClingKernel(Kernel):
|
||||
self.output_thread = threading.Thread(target=self.publish_pipe_output)
|
||||
self.output_thread.daemon = True
|
||||
self.output_thread.start()
|
||||
|
||||
|
||||
def _recv_dict(self, pipe):
|
||||
"""Receive a serialized dict on a pipe
|
||||
|
||||
|
||||
Returns the dictionary.
|
||||
"""
|
||||
# Wire format:
|
||||
@ -135,13 +135,13 @@ class ClingKernel(Kernel):
|
||||
value = os.read(pipe, len_value).decode('utf8')
|
||||
data[key] = value
|
||||
return data
|
||||
|
||||
|
||||
def publish_pipe_output(self):
|
||||
"""Watch output_pipe for display-data messages
|
||||
|
||||
|
||||
and publish them on IOPub when they arrive
|
||||
"""
|
||||
|
||||
|
||||
while True:
|
||||
select.select([self.output_pipe], [], [])
|
||||
data = self._recv_dict(self.output_pipe)
|
||||
@ -163,13 +163,13 @@ class ClingKernel(Kernel):
|
||||
c_flush_p = c_stderr_p
|
||||
else:
|
||||
raise ValueError("Name must be stdout or stderr, not %r" % name)
|
||||
|
||||
|
||||
real_fd = getattr(sys, '__%s__' % name).fileno()
|
||||
save_fd = os.dup(real_fd)
|
||||
pipe_out, pipe_in = os.pipe()
|
||||
os.dup2(pipe_in, real_fd)
|
||||
os.close(pipe_in)
|
||||
|
||||
|
||||
# make pipe_out non-blocking
|
||||
flags = fcntl(pipe_out, F_GETFL)
|
||||
fcntl(pipe_out, F_SETFL, flags|os.O_NONBLOCK)
|
||||
@ -201,7 +201,7 @@ class ClingKernel(Kernel):
|
||||
libc.fflush(c_flush_p)
|
||||
os.close(real_fd)
|
||||
t.join()
|
||||
|
||||
|
||||
# and restore original stdout
|
||||
os.close(pipe_out)
|
||||
os.dup2(save_fd, real_fd)
|
||||
@ -220,7 +220,7 @@ class ClingKernel(Kernel):
|
||||
'user_expressions': {},
|
||||
}
|
||||
status = 'ok'
|
||||
|
||||
|
||||
with self.forward_stream('stdout'), self.forward_stream('stderr'):
|
||||
stringResult = self.run_cell(code, silent)
|
||||
|
||||
@ -266,7 +266,7 @@ class ClingKernel(Kernel):
|
||||
})
|
||||
else:
|
||||
raise ValueError("Invalid status: %r" % status)
|
||||
|
||||
|
||||
return reply
|
||||
|
||||
def do_complete(self, code, cursor_pos):
|
||||
|
Loading…
x
Reference in New Issue
Block a user