lib/pycall/libpython.rb in pycall-0.1.0.alpha.20170311 vs lib/pycall/libpython.rb in pycall-0.1.0.alpha.20170317
- old
+ new
@@ -39,11 +39,11 @@
libs.uniq!
executable = python_config[:executable]
libpaths = [ python_config[:LIBDIR] ]
if FFI::Platform.windows?
- libpaths << dirname(executable)
+ libpaths << File.dirname(executable)
else
libpaths << File.expand_path('../../lib', executable)
end
libpaths << python_config[:PYTHONFRAMEWORKPREFIX] if FFI::Platform.mac?
@@ -71,14 +71,20 @@
# Find libpython (we hope):
libsuffix = FFI::Platform::LIBSUFFIX
libs.each do |lib|
libpaths.each do |libpath|
- libpath_lib = File.join(libpath, lib)
+ next unless libpath
+ # NOTE: File.join doesn't use File::ALT_SEPARATOR
+ libpath_lib = [libpath, lib].join(File::ALT_SEPARATOR || File::SEPARATOR)
if File.file?("#{libpath_lib}.#{libsuffix}")
- libs = ffi_lib("#{libpath_lib}.#{libsuffix}")
- return libs.first
+ begin
+ libs = ffi_lib("#{libpath_lib}.#{libsuffix}")
+ return libs.first
+ rescue LoadError
+ # skip load error
+ end
end
end
end
end
@@ -86,10 +92,10 @@
python_env = { 'PYTHONIOENCODING' => 'UTF-8' }
IO.popen(python_env, [python, python_investigator_py], 'r') do |io|
{}.tap do |config|
io.each_line do |line|
key, value = line.chomp.split(': ', 2)
- config[key.to_sym] = value
+ config[key.to_sym] = value if value != 'None'
end
end
end
end