pycall 1.0.1-x64-mingw32 → 1.0.2-x64-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +5 -5
- data/CHANGES.md +5 -0
- data/README.md +3 -3
- data/ext/pycall/pycall.c +36 -10
- data/ext/pycall/pycall_internal.h +1 -0
- data/lib/pycall.rb +2 -0
- data/lib/pycall/iruby_helper.rb +17 -19
- data/lib/pycall/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: '089189762ae2cbdb8d8f7d5d472f3f5e8b8b7620'
         | 
| 4 | 
            +
              data.tar.gz: 3340df4342ea9a2938699d862bc04f17c7cd6259
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 33a6396abff3be597d56630663635100b034a17ed28326b6d8cd136f9d9bb9edfe0e9dec3ecf67af6dd7b5079e035e94ca5cd5eaff7678e1fe662f01da9ab5be
         | 
| 7 | 
            +
              data.tar.gz: dd4a2ca053b6b992bc25665f4b90d728e98869c9543932e8874289ecf7f739ddec58aa9649760ebfdfedfdb58aaf59f5558e667306d60d2aa4f202a50daab4cd
         | 
    
        data/.travis.yml
    CHANGED
    
    | @@ -12,9 +12,9 @@ env: | |
| 12 12 | 
             
              global:
         | 
| 13 13 | 
             
              - PYCALL_DEBUG_FIND_LIBPYTHON=1
         | 
| 14 14 | 
             
              matrix:
         | 
| 15 | 
            -
              - PYTHON=python
         | 
| 16 | 
            -
              - PYTHON=python3 LIBPYTHON=wrong_value
         | 
| 17 | 
            -
              - LIBPYTHON=/opt/python/3.5.3/lib/libpython3.5m.so
         | 
| 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 18 |  | 
| 19 19 | 
             
            addons:
         | 
| 20 20 | 
             
              apt:
         | 
| @@ -33,8 +33,8 @@ before_script: | |
| 33 33 | 
             
              - echo === python investigator.py ===
         | 
| 34 34 | 
             
              - python lib/pycall/python/investigator.py
         | 
| 35 35 | 
             
              - python3 lib/pycall/python/investigator.py
         | 
| 36 | 
            -
              - pip install numpy
         | 
| 37 | 
            -
              - pip3 install numpy
         | 
| 36 | 
            +
              - travis_retry pip install --user numpy
         | 
| 37 | 
            +
              - PYENV_VERSION=3.5.3 travis_retry pip3 install --user numpy
         | 
| 38 38 |  | 
| 39 39 | 
             
            matrix:
         | 
| 40 40 | 
             
              allow_failures:
         | 
    
        data/CHANGES.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            # PyCall: Calling Python functions from the Ruby language
         | 
