pycall 1.0.3 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 254de6af22a7da5928ad1f5233727a7ac378c84c
4
- data.tar.gz: fc897d3873076f610b527fb23841c4044793e317
2
+ SHA256:
3
+ metadata.gz: ba0b7938e482d87e6a6eb540b92b2e581974fc6e894e674c7da00b4b68807b15
4
+ data.tar.gz: ad5ce0352f59744abf9193e69cf33719f9314aad45e9c24fd6584fe73873330e
5
5
  SHA512:
6
- metadata.gz: 32b60a4408b80fd5df671b8c1c9177d5973ff9fff11603ea0f4dd9407dbb27e39532f7d269cd7d5805e0e275ab2e5e9e956a247100160ecc091028b9757828df
7
- data.tar.gz: 79d9c857888a3577f76428247bc73e999df73cbbac3269d39c86765d2b6656f32ca916caf54fe955921842a9119141e60b53d1a16973de63cf1a154b08715f27
6
+ metadata.gz: cc2eb8963c91d69086eccab17cb06ebea072908f77f3e4f85a23f328f858f7cda29ebec70c519fa70f3fc88eaf5e37b61b88136515f2326e0c239467a522067b
7
+ data.tar.gz: cfb14589abee3741fcec45f31d8d94dc076341ae425ee0302e50628e6ffafdfff665a6e90c67a80ce10df6a8866282bc221ecddf198d0049ee85d1055bb50255
@@ -0,0 +1,67 @@
1
+ name: CI
2
+
3
+ on:
4
+ - push
5
+
6
+ jobs:
7
+ test:
8
+ name: Test
9
+ runs-on: ${{ matrix.os }}
10
+
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os:
15
+ - ubuntu-18.04
16
+ - macos-latest
17
+ ruby_version:
18
+ - 2.7.x
19
+ - 2.6.x
20
+ - 2.5.x
21
+ - 2.4.x
22
+ python_version:
23
+ - 3.8.x
24
+ - 3.7.x
25
+ - 3.6.x
26
+ - 2.7.x
27
+ python_architecture:
28
+ - x64
29
+
30
+ steps:
31
+ - name: Setup Ruby
32
+ if: matrix.ruby_version != 'master-nightly'
33
+ uses: actions/setup-ruby@v1
34
+ with:
35
+ ruby-version: ${{ matrix.ruby_version }}
36
+
37
+ - name: Setup Python
38
+ uses: actions/setup-python@v1
39
+ with:
40
+ python-version: ${{ matrix.python_version }}
41
+ architecture: ${{ matrix.python_architecture }}
42
+
43
+ - name: Checkout
44
+ uses: actions/checkout@v1
45
+ with:
46
+ fetch-depth: 1
47
+
48
+ - name: Prepare environment
49
+ run: |
50
+ gem install bundler
51
+
52
+ - name: Install requirements
53
+ run: |
54
+ pip install --user numpy
55
+ bundle install
56
+
57
+ - name: Compile pycall.so
58
+ run: |
59
+ bundle exec rake compile
60
+
61
+ - name: Python investigator
62
+ run: |
63
+ python lib/pycall/python/investigator.py
64
+
65
+ - name: Test
66
+ run: |
67
+ PYTHON=python bundle exec rake
data/.travis.yml CHANGED
@@ -2,49 +2,74 @@ language: ruby
2
2
 
3
3
  os: linux
4
4
 
5
- dist: trusty
5
+ dist: bionic
6
6
  sudo: required
7
7
 
8
8
  rvm:
9
9
  - ruby-head
10
- - 2.4.2
11
- - 2.3.5
12
- - 2.2.8
13
- - 2.1.10
10
+ - 2.7
11
+ - 2.6
12
+ - 2.5
13
+ - 2.4
14
14
 
15
15
  env:
16
16
  global:
17
17
  - PYCALL_DEBUG_FIND_LIBPYTHON=1
18
18
  matrix:
