iruby 0.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +35 -10
  3. data/Gemfile +4 -0
  4. data/README.md +115 -84
  5. data/Rakefile +26 -0
  6. data/ci/Dockerfile.base.erb +41 -0
  7. data/ci/Dockerfile.main.erb +9 -0
  8. data/ci/requirements.txt +1 -0
  9. data/docker/setup.sh +15 -0
  10. data/docker/test.sh +7 -0
  11. data/iruby.gemspec +4 -2
  12. data/lib/iruby.rb +13 -7
  13. data/lib/iruby/command.rb +67 -11
  14. data/lib/iruby/input/README.md +299 -0
  15. data/lib/iruby/jupyter.rb +76 -0
  16. data/lib/iruby/kernel.rb +49 -9
  17. data/lib/iruby/ostream.rb +4 -0
  18. data/lib/iruby/session.rb +116 -0
  19. data/lib/iruby/session/cztop.rb +4 -0
  20. data/lib/iruby/session/rbczmq.rb +5 -1
  21. data/lib/iruby/session_adapter.rb +68 -0
  22. data/lib/iruby/session_adapter/cztop_adapter.rb +45 -0
  23. data/lib/iruby/session_adapter/ffirzmq_adapter.rb +55 -0
  24. data/lib/iruby/session_adapter/pyzmq_adapter.rb +76 -0
  25. data/lib/iruby/session_adapter/rbczmq_adapter.rb +33 -0
  26. data/lib/iruby/utils.rb +1 -2
  27. data/lib/iruby/version.rb +1 -1
  28. data/run-test.sh +12 -0
  29. data/tasks/ci.rake +65 -0
  30. data/test/integration_test.rb +22 -10
  31. data/test/iruby/command_test.rb +208 -0
  32. data/test/iruby/jupyter_test.rb +28 -0
  33. data/test/iruby/multi_logger_test.rb +1 -1
  34. data/test/iruby/session_adapter/cztop_adapter_test.rb +20 -0
  35. data/test/iruby/session_adapter/ffirzmq_adapter_test.rb +20 -0
  36. data/test/iruby/session_adapter/rbczmq_adapter_test.rb +37 -0
  37. data/test/iruby/session_adapter/session_adapter_test_base.rb +29 -0
  38. data/test/iruby/session_adapter_test.rb +116 -0
  39. data/test/iruby/session_test.rb +53 -0
  40. data/test/test_helper.rb +44 -1
  41. metadata +72 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 535b2e6920da18e1d6610cda01d192814a5f9595
4
- data.tar.gz: 401889f3e858262e478fa15a3c709bcd6d09bd16
2
+ SHA256:
3
+ metadata.gz: ab064a6f7df94f983b75ff53092fb54f6e9a7cc747e220a2e5b021eac840897e
4
+ data.tar.gz: c20d21297d688fc7794b4d0813ada1d9762ba38ea0fb3ccd99f9fbe7845ca5e3
5
5
  SHA512:
6
- metadata.gz: 5d35b89326c32a1dcb52fc2242e366b693ffcac70b3b0ad232233010a6cd1de7c894429c724fb96a766ed35d995465c7b61e3274c7836639a8afd7a9fa56f0e9
7
- data.tar.gz: 423d15b33c265bd943b5811fb3993f79d2da741790948f9efdd5890ca0f755f94d9fdb51ee78faf5adfa612a30d031e4014758725322f4fe22fd099c37a093c4
6
+ metadata.gz: eaf70e7d4ac97a11e03c7c6b5a94f5eb3d1b521ed18332ae510be5872c7faa87fb2814101fff22a8a5019adc8a93915085fb93c1fee5cfec24dd936c57c13fd4
7
+ data.tar.gz: cbfb04ac1dc3be65aa4c1c83b0701e39d603a439b35119b0bfa11d11467a7e4b3d29f347317b5b2f9cdfecd17fdcaf4b1474513d56b8a730764ff1ee7482cab7
@@ -1,16 +1,41 @@
1
+ sudo: required
2
+
1
3
  language: ruby
2
4
 
3
- rvm:
4
- - ruby-head
5
- - 2.2.2
6
- - 2.1.6
7
- - 2.0.0
5
+ services:
6
+ - docker
8
7
 
9
8
  before_install:
10
- - "sudo apt-get install libzmq3-dev"
11
- - "sudo pip install 'ipython[notebook]'"
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
- script: bundle exec rake
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
- notifications:
16
- irc: "chat.freenode.net#sciruby"
40
+ allow_failures:
41
+ - name: "Ruby trunk-nightly"
data/Gemfile CHANGED
@@ -13,3 +13,7 @@ group :plot do
13
13
  gem 'nyaplot', github: 'sciruby/nyaplot'
