pycall 1.0.2 → 1.0.3

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
2
  SHA1:
3
- metadata.gz: fc7457af2e316e61b4e58a0a11075914fad55c34
4
- data.tar.gz: 17adfb758a2822733fdeb79ff2d2bc261d6230af
3
+ metadata.gz: 254de6af22a7da5928ad1f5233727a7ac378c84c
4
+ data.tar.gz: fc897d3873076f610b527fb23841c4044793e317
5
5
  SHA512:
6
- metadata.gz: 5e309b2814a7ed985e6d3f4c763cbc68f3a354d1beebb1330230825085351a823cae292875bb41984ae308e8d668c83f11e064bb863f9e5e82bb7a3feaad247b
7
- data.tar.gz: 0ce1b87b5df41852c11995b794921a929f30a710f53641cdec4b2ed626689493c302e66d359eacfcf66addd062605c5538b5eceb1603c05164d999a1dd9b2895
6
+ metadata.gz: 32b60a4408b80fd5df671b8c1c9177d5973ff9fff11603ea0f4dd9407dbb27e39532f7d269cd7d5805e0e275ab2e5e9e956a247100160ecc091028b9757828df
7
+ data.tar.gz: 79d9c857888a3577f76428247bc73e999df73cbbac3269d39c86765d2b6656f32ca916caf54fe955921842a9119141e60b53d1a16973de63cf1a154b08715f27
data/.gitignore CHANGED
@@ -7,7 +7,10 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- __pycache__
10
+
11
+ __pycache__/
12
+ .ipynb_checkpoints/
11
13
  *.bundle
12
14
  *.so
13
15
  *.o
16
+ *.pyc
@@ -1,41 +1,57 @@
1
- sudo: false
2
1
  language: ruby
3
2
 
3
+ os: linux
4
+
5
+ dist: trusty
6
+ sudo: required
7
+
4
8
  rvm:
5
- - ruby-head
6
- - 2.4.0
7
- - 2.3.1
8
- - 2.2.5
9
- - 2.1.10
9
+ - ruby-head
10
+ - 2.4.2
11
+ - 2.3.5
12
+ - 2.2.8
13
+ - 2.1.10
10
14
 
11
15
  env:
12
16
  global:
13
17
  - PYCALL_DEBUG_FIND_LIBPYTHON=1
14
18
  matrix:
15
- - PYTHON=python PYENV_VERSION=system
16
- - PYTHON=python3 PYENV_VERSION=3.5.3 LIBPYTHON=wrong_value
17
- - PYENV_VERSION=3.5.3 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
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
24
+
25
+ matrix:
26
+ include:
27
+ - os: osx
28
+ osx_image: xcode9
29
+ compiler: clang
30
+ rvm: 2.4.1
31
+ env: PYENV_VERSION=3.6.2
32
+ - os: osx
33
+ osx_image: xcode9
34
+ compiler: clang
35
+ rvm: 2.4.1
36
+ env: PYENV_VERSION=system LIBPYTHON=versions/3.6.2/lib/libpython3.6m.so
37
+ - os: osx
38
+ osx_image: xcode9
39
+ compiler: clang
40
+ rvm: 2.4.1
41
+ env: PYENV_VERSION=miniconda3-4.3.11
42
+ allow_failure:
43
+ - os: osx
26
44
 
27
45
  before_install:
28
- - gem update --system
29
- - gem update bundler
46
+ - gem update --system
47
+ - gem update bundler
48
+ - export PATH="$(pyenv root)/bin:$PATH"
49
+ - eval "$(pyenv init -)"
30
50
 
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
- - travis_retry pip install --user numpy
37
- - PYENV_VERSION=3.5.3 travis_retry pip3 install --user numpy
51
+ install:
52
+ - ci/travis_install.sh
38
53
 
39
- matrix:
40
- allow_failures:
41
- - env: PYTHON=python # Ignore failed on python 2.7
54
+ before_script:
55
+ - . ci/travis_before_script.sh
56
+ - bundle exec rake clobber compile
57
+ - python lib/pycall/python/investigator.py
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # The change history of PyCall
2
2
 
3
+ ## 1.0.3
4
+
5
+ * Fix anaconda support to define the environment variable `PYTHONHOME`.
6
+ https://github.com/mrkn/pycall.rb/issues/37
7
+
3
8
  ## 1.0.2
4
9
 
5
10
  * Fix the bug that a large Python string is broken when it converted to Ruby string