19
- - PYENV_VERSION=2.7.13
20
- - PYENV_VERSION=3.6.2
21
- - PYENV_VERSION=system LIBPYTHON=versions/3.6.2/lib/libpython3.6m.so
22
- - PYENV_VERSION=miniconda2-4.1.11
23
- - PYENV_VERSION=miniconda3-4.3.11
19
+ - PYENV_VERSION=3.8.0
20
+ - PYENV_VERSION=3.7.5
21
+ - PYENV_VERSION=2.7.17
22
+ - PYENV_VERSION=system LIBPYTHON=/usr/lib/x86_64-linux-gnu/libpython3.6m.so
23
+ - PYENV_VERSION=system LIBPYTHON=/usr/lib/x86_64-linux-gnu/libpython2.7.so
24
+ - PYENV_VERSION=miniconda2-4.3.30
25
+ - PYENV_VERSION=miniconda3-4.3.30
24
26
 
25
27
  matrix:
26
28
  include:
27
29
  - os: osx
28
- osx_image: xcode9
30
+ osx_image: xcode11.2
29
31
  compiler: clang
30
- rvm: 2.4.1
31
- env: PYENV_VERSION=3.6.2
32
+ rvm: 2.7
33
+ env: PYENV_VERSION=3.8.0
32
34
  - os: osx
33
- osx_image: xcode9
35
+ osx_image: xcode11.2
34
36
  compiler: clang
35
- rvm: 2.4.1
36
- env: PYENV_VERSION=system LIBPYTHON=versions/3.6.2/lib/libpython3.6m.so
37
+ rvm: 2.6
38
+ env: PYENV_VERSION=3.8.0
37
39
  - os: osx
38
- osx_image: xcode9
40
+ osx_image: xcode11.2
39
41
  compiler: clang
40
- rvm: 2.4.1
42
+ rvm: 2.5
43
+ env: PYENV_VERSION=3.8.0
44
+ - os: osx
45
+ osx_image: xcode11.2
46
+ compiler: clang
47
+ rvm: 2.4
48
+ env: PYENV_VERSION=3.8.0
49
+ - os: osx
50
+ osx_image: xcode11.2
51
+ compiler: clang
52
+ rvm: 2.7
53
+ env: PYENV_VERSION=miniconda3-4.3.11
54
+ - os: osx
55
+ osx_image: xcode11.2
56
+ compiler: clang
57
+ rvm: 2.6
58
+ env: PYENV_VERSION=miniconda3-4.3.11
59
+ - os: osx
60
+ osx_image: xcode11.2
61
+ compiler: clang
62
+ rvm: 2.5
63
+ env: PYENV_VERSION=miniconda3-4.3.11
64
+ - os: osx
65
+ osx_image: xcode11.2
66
+ compiler: clang
67
+ rvm: 2.4
41
68
  env: PYENV_VERSION=miniconda3-4.3.11
42
- allow_failure:
69
+ allow_failures:
43
70
  - os: osx
44
71
 
45
72
  before_install:
46
- - gem update --system
47
- - gem update bundler
48
73
  - export PATH="$(pyenv root)/bin:$PATH"
49
74
  - eval "$(pyenv init -)"
50
75
 
data/CHANGES.md CHANGED
@@ -1,5 +1,67 @@
1
1
  # The change history of PyCall
2
2
 