14
14
  end
15
15
 
16
+ group :test do
17
+ gem 'cztop'
18
+ gem 'rbczmq'
19
+ end
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
- This is a Ruby kernel for IPython/Jupyter and is part of [SciRuby](http://sciruby.com/). You can try it at [try.jupyter.org](http://try.jupyter.org/).
6
-
7
- ![Screenshot](https://cloud.githubusercontent.com/assets/50754/7956845/3fa46df8-09e3-11e5-8641-f5b8669061b5.png)
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
- ### Quick start
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
- #### Ubuntu/Debian
13
- At first install IPython/Jupyter. I recommend an installation using virtualenv.
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
- sudo apt-get install python3-dev python-virtualenv
16
- virtualenv -p python3 venv
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
- After that, install the Ruby gem.
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
- gem install cztop
23
- gem install iruby
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
- Now you can run iruby with:
30
+ #### Setup ZeroMQ on Ubuntu 17.04 to 18.10
31
+ Use official packages.
26
32
 
27
- iruby notebook
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
- #### Windows
30
- At first install IPython/Jupyter. I recommend an installation using [Enthought Canopy](https://www.enthought.com/).
38
+ #### Install CZTop and IRuby
39
+ ```shell
40
+ gem install cztop
41
+ gem install iruby --pre
42
+ iruby register --force
43
+ ```
31
44
 
32
- Run two commands below:
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
- gem install cztop
35
- gem install iruby
49
+ Install ZeroMQ.
50
+ ```shell
51
+ pacman -S mingw64/mingw-w64-x86_64-zeromq
52
+ ```
36
53
 
37
- Now you can run iruby with:
54
+ ```shell
55
+ gem install ffi-rzmq
56
+ gem install iruby --pre
57
+ iruby register --force
58
+ ```
38
59
 
39
- iruby notebook
60
+ ### macOS
61
+ Install ruby with rbenv or rvm.
62
+ Install Jupyter with [Anaconda](https://www.anaconda.com/) (recommended).
40
63
 
41
- #### Mac
42
- I recommend an installation using [Anaconda](https://store.continuum.io/cshop/anaconda/).
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
- After that, run three commands shown below.
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
- brew install libtool autoconf automake autogen
47
- gem install cztop
48
- gem install iruby
80
+ #### MacPorts
81
+ If you are using macports, run the following commands.
49
82
 
50
- #### FreeBSD
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
- ```shell
60
- LIB_DEPENDS= libzmq.so:${PORTSDIR}/net/libzmq4
61
- ```
62
- with
63
- ```shell
64
- LIB_DEPENDS= libzmq.so:${PORTSDIR}/net/libzmq3
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
- ```shell
69
- $ sudo pkg install libzmq3 py27-qt4-gui py27-pexpect-3.3 py27-qt4-svg py27-pygments py27-Jinja2 py27-tornado py27-jsonschema
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
- ```shell
74
- $ cd /usr/ports/net/py-pyzmq
75
- $ sudo make install
76
- $ cd /usr/ports/devel/ipython
77
- $ sudo make install
78
- ```
79
- Then, install iruby and related ports and gems.
80
- ```shell
81
- $ sudo pkg install rubygem-mimemagic
82
- $ sudo gem install ffi-rzmq # install ffi, ffi-rzmq-core and ffi-rzmq
83
- $ git clone https://github.com/SciRuby/iruby.git
84
- $ cd iruby
85
- $ gem build iruby.gemspec
86
- $ sudo gem install iruby-0.2.7.gem
87
- ```
88
- ### Installation for jRuby
89
-
90
- Since jRuby is fully compatible with Ruby version 2.2, it is possible to use iruby with jRuby.
91
- It can be helpful if you want to use java classes in your iruby notebook.
92
- This will require the following software:
93
- * jRuby version >= 9.0.4.0
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
- * this iruby gem
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
- If you have already used iruby with a different version, you need to generate a new kernel:
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
- ### Required dependencies
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
- ### License
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 for details.
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
+ )
@@ -0,0 +1,9 @@
1
+ FROM iruby-test-base:ruby-<%= ruby_version %>
2
+
3
+ RUN gem install cztop \
4
+ && gem install rbczmq -- --with-system-libs
5
+
6
+ RUN mkdir -p /iruby
7
+ ADD . /iruby
8
+ WORKDIR /iruby
9
+ RUN bundle install
@@ -0,0 +1 @@
1
+ jupyter-console>=6.0.0
@@ -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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+
3
+ set -ex
4
+
5
+ cd /tmp/iruby
6
+ bundle install --with test --without plot
7
+ bundle exec rake test
@@ -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', '~> 10.4'
28
- s.add_development_dependency 'minitest', '~> 5.6'
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'