module PyBind
Constants
- PYTHON_DESCRIPTION
- PYTHON_VERSION
- VERSION
Attributes
builtin[R]
Public Class Methods
import(name) { |value| ... }
click to toggle source
# File lib/pybind/import.rb, line 38 def self.import(name) name = name.to_s if name.is_a? Symbol raise TypeError, 'name must be a String' unless name.is_a? String value = LibPython.PyImport_ImportModule(name) raise PyError.fetch if value.null? value = value.to_ruby return value unless block_given? begin yield value ensure PyBind.decref(value) end end
parse_traceback(traceback)
click to toggle source
# File lib/pybind/error.rb, line 34 def self.parse_traceback(traceback) format_tb_func = PyBind.traceback.get_attribute('format_tb') format_tb_func.call(traceback).to_a end
Private Class Methods
__initialize_pybind__()
click to toggle source
# File lib/pybind/init.rb, line 8 def self.__initialize_pybind__ initialized = (0 != LibPython.Py_IsInitialized()) return if initialized LibPython.Py_InitializeEx(0) FFI::MemoryPointer.new(:pointer, 1) do |argv| argv.write_pointer(FFI::MemoryPointer.from_string('')) LibPython.PySys_SetArgvEx(0, argv, 0) end @builtin = LibPython.PyImport_ImportModule(PYTHON_VERSION < '3.0.0' ? '__builtin__' : 'builtins').to_ruby end