3
+ ## 1.3.1
4
+
5
+ * Stop using `&proc` idiom to prevent warnings
6
+
7
+ *Kenta Murata*
8
+
9
+ ## 1.3.0
10
+
11
+ * Add `PyCall.without_gvl` for explicitly releasing the RubyVM GVL
12
+
13
+ * Fix for missing if in PyObjectWrapper
14
+
15
+ *Kouhei Sutou*
16
+
17
+ * Fix for Anaconda environment
18
+
19
+ *Ryo MATSUMIYA*
20
+
21
+ * Fix against `unknown symbol "PyInt_AsSsize_t"` (Fiddle::DLError)
22
+
23
+ *Kouhei Sutou*
24
+
25
+ * Fix for `TypeError: Compared with non class/module`
26
+
27
+ *Archonic*
28
+
29
+ ## 1.2.1
30
+
31
+ * Prevent circular require in pycall/iruby.rb
32
+
33
+ ## 1.2.0
34
+
35
+ * Add `PyCall::Tuple#to_ary`
36
+
37
+ *Naoto Takai*
38
+
39
+ * Release GVL while the Python interpreter is running
40
+
41
+ * Drop support Ruby 2.2.x and 2.1.x
42
+
43
+ * Release GVL while the Python interpreter is running [Fix #45]
44
+
45
+ * Add public header file
46
+
47
+ * Use PyPtr.none? instead of removed PyCall.none?
48
+
49
+ *Kouhei Sutou*
50
+
51
+ * Export PyObject convert functions
52
+
53
+ *Kouhei Sutou*
54
+
55
+ * Support multiple candidates of Python command in `PyCall.init`
56
+
57
+ * Now, `PyCall.init` tries `python3` command before `python` in default
58
+
59
+ * Drop Ruby 2.2 and 2.1 supports
60
+
61
+ * Add `PyCall::PyTypeObjectWrapper#<` as `Class#<`
62
+
63
+ * Support class inheritance in python type mapping
64
+
3
65
  ## 1.0.3
4
66
 
5
67
  * Fix anaconda support to define the environment variable `PYTHONHOME`.
data/README.md CHANGED
@@ -1,13 +1,38 @@
1
+ <a name="logo"/>
2
+ <div align="center">
3
+ <img src="./images/pycallrb_logo_200.png" alt="pycall.rb logo" width="200" height="200"></img>
4
+ </div>
5
+
1
6
  # PyCall: Calling Python functions from the Ruby language
2
7
 
3
- [![Build Status](https://travis-ci.org/mrkn/pycall.rb.svg?branch=1.0)](https://travis-ci.org/mrkn/pycall.rb)
4
- [![Build status](https://ci.appveyor.com/api/projects/status/naw56ldru71w7qsw/branch/1.0?svg=true)](https://ci.appveyor.com/project/mrkn/pycall-rb/branch/1.0)
8
+ [![Build Status](https://github.com/mrkn/pycall.rb/workflows/CI/badge.svg)](https://github.com/mrkn/pycall.rb/actions?query=workflow%3ACI)
9
+ [![Build Status](https://travis-ci.org/mrkn/pycall.rb.svg?branch=master)](https://travis-ci.org/mrkn/pycall.rb)
10
+ [![Build status](https://ci.appveyor.com/api/projects/status/0fad23u4qj1yr49e/branch/master?svg=true)](https://ci.appveyor.com/project/mrkn/pycall-rb/branch/master)
5
11
 
6
12
  This library provides the features to directly call and partially interoperate
7
13
  with Python from the Ruby language. You can import arbitrary Python modules
8
14
  into Ruby modules, call Python functions with automatic type conversion from
9
15
  Ruby to Python.
10
16
 
17
+ ## Supported Ruby versions
18
+
19
+ pycall.rb supports Ruby version 2.3 or higher.
20
+
21
+ ## Supported Python versions
22
+
23
+ pycall.rb supports Python version 2.7 or higher.
24
+
25
+ Note that in Python 2.7 old-style class, that is defined without a super class, is not fully supported in pycall.rb.
26
+
27
+ ## Note for pyenv users
28
+
29
+ pycall.rb requires Python's shared library (e.g. `libpython3.7m.so`).
30
+ pyenv does not build the shared library in default, so you need to specify `--enable-shared` option at the installation like below:
31
+
32
+ ```
33
+ $ env PYTHON_CONFIGURE_OPTS='--enable-shared' pyenv install 3.7.2
34
+ ```
35
+
11
36
  ## Installation
12
37
 
13
38
  Add this line to your application's Gemfile:
@@ -37,6 +62,45 @@ the `Math.sin` in Ruby:
37
62
  Type conversions from Ruby to Python are automatically performed for numeric,
38
63
  boolean, string, arrays, and hashes.
39
64
 
65
+ ### Releasing the RubyVM GVL during Python function calls
66
+
67
+ You may want to release the RubyVM GVL when you call a Python function that takes very long runtime.
68
+ PyCall provides `PyCall.without_gvl` method for such purpose. When PyCall performs python function call,
69
+ PyCall checks the current context, and then it releases the RubyVM GVL when the current context is in a `PyCall.without_gvl`'s block.
70
+
71
+ ```ruby
72
+ PyCall.without_gvl do
73
+ # In this block, all Python function calls are performed without
74
+ # the GVL acquisition.
75
+ pyobj.long_running_function()
76
+ end
77
+
78
+ # Outside of PyCall.without_gvl block,
79
+ # all Python function calls are performed with the GVL acquisition.
80
+ pyobj.long_running_function()
81
+ ```
82
+
83
+ ### Debugging python finder
84
+
85
+ When you encounter `PyCall::PythonNotFound` error, you can investigate PyCall's python finder by setting `PYCALL_DEBUG_FIND_LIBPYTHON` environment variable to `1`. You can see the log like below:
86
+
87
+ ```
88
+ $ PYCALL_DEBUG_FIND_LIBPYTHON=1 ruby -rpycall -ePyCall.builtins
89
+ DEBUG(find_libpython) find_libpython(nil)
90
+ DEBUG(find_libpython) investigate_python_config("python3")
91
+ DEBUG(find_libpython) libs: ["Python.framework/Versions/3.7/Python", "Python", "libpython3.7m", "libpython3.7", "libpython"]
92
+ DEBUG(find_libpython) libpaths: ["/opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/lib", "/opt/brew/opt/python/lib", "/opt/brew/opt/python/Frameworks", "/opt/brew/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7", "/opt/brew/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib"]
93
+ DEBUG(find_libpython) Unable to find /opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/lib/Python.framework/Versions/3.7/Python
94
+ DEBUG(find_libpython) Unable to find /opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/lib/Python.framework/Versions/3.7/Python.dylib
95
+ DEBUG(find_libpython) Unable to find /opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/lib/darwin/Python.framework/Versions/3.7/Python
96
+ DEBUG(find_libpython) Unable to find /opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/lib/darwin/Python.framework/Versions/3.7/Python.dylib
97
+ DEBUG(find_libpython) Unable to find /opt/brew/opt/python/lib/Python.framework/Versions/3.7/Python
98
+ DEBUG(find_libpython) Unable to find /opt/brew/opt/python/lib/Python.framework/Versions/3.7/Python.dylib
99
+ DEBUG(find_libpython) Unable to find /opt/brew/opt/python/lib/darwin/Python.framework/Versions/3.7/Python
100
+ DEBUG(find_libpython) Unable to find /opt/brew/opt/python/lib/darwin/Python.framework/Versions/3.7/Python.dylib
101
+ DEBUG(find_libpython) dlopen("/opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/Python") = #<Fiddle::Handle:0x00007fc012048650>
102
+ ```
103
+
40
104
  ## PyCall object system
41
105
 
42
106
  PyCall wraps pointers of Python objects in `PyCall::PyPtr` objects.
data/Rakefile CHANGED
@@ -17,6 +17,8 @@ Rake::ExtensionTask.new('pycall', gem_spec) do |ext|
17
17
  end
18
18
  end
19
19
 
20
+ Rake::ExtensionTask.new('pycall/spec_helper')
21
+
20
22
  desc "Compile binaries for mingw platform using rake-compiler-dock"
21
23
  task 'build:mingw' do
22
24
  require 'rake_compiler_dock'
data/appveyor.yml CHANGED
@@ -1,71 +1,29 @@
1
1
  ---
2
2
  environment:
3
3
  matrix:
4
- # Ruby 2.1 (32bit)
5
- - ruby_version: "21"
4
+ # Ruby 2.4 (32bit)
5
+ - ruby_version: "24"
6
6
  PYTHONDIR: "C:\\Python27"
7
7
  PYTHON: "C:\\Python27\\python.exe"
8
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"
9
+ - ruby_version: "24"
48
10
  PYTHONDIR: "C:\\Python35"
49
11
  PYTHON: "C:\\Python35\\python.exe"
50
12
 
51
- - ruby_version: "22"
13
+ - ruby_version: "24"
52
14
  PYTHONDIR: "C:\\Python36"
53
15
  PYTHON: "C:\\Python36\\python.exe"
54
16
 
55
- # Ruby 2.2 (64bit)
56
- - ruby_version: "22-x64"
17
+ # Ruby 2.4 (64bit)
18
+ - ruby_version: "24-x64"
57
19
  PYTHONDIR: "C:\\Python27-x64"
58
20
  PYTHON: "C:\\Python27-x64\\python.exe"
59
21
 
60
- - ruby_version: "22-x64"
61
- PYTHONDIR: "C:\\Python34-x64"
62
- PYTHON: "C:\\Python34-x64\\python.exe"
63
-
64
- - ruby_version: "22-x64"
22
+ - ruby_version: "24-x64"
65
23
  PYTHONDIR: "C:\\Python35-x64"
66
24
  PYTHON: "C:\\Python35-x64\\python.exe"
67
25
 
68
- - ruby_version: "22-x64"
26
+ - ruby_version: "24-x64"
69
27
  PYTHONDIR: "C:\\Python36-x64"
70
28
  PYTHON: "C:\\Python36-x64\\python.exe"
71
29
 
@@ -91,10 +49,6 @@ environment:
91
49
  PYTHONDIR: "C:\\Python27-x64"
92
50
  PYTHON: "C:\\Python27-x64\\python.exe"
93
51
 
94
- - ruby_version: "23-x64"
95
- PYTHONDIR: "C:\\Python34-x64"
96
- PYTHON: "C:\\Python34-x64\\python.exe"
97
-
98
52
  - ruby_version: "23-x64"
99
53
  PYTHONDIR: "C:\\Python35-x64"
100
54
  PYTHON: "C:\\Python35-x64\\python.exe"
data/ci/travis_install.sh CHANGED
@@ -10,19 +10,35 @@ if test -z "$PYENV_VERSION"; then
10
10
  exit 1
11
11
  fi
12
12
 
13
+ pyenv_root=$(pyenv root)
14
+
13
15
  if test -n "$LIBPYTHON"; then
14
- export LIBPYTHON=$(pyenv root)/$LIBPYTHON
16
+ if test ! -f $LIBPYTHON; then
17
+ if test -f ${pyenv_root}/$LIBPYTHON; then
18
+ export LIBPYTHON=${pyenv_root}/$LIBPYTHON
19
+ else
20
+ echo "Invalid value in LIBPYTHON: ${LIBPYTHON}" >&2
21
+ exit 1
22
+ fi
23
+ fi
15
24
  fi
16
25
 
17
- if test "$PYENV_VERSION" = "system"; then
18
- if test -z "$LIBPYTHON"; then
19
- echo "ERROR: LIBPYTHON is not provided for PYENV_VERSION=system" >2
20
- exit 1
26
+ (
27
+ cd $(pyenv root)
28
+ if [ -d .git ]; then
29
+ git fetch origin
30
+ git checkout master
31
+ git reset --hard origin/master
21
32
  fi
22
- # NOTE: PYENV_VERSION should be the version of LIBPYTHON during install script
23
- PYENV_VERSION=$(basename $(dirname $(dirname $LIBPYTHON)))
24
- fi
25
- PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -f $PYENV_VERSION
33
+ )
34
+
35
+ case $PYENV_VERSION in
36
+ system)
37
+ ;;
38
+ *)
39
+ PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -f $PYENV_VERSION
40
+ ;;
41
+ esac
26
42
 
27
43
  case "$PYENV_VERSION" in
28
44
  *conda*)
@@ -40,6 +56,11 @@ case "$PYENV_VERSION" in
40
56
  travis_retry conda create -q -n test-environment python=$python_version numpy
41
57
  source $(pyenv prefix)/bin/activate test-environment
42
58
  ;;
59
+ system)
60
+ travis_retry pip install --user numpy
61
+ sudo sh -c "apt-get update && apt-get install --no-install-recommends -y python3-pip"
62
+ travis_retry python3.6 -m pip install --user numpy
63
+ ;;
43
64
  *)
44
65
  travis_retry pip install --user numpy
45
66
  ;;