pycall 1.0.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +41 -0
  5. data/CHANGES.md +39 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +91 -0
  9. data/Rakefile +29 -0
  10. data/appveyor.yml +138 -0
  11. data/bin/console +10 -0
  12. data/bin/guard +17 -0
  13. data/bin/rspec +17 -0
  14. data/bin/runner +6 -0
  15. data/bin/setup +8 -0
  16. data/config/Guardfile +30 -0
  17. data/docker/Dockerfile +191 -0
  18. data/docker/Gemfile +12 -0
  19. data/docker/README.md +22 -0
  20. data/examples/classifier_comparison.rb +135 -0
  21. data/examples/datascience_rb_20170519.ipynb +4836 -0
  22. data/examples/hist.rb +32 -0
  23. data/examples/notebooks/classifier_comparison.ipynb +226 -0
  24. data/examples/notebooks/forest_importances.ipynb +238 -0
  25. data/examples/notebooks/iruby_integration.ipynb +183 -0
  26. data/examples/notebooks/lorenz_attractor.ipynb +214 -0
  27. data/examples/notebooks/polar_axes.ipynb +209 -0
  28. data/examples/notebooks/sum_benchmarking.ipynb +374 -0
  29. data/examples/notebooks/xkcd_style.ipynb +149 -0
  30. data/examples/plot_forest_importances_faces.rb +46 -0
  31. data/examples/sum_benchmarking.rb +49 -0
  32. data/ext/pycall/extconf.rb +3 -0
  33. data/ext/pycall/gc.c +74 -0
  34. data/ext/pycall/libpython.c +217 -0
  35. data/ext/pycall/pycall.c +2184 -0
  36. data/ext/pycall/pycall_internal.h +700 -0
  37. data/ext/pycall/range.c +69 -0
  38. data/ext/pycall/ruby_wrapper.c +432 -0
  39. data/lib/2.1/pycall.so +0 -0
  40. data/lib/2.2/pycall.so +0 -0
  41. data/lib/2.3/pycall.so +0 -0
  42. data/lib/2.4/pycall.so +0 -0
  43. data/lib/pycall/conversion.rb +173 -0
  44. data/lib/pycall/dict.rb +48 -0
  45. data/lib/pycall/error.rb +10 -0
  46. data/lib/pycall/gc_guard.rb +84 -0
  47. data/lib/pycall/import.rb +120 -0
  48. data/lib/pycall/init.rb +55 -0
  49. data/lib/pycall/iruby_helper.rb +40 -0
  50. data/lib/pycall/libpython/finder.rb +170 -0
  51. data/lib/pycall/libpython/pyobject_struct.rb +30 -0
  52. data/lib/pycall/libpython/pytypeobject_struct.rb +273 -0
  53. data/lib/pycall/libpython.rb +12 -0
  54. data/lib/pycall/list.rb +45 -0
  55. data/lib/pycall/pretty_print.rb +9 -0
  56. data/lib/pycall/pyerror.rb +30 -0
  57. data/lib/pycall/pyobject_wrapper.rb +212 -0
  58. data/lib/pycall/python/PyCall/__init__.py +1 -0
  59. data/lib/pycall/python/PyCall/six.py +23 -0
  60. data/lib/pycall/python/investigator.py +7 -0
  61. data/lib/pycall/pytypeobject_wrapper.rb +90 -0
  62. data/lib/pycall/set.rb +19 -0
  63. data/lib/pycall/slice.rb +8 -0
  64. data/lib/pycall/tuple.rb +46 -0
  65. data/lib/pycall/version.rb +3 -0
  66. data/lib/pycall/wrapper_object_cache.rb +61 -0
  67. data/lib/pycall.rb +91 -0
  68. data/pycall.gemspec +40 -0
  69. data/tasks/docker.rake +21 -0
  70. data/tasks/pycall.rake +7 -0
  71. metadata +228 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 180214067ddcaf79661c66115fff03746377e8df
