lib/pycall/libpython/finder.rb in pycall-1.0.2 vs lib/pycall/libpython/finder.rb in pycall-1.0.3
- old
+ new
@@ -37,10 +37,11 @@
raise ::PyCall::PythonNotFound
end
end
end
+ set_PYTHONHOME(python_config)
libs = make_libs(python_config)
libpaths = make_libpaths(python_config)
# Try LIBPYTHON environment variable first.
if (libpython = ENV['LIBPYTHON'])
@@ -99,19 +100,34 @@
debug_report("investigate_python_config(#{python.inspect})")
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)
+ case value
+ when 'True', 'true', 'False', 'false'
+ value = (value == 'True' || value == 'true')
+ end
config[key.to_sym] = value if value != 'None'
end
end
end
rescue Errno::ENOENT
raise PyCall::PythonInvestigationFailed
end
def python_investigator_py
File.expand_path('../../python/investigator.py', __FILE__)
+ end
+
+ def set_PYTHONHOME(python_config)
+ if !ENV.has_key?('PYTHONHOME') && python_config[:conda]
+ case RUBY_PLATFORM
+ when /mingw32/, /cygwin/, /mswin/
+ ENV['PYTHONHOME'] = python_config[:exec_prefix]
+ else
+ ENV['PYTHONHOME'] = python_config.values_at(:prefix, :exec_prefix).join(':')
+ end
+ end
end
def make_libs(python_config)
libs = []
%i(INSTSONAME LDLIBRARY).each do |key|