iruby 0.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +35 -10
- data/Gemfile +4 -0
- data/README.md +115 -84
- data/Rakefile +26 -0
- data/ci/Dockerfile.base.erb +41 -0
- data/ci/Dockerfile.main.erb +9 -0
- data/ci/requirements.txt +1 -0
- data/docker/setup.sh +15 -0
- data/docker/test.sh +7 -0
- data/iruby.gemspec +4 -2
- data/lib/iruby.rb +13 -7
- data/lib/iruby/command.rb +67 -11
- data/lib/iruby/input/README.md +299 -0
- data/lib/iruby/jupyter.rb +76 -0
- data/lib/iruby/kernel.rb +49 -9
- data/lib/iruby/ostream.rb +4 -0
- data/lib/iruby/session.rb +116 -0
- data/lib/iruby/session/cztop.rb +4 -0
- data/lib/iruby/session/rbczmq.rb +5 -1
- data/lib/iruby/session_adapter.rb +68 -0
- data/lib/iruby/session_adapter/cztop_adapter.rb +45 -0
- data/lib/iruby/session_adapter/ffirzmq_adapter.rb +55 -0
- data/lib/iruby/session_adapter/pyzmq_adapter.rb +76 -0
- data/lib/iruby/session_adapter/rbczmq_adapter.rb +33 -0
- data/lib/iruby/utils.rb +1 -2
- data/lib/iruby/version.rb +1 -1
- data/run-test.sh +12 -0
- data/tasks/ci.rake +65 -0
- data/test/integration_test.rb +22 -10
- data/test/iruby/command_test.rb +208 -0
- data/test/iruby/jupyter_test.rb +28 -0
- data/test/iruby/multi_logger_test.rb +1 -1
- data/test/iruby/session_adapter/cztop_adapter_test.rb +20 -0
- data/test/iruby/session_adapter/ffirzmq_adapter_test.rb +20 -0
- data/test/iruby/session_adapter/rbczmq_adapter_test.rb +37 -0
- data/test/iruby/session_adapter/session_adapter_test_base.rb +29 -0
- data/test/iruby/session_adapter_test.rb +116 -0
- data/test/iruby/session_test.rb +53 -0
- data/test/test_helper.rb +44 -1
- metadata +72 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ab064a6f7df94f983b75ff53092fb54f6e9a7cc747e220a2e5b021eac840897e
|
4
|
+
data.tar.gz: c20d21297d688fc7794b4d0813ada1d9762ba38ea0fb3ccd99f9fbe7845ca5e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaf70e7d4ac97a11e03c7c6b5a94f5eb3d1b521ed18332ae510be5872c7faa87fb2814101fff22a8a5019adc8a93915085fb93c1fee5cfec24dd936c57c13fd4
|
7
|
+
data.tar.gz: cbfb04ac1dc3be65aa4c1c83b0701e39d603a439b35119b0bfa11d11467a7e4b3d29f347317b5b2f9cdfecd17fdcaf4b1474513d56b8a730764ff1ee7482cab7
|
data/.travis.yml
CHANGED
@@ -1,16 +1,41 @@
|
|
1
|
+
sudo: required
|
2
|
+
|
1
3
|
language: ruby
|
2
4
|
|
3
|
-
|
4
|
-
-
|
5
|
-
- 2.2.2
|
6
|
-
- 2.1.6
|
7
|
-
- 2.0.0
|
5
|
+
services:
|
6
|
+
- docker
|
8
7
|
|
9
8
|
before_install:
|
10
|
-
-
|
11
|
-
-
|
9
|
+
- docker images
|
10
|
+
- rake ci:docker:before_install
|
11
|
+
|
12
|
+
install:
|
13
|
+
- rake ci:docker:install
|
14
|
+
- docker images
|
15
|
+
|
16
|
+
after_install:
|
17
|
+
- rake ci:docker:install
|
18
|
+
- docker images
|
19
|
+
|
20
|
+
script: rake ci:docker:script
|
12
21
|
|
13
|
-
|
22
|
+
matrix:
|
23
|
+
include:
|
24
|
+
- name: "Ruby trunk-nightly"
|
25
|
+
env:
|
26
|
+
- ruby_version=trunk-nightly
|
27
|
+
- name: "Ruby 2.6"
|
28
|
+
env:
|
29
|
+
- ruby_version=2.6.1
|
30
|
+
- name: "Ruby 2.5"
|
31
|
+
env:
|
32
|
+
- ruby_version=2.5.3
|
33
|
+
- name: "Ruby 2.4"
|
34
|
+
env:
|
35
|
+
- ruby_version=2.4.5
|
36
|
+
- name: "Ruby 2.3"
|
37
|
+
env:
|
38
|
+
- ruby_version=2.3.8
|
14
39
|
|
15
|
-
|
16
|
-
|
40
|
+
allow_failures:
|
41
|
+
- name: "Ruby trunk-nightly"
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,54 +1,92 @@
|
|
1
|
-
***The current master branch and gem version >= 0.2 are compatible with IPython3/Jupyter. If you require IPython2 support, please install an older gem version < 0.2 or use the branch ipython2***
|
2
|
-
|
3
1
|
# IRuby
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
![
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/iruby.svg)](https://badge.fury.io/rb/iruby)
|
4
|
+
[![Build Status](https://travis-ci.org/SciRuby/iruby.svg?branch=master)](https://travis-ci.org/SciRuby/iruby)
|
5
|
+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/RubyData/binder/master?filepath=ruby-data.ipynb)
|
8
6
|
|
9
|
-
|
10
|
-
The installation instructions are divided according to environments mainly because of ZeroMQ.
|
7
|
+
IRuby is a Ruby kernel for [Jupyter project](http://try.jupyter.org/).
|
11
8
|
|
12
|
-
|
13
|
-
|
9
|
+
## Installation
|
10
|
+
How to set up [ZeroMQ](http://zeromq.org/) depends on your environment.
|
11
|
+
You can use one of the following libraries.
|
12
|
+
* [CZTop](https://gitlab.com/paddor/cztop) and [CZMQ](https://github.com/zeromq/czmq) >= 4.0.0
|
13
|
+
* [ffi-rzmq](https://github.com/chuckremes/ffi-rzmq) and [libzmq
|
14
|
+
](https://github.com/zeromq/libzmq) >= 3.2
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
source venv/bin/activate
|
18
|
-
pip install 'ipython[notebook]'
|
16
|
+
### Ubuntu
|
17
|
+
Install Jupyter with [Anaconda](https://www.anaconda.com/) (recommended).
|
19
18
|
|
20
|
-
|
19
|
+
#### Setup ZeroMQ on Ubuntu 16.04
|
20
|
+
CZTop requires CZMQ >= 4.0.0 and ZMQ >= 4.2.0. The official packages for Ubuntu 16.04 don't satisfy these version requrements, so you need to install from source.
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
```shell
|
23
|
+
sudo apt install libtool libffi-dev ruby ruby-dev make
|
24
|
+
sudo apt install git libzmq-dev autoconf pkg-config
|
25
|
+
git clone https://github.com/zeromq/czmq
|
26
|
+
cd czmq
|
27
|
+
./autogen.sh && ./configure && sudo make && sudo make install
|
28
|
+
```
|
24
29
|
|
25
|
-
|
30
|
+
#### Setup ZeroMQ on Ubuntu 17.04 to 18.10
|
31
|
+
Use official packages.
|
26
32
|
|
27
|
-
|
33
|
+
```shell
|
34
|
+
sudo apt install libtool libffi-dev ruby ruby-dev make
|
35
|
+
sudo apt install libzmq3-dev libczmq-dev
|
36
|
+
```
|
28
37
|
|
29
|
-
####
|
30
|
-
|
38
|
+
#### Install CZTop and IRuby
|
39
|
+
```shell
|
40
|
+
gem install cztop
|
41
|
+
gem install iruby --pre
|
42
|
+
iruby register --force
|
43
|
+
```
|
31
44
|
|
32
|
-
|
45
|
+
### Windows
|
46
|
+
Install git and Jupyter with [Anaconda](https://www.anaconda.com/) (recommended).
|
47
|
+
[DevKit](https://rubyinstaller.org/add-ons/devkit.html) is necessary for building RubyGems with native C-based extensions.
|
33
48
|
|
34
|
-
|
35
|
-
|
49
|
+
Install ZeroMQ.
|
50
|
+
```shell
|
51
|
+
pacman -S mingw64/mingw-w64-x86_64-zeromq
|
52
|
+
```
|
36
53
|
|
37
|
-
|
54
|
+
```shell
|
55
|
+
gem install ffi-rzmq
|
56
|
+
gem install iruby --pre
|
57
|
+
iruby register --force
|
58
|
+
```
|
38
59
|
|
39
|
-
|
60
|
+
### macOS
|
61
|
+
Install ruby with rbenv or rvm.
|
62
|
+
Install Jupyter with [Anaconda](https://www.anaconda.com/) (recommended).
|
40
63
|
|
41
|
-
####
|
42
|
-
|
64
|
+
#### Homebrew
|
65
|
+
```shell
|
66
|
+
brew install automake gmp libtool wget
|
67
|
+
brew install zeromq --HEAD
|
68
|
+
brew install czmq --HEAD
|
69
|
+
```
|
43
70
|
|
44
|
-
|
71
|
+
```shell
|
72
|
+
# export LIBZMQ_PATH=$(brew --prefix zeromq)/lib
|
73
|
+
# export LIBCZMQ_PATH=$(brew --prefix czmq)/lib
|
74
|
+
# gem install cztop
|
75
|
+
gem install ffi-rzmq
|
76
|
+
gem install iruby --pre
|
77
|
+
iruby register --force
|
78
|
+
```
|
45
79
|
|
46
|
-
|
47
|
-
|
48
|
-
gem install iruby
|
80
|
+
#### MacPorts
|
81
|
+
If you are using macports, run the following commands.
|
49
82
|
|
50
|
-
|
83
|
+
```shell
|
84
|
+
port install libtool autoconf automake autogen
|
85
|
+
gem install ffi-rzmq
|
86
|
+
gem install iruby
|
87
|
+
```
|
51
88
|
|
89
|
+
### FreeBSD
|
52
90
|
At first install IPython/Jupyter.
|
53
91
|
There is a pyzmq ports (ports/net/py-pyzmq) which depends on libzmq4, however, it doesn't works with ipython.
|
54
92
|
Therefore we use libzmq3 like the following:
|
@@ -56,79 +94,72 @@ Therefore we use libzmq3 like the following:
|
|
56
94
|
1. make your ports tree up-to-date.
|
57
95
|
2. replace LIBDEPENDS line in ports/net/py-pyzmq/Makefile
|
58
96
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
97
|
+
```shell
|
98
|
+
LIB_DEPENDS= libzmq.so:${PORTSDIR}/net/libzmq4
|
99
|
+
```
|
100
|
+
with
|
101
|
+
```shell
|
102
|
+
LIB_DEPENDS= libzmq.so:${PORTSDIR}/net/libzmq3
|
103
|
+
```
|
66
104
|
3. install related packages
|
67
105
|
|
68
|
-
|
69
|
-
|
70
|
-
|
106
|
+
```shell
|
107
|
+
sudo pkg install libzmq3 py27-qt4-gui py27-pexpect-3.3 py27-qt4-svg py27-pygments py27-Jinja2 py27-tornado py27-jsonschema
|
108
|
+
```
|
71
109
|
4. make install using ports
|
72
110
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
Then, install
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
*
|
111
|
+
```shell
|
112
|
+
cd /usr/ports/net/py-pyzmq
|
113
|
+
sudo make install
|
114
|
+
cd /usr/ports/devel/ipython
|
115
|
+
sudo make install
|
116
|
+
```
|
117
|
+
Then, install IRuby and related ports and gems.
|
118
|
+
```shell
|
119
|
+
sudo pkg install rubygem-mimemagic
|
120
|
+
sudo gem install ffi-rzmq # install ffi, ffi-rzmq-core and ffi-rzmq
|
121
|
+
git clone https://github.com/SciRuby/iruby.git
|
122
|
+
cd iruby
|
123
|
+
gem build iruby.gemspec
|
124
|
+
sudo gem install iruby-0.2.7.gem
|
125
|
+
```
|
126
|
+
|
127
|
+
### Installation for JRuby
|
128
|
+
|
129
|
+
You can use Java classes in your IRuby notebook.
|
130
|
+
|
131
|
+
* JRuby version >= 9.0.4.0
|
94
132
|
* cztop gem
|
95
|
-
*
|
133
|
+
* iruby gem
|
134
|
+
|
135
|
+
After installation, make sure that your `env` is set up to use jruby.
|
96
136
|
|
97
|
-
After installation, make sure that your `env` is set up to jruby.
|
98
137
|
```shell
|
99
138
|
$ env ruby -v
|
100
139
|
```
|
140
|
+
|
101
141
|
If you use RVM, it is enough to switch the current version to jruby.
|
102
|
-
|
142
|
+
|
143
|
+
If you have already used IRuby with a different version, you need to generate a new kernel:
|
144
|
+
|
103
145
|
```shell
|
104
146
|
$ iruby register --force
|
105
147
|
```
|
106
|
-
After that you can use iruby with jRuby in usual way.
|
107
|
-
|
108
|
-
### After the installation
|
109
148
|
|
149
|
+
## Notebooks
|
110
150
|
Take a look at the [example notebook](http://nbviewer.ipython.org/urls/raw.github.com/SciRuby/sciruby-notebooks/master/getting_started.ipynb)
|
111
151
|
and the [collection of notebooks](https://github.com/SciRuby/sciruby-notebooks/) which includes a Dockerfile to create a containerized installation of iruby
|
112
152
|
and other scientific gems. You can find the prebuild image at [dockerhub](https://registry.hub.docker.com/u/minad/sciruby-notebooks/).
|
113
153
|
|
154
|
+
## Contributing
|
155
|
+
We welcome contributions from everyone.
|
114
156
|
|
115
|
-
|
116
|
-
|
117
|
-
* IPython/Jupyter >= 3.0.0
|
118
|
-
* Ruby >= 2.1.0
|
119
|
-
|
120
|
-
If you install IRuby with CZTop, CZMQ >= 4.0.0 is added to the list above.
|
121
|
-
|
122
|
-
If you install IRuby with ffi-rzmq, libzmq >= 3.2 is added to the list above.
|
123
|
-
|
124
|
-
### Authors
|
125
|
-
|
157
|
+
## Authors
|
126
158
|
See the [CONTRIBUTORS](CONTRIBUTORS) file.
|
127
159
|
|
128
|
-
|
129
|
-
|
130
|
-
Copyright © 2013-15, IRuby contributors and the Ruby Science Foundation.
|
160
|
+
## License
|
161
|
+
Copyright © 2013-19, IRuby contributors and the Ruby Science Foundation.
|
131
162
|
|
132
163
|
All rights reserved.
|
133
164
|
|
134
|
-
IRuby, along with [SciRuby](http://sciruby.com/), is licensed under the MIT license. See the [LICENSE](LICENSE) file
|
165
|
+
IRuby, along with [SciRuby](http://sciruby.com/), is licensed under the MIT license. See the [LICENSE](LICENSE) file.
|
data/Rakefile
CHANGED
@@ -5,6 +5,8 @@ begin
|
|
5
5
|
rescue Exception
|
6
6
|
end
|
7
7
|
|
8
|
+
FileList['tasks/**.rake'].each {|f| load f }
|
9
|
+
|
8
10
|
Rake::TestTask.new('test') do |t|
|
9
11
|
t.libs << 'lib'
|
10
12
|
t.libs << 'test'
|
@@ -13,3 +15,27 @@ Rake::TestTask.new('test') do |t|
|
|
13
15
|
end
|
14
16
|
|
15
17
|
task default: 'test'
|
18
|
+
|
19
|
+
namespace :docker do
|
20
|
+
def root_dir
|
21
|
+
@root_dir ||= File.expand_path("..", __FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
task :build do
|
25
|
+
container_name = "iruby_build"
|
26
|
+
image_name = "mrkn/iruby"
|
27
|
+
sh "docker", "run",
|
28
|
+
"--name", container_name,
|
29
|
+
"-v", "#{root_dir}:/tmp/iruby",
|
30
|
+
"rubylang/ruby", "/bin/bash", "/tmp/iruby/docker/setup.sh"
|
31
|
+
sh "docker", "commit", container_name, image_name
|
32
|
+
sh "docker", "rm", container_name
|
33
|
+
end
|
34
|
+
|
35
|
+
task :test do
|
36
|
+
root_dir = File.expand_path("..", __FILE__)
|
37
|
+
sh "docker", "run", "-it", "--rm",
|
38
|
+
"-v", "#{root_dir}:/tmp/iruby",
|
39
|
+
"mrkn/iruby", "/bin/bash", "/tmp/iruby/docker/test.sh"
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
FROM rubylang/ruby:<%= ruby_version %>-bionic
|
2
|
+
|
3
|
+
ADD ci/requirements.txt /tmp
|
4
|
+
|
5
|
+
RUN apt-get update \
|
6
|
+
&& apt-get install -y --no-install-recommends \
|
7
|
+
libczmq-dev \
|
8
|
+
python3 \
|
9
|
+
python3-pip \
|
10
|
+
python3-setuptools \
|
11
|
+
libpython3.6 \
|
12
|
+
&& pip3 install wheel \
|
13
|
+
&& pip3 install -r /tmp/requirements.txt \
|
14
|
+
&& rm -f /tmp/requirements.txt
|
15
|
+
|
16
|
+
# ZeroMQ version 4.1.6 and CZMQ version 3.0.2 for rbczmq
|
17
|
+
RUN apt-get update \
|
18
|
+
&& apt-get install -y --no-install-recommends \
|
19
|
+
build-essential \
|
20
|
+
file \
|
21
|
+
wget \
|
22
|
+
&& cd /tmp \
|
23
|
+
&& wget https://github.com/zeromq/zeromq4-1/releases/download/v4.1.6/zeromq-4.1.6.tar.gz \
|
24
|
+
&& wget https://archive.org/download/zeromq_czmq_3.0.2/czmq-3.0.2.tar.gz \
|
25
|
+
&& tar xf zeromq-4.1.6.tar.gz \
|
26
|
+
&& tar xf czmq-3.0.2.tar.gz \
|
27
|
+
&& \
|
28
|
+
( \
|
29
|
+
cd zeromq-4.1.6 \
|
30
|
+
&& ./configure \
|
31
|
+
&& make install \
|
32
|
+
) \
|
33
|
+
&& \
|
34
|
+
( \
|
35
|
+
cd czmq-3.0.2 \
|
36
|
+
&& wget -O 1.patch https://github.com/zeromq/czmq/commit/2594d406d8ec6f54e54d7570d7febba10a6906b2.diff \
|
37
|
+
&& wget -O 2.patch https://github.com/zeromq/czmq/commit/b651cb479235751b22b8f9a822a2fc6bc1be01ab.diff \
|
38
|
+
&& cat *.patch | patch -p1 \
|
39
|
+
&& ./configure \
|
40
|
+
&& make install \
|
41
|
+
)
|
data/ci/requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jupyter-console>=6.0.0
|
data/docker/setup.sh
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -ex
|
4
|
+
|
5
|
+
apt-get update
|
6
|
+
apt-get install -y --no-install-recommends \
|
7
|
+
libczmq-dev \
|
8
|
+
python3 \
|
9
|
+
python3-pip \
|
10
|
+
python3-setuptools \
|
11
|
+
python3-wheel
|
12
|
+
|
13
|
+
cd /tmp/iruby
|
14
|
+
bundle install --with test --without plot
|
15
|
+
pip3 install jupyter
|
data/docker/test.sh
ADDED
data/iruby.gemspec
CHANGED
@@ -24,8 +24,10 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
s.required_ruby_version = '>= 2.1.0'
|
26
26
|
|
27
|
-
s.add_development_dependency 'rake'
|
28
|
-
s.add_development_dependency 'minitest'
|
27
|
+
s.add_development_dependency 'rake'
|
28
|
+
s.add_development_dependency 'minitest'
|
29
|
+
s.add_development_dependency 'ffi-rzmq'
|
30
|
+
s.add_development_dependency 'pycall', '>= 1.2.1'
|
29
31
|
|
30
32
|
s.add_runtime_dependency 'bond', '~> 0.5'
|
31
33
|
s.add_runtime_dependency 'multi_json', '~> 1.11'
|