4
+ data.tar.gz: cc52f4b1a14b7b404aac141accbe7c59cecb5fcf
5
+ SHA512:
6
+ metadata.gz: c007c0aba62d54a1078df393c67e989c49acaaff3f6c11f8ec46c84a01fb455c4cf10e546df1daaf84c52e0cfe504fa00911525fe2dd21f92f0a46d9c6ddf649
7
+ data.tar.gz: db164125165d7d53fb85d64b0ba050e05051b70fcf00b1417229bc359488dc97fc01b4fef229d50292637e13a844d7ee58f8aa3962caca747d99c9b1b394274b
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ __pycache__
11
+ *.bundle
12
+ *.so
13
+ *.o
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,41 @@
1
+ sudo: false
2
+ language: ruby
3
+
4
+ rvm:
5
+ - ruby-head
6
+ - 2.4.0
7
+ - 2.3.1
8
+ - 2.2.5
9
+ - 2.1.10
10
+
11
+ env:
12
+ global:
13
+ - PYCALL_DEBUG_FIND_LIBPYTHON=1
14
+ matrix:
15
+ - PYTHON=python
16
+ - PYTHON=python3 LIBPYTHON=wrong_value
17
+ - LIBPYTHON=/opt/python/3.5.3/lib/libpython3.5m.so
18
+
19
+ addons:
20
+ apt:
21
+ packages:
22
+ - python3
23
+ - python3-dev
24
+ - python3-all
25
+ - python3-all-dev
26
+
27
+ before_install:
28
+ - gem update --system
29
+ - gem update bundler
30
+
31
+ before_script:
32
+ - bundle exec rake clobber compile
33
+ - echo === python investigator.py ===
34
+ - python lib/pycall/python/investigator.py
35
+ - python3 lib/pycall/python/investigator.py
36
+ - pip install numpy
37
+ - pip3 install numpy
38
+
39
+ matrix:
40
+ allow_failures:
41
+ - env: PYTHON=python # Ignore failed on python 2.7
data/CHANGES.md ADDED
@@ -0,0 +1,39 @@
1
+ # The change history of PyCall
2
+
3
+ ## 1.0.1
4
+
5
+ * Add PyTypeObject#===.
6
+
7
+ ## 1.0.0
8
+
9
+ * `#[]` and `#[]=` accept a `Range` and an `Enumerable`, which is genated by
10
+ `Range#step`, as a slice.
11
+
12
+ * Rewrite almost all fundamental parts of PyCall as C extension.
13
+
14
+ * PyCall now calls `Py_DecRef` in the finalizer of `PyCall::PyPtr`.
15
+
16
+ * Change the system of object mapping between Python and Ruby, drastically.
17
+ Now PyCall does not have `PyObject` class for wrapper objects.
18
+ Instead, PyCall generally makes `Object` instances and extends them by
19
+ `PyObjectWrapper` module.
20
+ But for Python module objects, PyCall makes anonymous `Module` instances
21
+ that are extended by `PyObjectWrapper` module.
22
+ Moreover for Python type objects, PyCall makes `Class` instances and extends
23
+ them by `PyTypeObjectWrapper` module.
24
+
25
+ * Change `PyCall.eval` to be a wrapper of `__builtins__.eval` in Python.
26
+ This means that `filename:` and `input_type:` parameters are dropped.
27
+ Instead, two new parameters `globals:` and `locals:` are introduced.
28
+ `globals:` is used for specifying a dictionary that is the global
29
+ namespace referred by the evaluated expression.
30
+ `locals:` is used for specifying a mapping object that is the local
31
+ namespace referred by the evaluated expression.
32
+
33
+ * Add `PyCall.exec` for the replacement of the former `PyCall.eval`
34
+ with `input_type: :file`.
35
+ It has `globals:` and `locals:` parameters for the same meaning as
36
+ the new `PyCall.eval` described above.
37
+
38
+ * Drop `PyCall.wrap_ruby_callable` and `PyCall.wrap_ruby_object` always
39
+ craetes a callable Python object taht has an ID of the given Ruby object.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pycall.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Kenta Murata
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # PyCall: Calling Python functions from the Ruby language
2
+
3
+ [![Build Status](https://travis-ci.org/mrkn/pycall.svg?branch=master)](https://travis-ci.org/mrkn/pycall)
4
+ [![Build status](https://ci.appveyor.com/api/projects/status/071is0f4iu0vy8lp/branch/master?svg=true)](https://ci.appveyor.com/project/mrkn/pycall/branch/master)
5
+
6
+ This library provides the features to directly call and partially interoperate
7
+ with Python from the Ruby language. You can import arbitrary Python modules
8
+ into Ruby modules, call Python functions with automatic type conversion from
9
+ Ruby to Python.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'pycall'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install --pre pycall
26
+
27
+ ## Usage
28
+
29
+ Here is a simple example to call Python's `math.sin` function and compare it to
30
+ the `Math.sin` in Ruby:
31
+
32
+ require 'pycall/import'
33
+ include PyCall::Import
34
+ pyimport :math
35
+ math.sin(math.pi / 4) - Math.sin(Math::PI / 4) # => 0.0
36
+
37
+ Type conversions from Ruby to Python are automatically performed for numeric,
38
+ boolean, string, arrays, and hashes.
39
+
40
+ ## PyCall object system
41
+
42
+ PyCall wraps pointers of Python objects in `PyCall::PyPtr` objects.
43
+ `PyCall::PyPtr` class has two subclasses, `PyCall::PyTypePtr` and
44
+ `PyCall::PyRubyPtr`. `PyCall::PyTypePtr` is specialized for type (and classobj
45
+ in 2.7) objects, and `PyCall::PyRubyPtr` is for the objects that wraps pointers
46
+ of Ruby objects.
47
+
48
+ These `PyCall::PyPtr` objects are used mainly in PyCall infrastructure.
49
+ Instead, we usually treats the instances of `Object`, `Class`, `Module`, or
50
+ other classes that are extended by `PyCall::PyObjectWrapper` module.
51
+
52
+ `PyCall::PyObjectWrapper` is a mix-in module for objects that wraps Python
53
+ objects. A wrapper object should have `PyCall::PyPtr` object in its instance
54
+ variable `@__pyptr__`. `PyCall::PyObjectWrapper` assumes the existance of
55
+ `@__pyptr__`, and provides general translation mechanisms between Ruby object
56
+ system and Python object system. For example, `PyCall::PyObjectWrapper`
57
+ translates Ruby's coerce system into Python's swapped operation protocol.
58
+
59
+ ### Specifying the Python version
60
+
61
+ If you want to use a specific version of Python instead of the default,
62
+ you can change the Python version by setting the `PYTHON` environment variable
63
+ to the path of the `python` executable.
64
+
65
+ ## Development
66
+
67
+ After checking out the repo, run `bin/setup` to install dependencies.
68
+ Then, run `rake spec` to run the tests. You can also run `bin/console`
69
+ for an interactive prompt that will allow you to experiment.
70
+
71
+ To install this gem onto your local machine, run `bundle exec rake install`.
72
+ To release a new version, update the version number in `version.rb`,
73
+ and then run `bundle exec rake release`, which will create a git tag for the
74
+ version, push git commits and tags, and push the `.gem` file to
75
+ [rubygems.org](https://rubygems.org).
76
+
77
+ ## Contributing
78
+
79
+ Bug reports and pull requests are welcome on GitHub at
80
+ https://github.com/mrkn/pycall.
81
+
82
+
83
+ ## Acknowledgement
84
+
85
+ [PyCall.jl](https://github.com/JuliaPy/PyCall.jl) is referred too many times
86
+ to implement this library.
87
+
88
+ ## License
89
+
90
+ The gem is available as open source under the terms of the
91
+ [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rake"
5
+ require "rake/extensiontask"
6
+ require "rspec/core/rake_task"
7
+
8
+ Dir[File.expand_path('../tasks/**/*.rake', __FILE__)].each {|f| load f }
9
+
10
+ gem_spec = eval(File.read('pycall.gemspec'))
11
+ Rake::ExtensionTask.new('pycall', gem_spec) do |ext|
12
+ ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
13
+ ext.cross_compile = true
14
+ ext.cross_platform = %w[x86-mingw32 x64-mingw32]
15
+ ext.cross_compiling do |s|
16
+ s.files.concat %w[lib/2.2/pycall.so lib/2.3/pycall.so lib/2.4/pycall.so]
17
+ end
18
+ end
19
+
20
+ desc "Compile binaries for mingw platform using rake-compiler-dock"
21
+ task 'build:mingw' do
22
+ require 'rake_compiler_dock'
23
+ RakeCompilerDock.sh "bundle && rake cross native gem RUBY_CC_VERSION=2.1.6:2.2.2:2.3.0:2.4.0"
24
+ end
25
+
26
+ RSpec::Core::RakeTask.new(:spec)
27
+
28
+ task :default => :spec
29
+ task spec: :compile
data/appveyor.yml ADDED
@@ -0,0 +1,138 @@
1
+ ---
2
+ environment:
3
+ matrix:
4
+ # Ruby 2.1 (32bit)
5
+ - ruby_version: "21"
6
+ PYTHONDIR: "C:\\Python27"
7
+ PYTHON: "C:\\Python27\\python.exe"
8
+
9
+ - ruby_version: "21"
10
+ PYTHONDIR: "C:\\Python34"
11
+ PYTHON: "C:\\Python34\\python.exe"
12
+
13
+ - ruby_version: "21"
14
+ PYTHONDIR: "C:\\Python35"
15
+ PYTHON: "C:\\Python35\\python.exe"
16
+
17
+ - ruby_version: "21"
18
+ PYTHONDIR: "C:\\Python36"
19
+ PYTHON: "C:\\Python36\\python.exe"
20
+
21
+ # Ruby 2.1 (64bit)
22
+ - ruby_version: "21-x64"
23
+ PYTHONDIR: "C:\\Python27-x64"
24
+ PYTHON: "C:\\Python27-x64\\python.exe"
25
+
26
+ - ruby_version: "21-x64"
27
+ PYTHONDIR: "C:\\Python34-x64"
28
+ PYTHON: "C:\\Python34-x64\\python.exe"
29
+
30
+ - ruby_version: "21-x64"
31
+ PYTHONDIR: "C:\\Python35-x64"
32
+ PYTHON: "C:\\Python35-x64\\python.exe"
33
+
34
+ - ruby_version: "21-x64"
35
+ PYTHONDIR: "C:\\Python36-x64"
36
+ PYTHON: "C:\\Python36-x64\\python.exe"
37
+
38
+ # Ruby 2.2 (32bit)
39
+ - ruby_version: "22"
40
+ PYTHONDIR: "C:\\Python27"
41
+ PYTHON: "C:\\Python27\\python.exe"
42
+
43
+ - ruby_version: "22"
44
+ PYTHONDIR: "C:\\Python34"
45
+ PYTHON: "C:\\Python34\\python.exe"
46
+
47
+ - ruby_version: "22"
48
+ PYTHONDIR: "C:\\Python35"
49
+ PYTHON: "C:\\Python35\\python.exe"
50
+
51
+ - ruby_version: "22"
52
+ PYTHONDIR: "C:\\Python36"
53
+ PYTHON: "C:\\Python36\\python.exe"
54
+
55
+ # Ruby 2.2 (64bit)
56
+ - ruby_version: "22-x64"
57
+ PYTHONDIR: "C:\\Python27-x64"
58
+ PYTHON: "C:\\Python27-x64\\python.exe"
59
+
60
+ - ruby_version: "22-x64"
61
+ PYTHONDIR: "C:\\Python34-x64"
62
+ PYTHON: "C:\\Python34-x64\\python.exe"
63
+
64
+ - ruby_version: "22-x64"
65
+ PYTHONDIR: "C:\\Python35-x64"
66
+ PYTHON: "C:\\Python35-x64\\python.exe"
67
+
68
+ - ruby_version: "22-x64"
69
+ PYTHONDIR: "C:\\Python36-x64"
70
+ PYTHON: "C:\\Python36-x64\\python.exe"
71
+
72
+ # Ruby 2.3 (32bit)
73
+ - ruby_version: "23"
74
+ PYTHONDIR: "C:\\Python27"
75
+ PYTHON: "C:\\Python27\\python.exe"
76
+
77
+ - ruby_version: "23"
78
+ PYTHONDIR: "C:\\Python34"
79
+ PYTHON: "C:\\Python34\\python.exe"
80
+
81
+ - ruby_version: "23"
82
+ PYTHONDIR: "C:\\Python35"
83
+ PYTHON: "C:\\Python35\\python.exe"
84
+
85
+ - ruby_version: "23"
86
+ PYTHONDIR: "C:\\Python36"
87
+ PYTHON: "C:\\Python36\\python.exe"
88
+
89
+ # Ruby 2.3 (64bit)
90
+ - ruby_version: "23-x64"
91
+ PYTHONDIR: "C:\\Python27-x64"
92
+ PYTHON: "C:\\Python27-x64\\python.exe"
93
+
94
+ - ruby_version: "23-x64"
95
+ PYTHONDIR: "C:\\Python34-x64"
96
+ PYTHON: "C:\\Python34-x64\\python.exe"
97
+
98
+ - ruby_version: "23-x64"
99
+ PYTHONDIR: "C:\\Python35-x64"
100
+ PYTHON: "C:\\Python35-x64\\python.exe"
101
+
102
+ - ruby_version: "23-x64"
103
+ PYTHONDIR: "C:\\Python36-x64"
104
+ PYTHON: "C:\\Python36-x64\\python.exe"
105
+
106
+ branches:
107
+ only:
108
+ - master
109
+ - /release-.*/
110
+
111
+ notifications:
112
+ - provider: Email
113
+ on_build_success: false
114
+ on_build_failure: false
115
+ on_build_status_changed: false
116
+
117
+ deploy: off
118
+ build: off
119
+
120
+ install:
121
+ - "SET PATH=%PYTHONDIR%;%PYTHONDIR%\\Scripts;%PATH%"
122
+ - "SET PATH=C:\\Ruby%ruby_version%\\bin;%PATH%"
123
+ - "bundle install"
124
+ - "pip install numpy"
125
+
126
+ before_test:
127
+ - "bundle exec rake -rdevkit clobber compile"
128
+ - ECHO "=== python investigator.py ==="
129
+ - "python lib\\pycall\\python\\investigator.py"
130
+
131
+ test_script:
132
+ - "SET PYCALL_DEBUG_FIND_LIBPYTHON=1"
133
+ - rake
134
+
135
+ matrix:
136
+ allow_failures:
137
+ - PYTHONDIR: "C:\\Python27"
138
+ - PYTHONDIR: "C:\\Python27-x64"
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pycall"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
data/bin/guard ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'guard' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("guard", "guard")
data/bin/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/runner ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pycall"
5
+
6
+ load ARGV.shift
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/config/Guardfile ADDED
@@ -0,0 +1,30 @@
1
+ # More info at https://github.com/guard/guard#readme
2
+
3
+ if RUBY_PLATFORM =~ /darwin/
4
+ notification :terminal_notifier, app_name: 'pycall.gem ::', activate: 'com.googlecode.iTerm2'
5
+ end
6
+
7
+ directories %w(config lib spec).select { |d|
8
+ Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")
9
+ }
10
+
11
+ watch('config/Guardfile') do
12
+ UI.info "Exiting guard because config changed"
13
+ exit 0
14
+ end
15
+
16
+ guard :rspec, cmd: 'bin/rspec' do
17
+ require "guard/rspec/dsl"
18
+ dsl = Guard::RSpec::Dsl.new(self)
19
+
20
+ # RSpec files
21
+ rspec = dsl.rspec
22
+ watch(rspec.spec_helper) { rspec.spec_dir }
23
+ watch(rspec.spec_support) { rspec.spec_dir }
24
+ watch(rspec.spec_files)
25
+
26
+ # Ruby files
27
+ ruby = dsl.ruby
28
+ dsl.watch_spec_files_for(ruby.lib_files)
29
+ watch('lib/pycall/libpython.rb') { 'spec' }
30
+ end
data/docker/Dockerfile ADDED
@@ -0,0 +1,191 @@
1
+ FROM buildpack-deps:xenial
2
+ MAINTAINER Kenta Murata mrkn
3
+
4
+ ###############################################################
5
+ # Ruby based on docker-library/ruby
6
+ ###############################################################
7
+
8
+ # skip installing gem documentation
9
+ RUN mkdir -p /usr/local/etc \
10
+ && { \
11
+ echo 'install: --no-document'; \
12
+ echo 'update: --no-document'; \
13
+ } >> /usr/local/etc/gemrc
14
+
15
+ ENV RUBY_MAJOR 2.4
16
+ ENV RUBY_VERSION 2.4.0
17
+ ENV RUBY_DOWNLOAD_SHA256 3a87fef45cba48b9322236be60c455c13fd4220184ce7287600361319bb63690
18
+ ENV RUBYGEMS_VERSION 2.6.10
19
+
20
+ # some of ruby's build scripts are written in ruby
21
+ # we purge system ruby later to make sure our final image uses what we just built
22
+ RUN set -ex \
23
+ \
24
+ && buildDeps=' \
25
+ bison \
26
+ libgdbm-dev \
27
+ ruby \
28
+ ' \
29
+ && apt-get update \
30
+ && apt-get install -y --no-install-recommends $buildDeps \
31
+ && rm -rf /var/lib/apt/lists/* \
32
+ \
33
+ && wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
34
+ && echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
35
+ \
36
+ && mkdir -p /usr/src/ruby \
37
+ && tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
38
+ && rm ruby.tar.xz \
39
+ \
40
+ && cd /usr/src/ruby \
41
+ \
42
+ # hack in "ENABLE_PATH_CHECK" disabling to suppress:
43
+ # warning: Insecure world writable dir
44
+ && { \
45
+ echo '#define ENABLE_PATH_CHECK 0'; \
46
+ echo; \
47
+ cat file.c; \
48
+ } > file.c.new \
49
+ && mv file.c.new file.c \
50
+ \
51
+ && autoconf \
52
+ && ./configure --disable-install-doc --enable-shared \
53
+ && make -j"$(nproc)" \
54
+ && make install \
55
+ \
56
+ && apt-get purge -y --auto-remove $buildDeps \
57
+ && cd / \
58
+ && rm -r /usr/src/ruby \
59
+ \
60
+ && gem update --system "$RUBYGEMS_VERSION"
61
+
62
+ ENV BUNDLER_VERSION 1.14.5
63
+
64
+ RUN gem install bundler --version "$BUNDLER_VERSION"
65
+
66
+ # install things globally, for great justice
67
+ # and don't create ".bundle" in all our apps
68
+ ENV GEM_HOME /usr/local/bundle
69
+ ENV BUNDLE_PATH="$GEM_HOME" \
70
+ BUNDLE_BIN="$GEM_HOME/bin" \
71
+ BUNDLE_SILENCE_ROOT_WARNING=1 \
72
+ BUNDLE_APP_CONFIG="$GEM_HOME"
73
+ ENV PATH $BUNDLE_BIN:$PATH
74
+ RUN mkdir -p "$GEM_HOME" "$BUNDLE_BIN" \
75
+ && chmod 777 "$GEM_HOME" "$BUNDLE_BIN"
76
+
77
+
78
+ ###############################################################
79
+ # Python based on docker-library/python
80
+ ###############################################################
81
+
82
+ # ensure local python is preferred over distribution python
83
+ ENV PATH /usr/local/bin:$PATH
84
+
85
+ # http://bugs.python.org/issue19846
86
+ # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
87
+ ENV LANG C.UTF-8
88
+
89
+ # runtime dependencies
90
+ RUN apt-get update && apt-get install -y --no-install-recommends \
91
+ tcl \
92
+ tk \
93
+ && rm -rf /var/lib/apt/lists/*
94
+
95
+ ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
96
+ ENV PYTHON_VERSION 3.6.0
97
+
98
+ # if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
99
+ ENV PYTHON_PIP_VERSION 9.0.1
100
+
101
+ RUN set -ex \
102
+ && buildDeps=' \
103
+ tcl-dev \
104
+ tk-dev \
105
+ ' \
106
+ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
107
+ \
108
+ && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
109
+ && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
110
+ && export GNUPGHOME="$(mktemp -d)" \
111
+ && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \
112
+ && gpg --batch --verify python.tar.xz.asc python.tar.xz \
113
+ && rm -r "$GNUPGHOME" python.tar.xz.asc \
114
+ && mkdir -p /usr/src/python \
115
+ && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
116
+ && rm python.tar.xz \
117
+ \
118
+ && cd /usr/src/python \
119
+ && ./configure \
120
+ --enable-loadable-sqlite-extensions \
121
+ --enable-shared \
122
+ && make -j$(nproc) \
123
+ && make install \
124
+ && ldconfig \
125
+ \
126
+ # explicit path to "pip3" to ensure distribution-provided "pip3" cannot interfere
127
+ && if [ ! -e /usr/local/bin/pip3 ]; then : \
128
+ && wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
129
+ && python3 /tmp/get-pip.py "pip==$PYTHON_PIP_VERSION" \
130
+ && rm /tmp/get-pip.py \
131
+ ; fi \
132
+ # we use "--force-reinstall" for the case where the version of pip we're trying to install is the same as the version bundled with Python
133
+ # ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
134
+ # https://github.com/docker-library/python/pull/143#issuecomment-241032683
135
+ && pip3 install --no-cache-dir --upgrade --force-reinstall "pip==$PYTHON_PIP_VERSION" \
136
+ # then we use "pip list" to ensure we don't have more than one pip version installed
137
+ # https://github.com/docker-library/python/pull/100
138
+ && [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ] \
139
+ \
140
+ && find /usr/local -depth \
141
+ \( \
142
+ \( -type d -a -name test -o -name tests \) \
143
+ -o \
144
+ \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
145
+ \) -exec rm -rf '{}' + \
146
+ && apt-get purge -y --auto-remove $buildDeps \
147
+ && rm -rf /usr/src/python ~/.cache
148
+
149
+ # make some useful symlinks that are expected to exist
150
+ RUN cd /usr/local/bin \
151
+ && { [ -e easy_install ] || ln -s easy_install-* easy_install; } \
152
+ && ln -s idle3 idle \
153
+ && ln -s pydoc3 pydoc \
154
+ && ln -s python3 python \
155
+ && ln -s python3-config python-config
156
+
157
+ ###############################################################
158
+ # pycall
159
+ ###############################################################
160
+
161
+ RUN apt-get update \
162
+ && apt-get install -y --no-install-recommends libczmq-dev
163
+
164
+ RUN pip3 install jupyter
165
+ RUN pip3 install numpy
166
+ RUN pip3 install scipy
167
+ RUN pip3 install pandas
168
+ RUN pip3 install matplotlib
169
+ RUN pip3 install seaborn
170
+ RUN pip3 install scikit-learn
171
+ RUN pip3 install gensim
172
+ RUN pip3 install nltk
173
+ RUN pip3 install statsmodels
174
+ RUN pip3 install xray
175
+
176
+ RUN mkdir -p /app /notebooks/examples /notebooks/local
177
+ WORKDIR /app
178
+ ADD docker/Gemfile /app
179
+ ADD docker/start.sh /app
180
+
181
+ RUN bundle install
182
+ RUN bundle exec iruby register
183
+
184
+ # Deploy matplotlib's examples
185
+ RUN mkdir -p /tmp \
186
+ && curl -fsSL https://github.com/mrkn/matplotlib.rb/archive/master.tar.gz | tar -xzf - -C /tmp \
187
+ && mv /tmp/matplotlib.rb-master/examples /notebooks/examples/matplotlib \
188
+ && rm -rf /tmp/matplotlib.rb-master
189
+
190
+ CMD sh /app/start.sh
191
+ EXPOSE 8888