@@ -0,0 +1,21 @@
1
+ __DIR__=$(cd $(dirname $BASH_SOURCE); pwd)
2
+ . $__DIR__/travis_retry.sh
3
+
4
+ set -ex
5
+
6
+ if test -z "$PYENV_VERSION"; then
7
+ echo "ERROR: PYENV_VERSION is not provided" >2
8
+ exit 1
9
+ fi
10
+
11
+ if test -n "$LIBPYTHON"; then
12
+ export LIBPYTHON=$(pyenv root)/$LIBPYTHON
13
+ fi
14
+
15
+ case "$PYENV_VERSION" in
16
+ *conda*)
17
+ source $(pyenv prefix)/bin/activate test-environment
18
+ ;;
19
+ esac
20
+
21
+ set +ex
@@ -0,0 +1,48 @@
1
+ #! /bin/bash
2
+
3
+ __DIR__=$(cd $(dirname $BASH_SOURCE); pwd)
4
+ . $__DIR__/travis_retry.sh
5
+
6
+ set -ex
7
+
8
+ if test -z "$PYENV_VERSION"; then
9
+ echo "ERROR: PYENV_VERSION is not provided" >2
10
+ exit 1
11
+ fi
12
+
13
+ if test -n "$LIBPYTHON"; then
14
+ export LIBPYTHON=$(pyenv root)/$LIBPYTHON
15
+ fi
16
+
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
21
+ 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
26
+
27
+ case "$PYENV_VERSION" in
28
+ *conda*)
29
+ case "$PYENV_VERSION" in
30
+ *conda2*)
31
+ python_version=2.7
32
+ ;;
33
+ *)
34
+ python_version=3.6
35
+ ;;
36
+ esac
37
+ conda config --set always_yes yes --set changeps1 no
38
+ travis_retry conda update -q conda
39
+ conda info -a
40
+ travis_retry conda create -q -n test-environment python=$python_version numpy
41
+ source $(pyenv prefix)/bin/activate test-environment
42
+ ;;
43
+ *)
44
+ travis_retry pip install --user numpy
45
+ ;;
46
+ esac
47
+
48
+ bundle install
@@ -0,0 +1,19 @@
1
+ travis_retry ()
2
+ {
3
+ local result=0
4
+ local count=1
5
+ while [ $count -le 3 ]; do
6
+ [ $result -ne 0 ] && {
7
+ echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" 1>&2
8
+ }
9
+ "$@"
10
+ result=$?
11
+ [ $result -eq 0 ] && break
12
+ count=$(($count + 1))
13
+ sleep 1
14
+ done
15
+ [ $count -gt 3 ] && {
16
+ echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" 1>&2
17
+ }
18
+ return $result
19
+ }
@@ -39,6 +39,7 @@ module PyCall
39
39
  end
40
40
  end
41
41
 
42
+ set_PYTHONHOME(python_config)
42
43
  libs = make_libs(python_config)
43
44
  libpaths = make_libpaths(python_config)
44
45
 
@@ -101,6 +102,10 @@ module PyCall
101
102
  {}.tap do |config|
102
103
  io.each_line do |line|
103
104
  key, value = line.chomp.split(': ', 2)
105
+ case value
106
+ when 'True', 'true', 'False', 'false'
107
+ value = (value == 'True' || value == 'true')
108
+ end
104
109
  config[key.to_sym] = value if value != 'None'
105
110
  end
106
111
  end
@@ -113,6 +118,17 @@ module PyCall
113
118
  File.expand_path('../../python/investigator.py', __FILE__)
114
119
  end
115
120
 
121
+ def set_PYTHONHOME(python_config)
122
+ if !ENV.has_key?('PYTHONHOME') && python_config[:conda]
123
+ case RUBY_PLATFORM
124
+ when /mingw32/, /cygwin/, /mswin/
125
+ ENV['PYTHONHOME'] = python_config[:exec_prefix]
126
+ else
127
+ ENV['PYTHONHOME'] = python_config.values_at(:prefix, :exec_prefix).join(':')
128
+ end
129
+ end
130
+ end
131
+
116
132
  def make_libs(python_config)
117
133
  libs = []
118
134
  %i(INSTSONAME LDLIBRARY).each do |key|
@@ -1,7 +1,12 @@
1
1
  from distutils.sysconfig import get_config_var
2
2
  import sys
3
+
4
+ def conda():
5
+ return 'conda' in sys.version or 'Continuum' in sys.version
6
+
3
7
  for var in ('executable', 'exec_prefix', 'prefix'):
4
8
  print(var + ': ' + str(getattr(sys, var)))
9
+ print('conda: ' + ('true' if conda() else 'false'))
5
10
  print('multiarch: ' + str(getattr(getattr(sys, 'implementation', sys), '_multiarch', None)))
6
11
  for var in ('VERSION', 'INSTSONAME', 'LIBRARY', 'LDLIBRARY', 'LIBDIR', 'PYTHONFRAMEWORKPREFIX', 'MULTIARCH'):
7
12
  print(var + ': ' + str(get_config_var(var)))
@@ -1,3 +1,3 @@
1
1
  module PyCall
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pycall
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Murata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-15 00:00:00.000000000 Z
11
+ date: 2017-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -144,6 +144,9 @@ files:
144
144
  - bin/rspec
145
145
  - bin/runner
146
146
  - bin/setup
147
+ - ci/travis_before_script.sh
148
+ - ci/travis_install.sh
149
+ - ci/travis_retry.sh
147
150
  - config/Guardfile
148
151
  - docker/Dockerfile
149
152
  - docker/Gemfile