Issue #9 closed

FFI support on windows is spotty

Anonymous created an issue

http://code.activestate.com/lists/python-win32/10743/ https://github.com/halostatue/rubypython/pull/1#issuecomment-3380452

Python is installing itself to the wrong place for some reason. This probably needs to be told to the python maintainers.

I copied the DLL to the SysWOW64 directory and now I get a load error from FFI:

c:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/lib/ffi/library.rb:121:in block in ffi_lib': Could not open library 'C:/Windows/system32/python27.dll': ∞ (LoadError) from c:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/lib/ffi/library.rb:88:inmap' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.0.11/lib/ffi/library.rb:88:in ffi_lib' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython/python.rb:29:in<module:Python>' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython/python.rb:21:in <top (required)>' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython.rb:261:inload' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython.rb:261:in reload_library' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rubypython-0.5.3/lib/rubypython.rb:104:instart' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.2.4/lib/pygments/ffi.rb:8:in start' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.2.4/lib/pygments/ffi.rb:82:inhighlight' from test.rb:3:in `<main>'

Comments (4)

  1. Anonymous

    I installed via python-2.7.2.msi on Windows 7 64-bit, and python27.dll landed in C:\Windows\SysWOW64. Here's a working version slightly improved from bendoerr's pull request:

        if FFI::Platform.windows?
          # Do this after trying to add alternative extensions, 
          # since windows install has a python27.a and can cause 
          # troble.
          #
          # Some Windows python installers install the DLL in the python directory
          # others install in the Windows system directory.  So we should search both.
          path = File.dirname(@python)
          windir = ENV['WINDIR']
          # Windows Python doesn't like ' with inner " so we have to switch it around. 
          winversion = %x(#{@python} -c "import sys; print '%d%d' % sys.version_info[:2]").chomp
          dll = "python#{winversion}.dll"
          locations << File.join(windir, "System32", dll)
          locations << File.join(windir, "SysWOW64", dll)
          locations << File.join(path, dll)
          locations << File.join(path, "libs", dll)
        end
    
  2. Log in to comment