| 2 2 |  | 
| 3 | 
            -
            [](https://travis-ci.org/mrkn/pycall.rb)
         | 
| 4 | 
            +
            [](https://ci.appveyor.com/project/mrkn/pycall-rb/branch/1.0)
         | 
| 5 5 |  | 
| 6 6 | 
             
            This library provides the features to directly call and partially interoperate
         | 
| 7 7 | 
             
            with Python from the Ruby language.  You can import arbitrary Python modules
         | 
| @@ -77,7 +77,7 @@ version, push git commits and tags, and push the `.gem` file to | |
| 77 77 | 
             
            ## Contributing
         | 
| 78 78 |  | 
| 79 79 | 
             
            Bug reports and pull requests are welcome on GitHub at
         | 
| 80 | 
            -
            https://github.com/mrkn/pycall.
         | 
| 80 | 
            +
            https://github.com/mrkn/pycall.rb.
         | 
| 81 81 |  | 
| 82 82 |  | 
| 83 83 | 
             
            ## Acknowledgement
         | 
    
        data/ext/pycall/pycall.c
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            #include "pycall_internal.h"
         | 
| 2 | 
            +
            #include <ruby/encoding.h>
         | 
| 2 3 |  | 
| 3 4 | 
             
            #include <stdarg.h>
         | 
| 4 5 |  | 
| @@ -1317,7 +1318,10 @@ pycall_pyobject_to_ruby(PyObject *pyobj) | |
| 1317 1318 | 
             
              if (pyobj->ob_type == Py_API(PyLong_Type))
         | 
| 1318 1319 | 
             
                return pycall_pylong_to_ruby(pyobj);
         | 
| 1319 1320 |  | 
| 1320 | 
            -
              if (pyobj->ob_type == Py_API(PyUnicode_Type) | 
| 1321 | 
            +
              if (pyobj->ob_type == Py_API(PyUnicode_Type))
         | 
| 1322 | 
            +
                return pycall_pyunicode_to_ruby(pyobj);
         | 
| 1323 | 
            +
             | 
| 1324 | 
            +
              if (pyobj->ob_type == Py_API(PyString_Type))
         | 
| 1321 1325 | 
             
                return pycall_pystring_to_ruby(pyobj);
         | 
| 1322 1326 |  | 
| 1323 1327 | 
             
              Py_API(Py_IncRef)(pyobj);
         | 
| @@ -1469,24 +1473,46 @@ pycall_pystring_to_ruby(PyObject *pyobj) | |
| 1469 1473 | 
             
            {
         | 
| 1470 1474 | 
             
              char *str = NULL;
         | 
| 1471 1475 | 
             
              Py_ssize_t len = 0;
         | 
| 1472 | 
            -
              int res | 
| 1476 | 
            +
              int res;
         | 
| 1477 | 
            +
             | 
| 1478 | 
            +
              /* TODO: PyString_Check */
         | 
| 1479 | 
            +
              if (pyobj->ob_type != Py_API(PyString_Type)) {
         | 
| 1480 | 
            +
                return Qnil;
         | 
| 1481 | 
            +
              }
         | 
| 1482 | 
            +
             | 
| 1483 | 
            +
              res = Py_API(PyString_AsStringAndSize)(pyobj, &str, &len);
         | 
| 1484 | 
            +
              if (res < 0) {
         | 
| 1485 | 
            +
                return Qnil;
         | 
| 1486 | 
            +
              }
         | 
| 1487 | 
            +
             | 
| 1488 | 
            +
              return rb_enc_str_new(str, len, rb_enc_from_index(rb_ascii8bit_encindex()));
         | 
| 1489 | 
            +
            }
         | 
| 1490 | 
            +
             | 
| 1491 | 
            +
            VALUE
         | 
| 1492 | 
            +
            pycall_pyunicode_to_ruby(PyObject *pyobj)
         | 
| 1493 | 
            +
            {
         | 
| 1494 | 
            +
              char *str = NULL;
         | 
| 1495 | 
            +
              Py_ssize_t len = 0;
         | 
| 1496 | 
            +
              int res;
         | 
| 1473 1497 |  | 
| 1474 1498 | 
             
              /* TODO: PyUnicode_Check */
         | 
| 1475 | 
            -
              if (pyobj->ob_type  | 
| 1476 | 
            -
                 | 
| 1477 | 
            -
                res = Py_API(PyString_AsStringAndSize)(pyobj, &str, &len);
         | 
| 1478 | 
            -
                pycall_Py_DecRef(pyobj);
         | 
| 1499 | 
            +
              if (pyobj->ob_type != Py_API(PyUnicode_Type)) {
         | 
| 1500 | 
            +
                return Qnil;
         | 
| 1479 1501 | 
             
              }
         | 
| 1480 | 
            -
             | 
| 1481 | 
            -
               | 
| 1482 | 
            -
             | 
| 1502 | 
            +
             | 
| 1503 | 
            +
              pyobj = Py_API(PyUnicode_AsUTF8String)(pyobj);
         | 
| 1504 | 
            +
              if (!pyobj) {
         | 
| 1505 | 
            +
                Py_API(PyErr_Clear)();
         | 
| 1506 | 
            +
                return Qnil;
         | 
| 1483 1507 | 
             
              }
         | 
| 1484 1508 |  | 
| 1509 | 
            +
              res = Py_API(PyString_AsStringAndSize)(pyobj, &str, &len);
         | 
| 1485 1510 | 
             
              if (res < 0) {
         | 
| 1511 | 
            +
                pycall_Py_DecRef(pyobj);
         | 
| 1486 1512 | 
             
                return Qnil;
         | 
| 1487 1513 | 
             
              }
         | 
| 1488 1514 |  | 
| 1489 | 
            -
              return  | 
| 1515 | 
            +
              return rb_enc_str_new(str, len, rb_enc_from_index(rb_utf8_encindex()));
         | 
| 1490 1516 | 
             
            }
         | 
| 1491 1517 |  | 
| 1492 1518 | 
             
            static VALUE
         | 
| @@ -646,6 +646,7 @@ VALUE pycall_pyfloat_to_ruby(PyObject *); | |
| 646 646 | 
             
            VALUE pycall_pyint_to_ruby(PyObject *);
         | 
| 647 647 | 
             
            VALUE pycall_pylong_to_ruby(PyObject *);
         | 
| 648 648 | 
             
            VALUE pycall_pystring_to_ruby(PyObject *);
         | 
| 649 | 
            +
            VALUE pycall_pyunicode_to_ruby(PyObject *);
         | 
| 649 650 | 
             
            VALUE pycall_pyobject_to_a(PyObject *);
         | 
| 650 651 |  | 
| 651 652 | 
             
            VALUE pycall_conv_to_str(VALUE);
         | 
    
        data/lib/pycall.rb
    CHANGED
    
    
    
        data/lib/pycall/iruby_helper.rb
    CHANGED
    
    | @@ -5,21 +5,19 @@ module PyCall | |
| 5 5 | 
             
              module IRubyHelper
         | 
| 6 6 | 
             
                private
         | 
| 7 7 |  | 
| 8 | 
            -
                def  | 
| 9 | 
            -
                  return false unless obj.kind_of?  | 
| 10 | 
            -
                  return false unless  | 
| 11 | 
            -
                   | 
| 8 | 
            +
                def check_python_object_respond_to_format_method(obj, method_name)
         | 
| 9 | 
            +
                  return false unless obj.kind_of? PyObjectWrapper
         | 
| 10 | 
            +
                  return false unless obj.respond_to? method_name
         | 
| 11 | 
            +
                  true
         | 
| 12 12 | 
             
                end
         | 
| 13 13 |  | 
| 14 | 
            -
                def  | 
| 14 | 
            +
                def register_python_object_formatter(format_name, mime, priority_value=0)
         | 
| 15 15 | 
             
                  method_name = :"_repr_#{format_name}_"
         | 
| 16 16 | 
             
                  match do |obj|
         | 
| 17 | 
            -
                     | 
| 17 | 
            +
                    check_python_object_respond_to_format_method(obj, method_name)
         | 
| 18 18 | 
             
                  end
         | 
| 19 19 | 
             
                  priority priority_value
         | 
| 20 | 
            -
                  format mime  | 
| 21 | 
            -
                    PyCall.getattr(obj, method_name).()
         | 
| 22 | 
            -
                  end
         | 
| 20 | 
            +
                  format mime, &method_name
         | 
| 23 21 | 
             
                end
         | 
| 24 22 | 
             
              end
         | 
| 25 23 | 
             
            end
         | 
| @@ -27,14 +25,14 @@ end | |
| 27 25 | 
             
            ::IRuby::Display::Registry.module_eval do
         | 
| 28 26 | 
             
              extend PyCall::IRubyHelper
         | 
| 29 27 |  | 
| 30 | 
            -
               | 
| 31 | 
            -
               | 
| 32 | 
            -
               | 
| 33 | 
            -
               | 
| 34 | 
            -
               | 
| 35 | 
            -
               | 
| 36 | 
            -
               | 
| 37 | 
            -
               | 
| 38 | 
            -
               | 
| 39 | 
            -
               | 
| 28 | 
            +
              register_python_object_formatter :html, 'text/html', 1
         | 
| 29 | 
            +
              register_python_object_formatter :markdown, 'text/markdown', 1
         | 
| 30 | 
            +
              register_python_object_formatter :svg, 'image/svg+xml', 1
         | 
| 31 | 
            +
              register_python_object_formatter :png, 'image/png', 1
         | 
| 32 | 
            +
              register_python_object_formatter :jpeg, 'image/jpeg', 1
         | 
| 33 | 
            +
              register_python_object_formatter :latex, 'text/latex', 1
         | 
| 34 | 
            +
              register_python_object_formatter :json, 'application/json', 1
         | 
| 35 | 
            +
              register_python_object_formatter :javascript, 'application/javascript', 1
         | 
| 36 | 
            +
              register_python_object_formatter :pdf, 'application/pdf', 1
         | 
| 37 | 
            +
              register_python_object_formatter :pretty, 'text/plain', -1000
         | 
| 40 38 | 
             
            end
         | 
    
        data/lib/pycall/version.rb
    CHANGED
    
    
    
        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. | 
| 4 | 
            +
              version: 1.0.2
         | 
| 5 5 | 
             
            platform: x64-mingw32
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Kenta Murata
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017-09- | 
| 11 | 
            +
            date: 2017-09-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |