Bug 51580 - import dbus fails on MSWindows (x86) python 2.7
Summary: import dbus fails on MSWindows (x86) python 2.7
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: python (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Windows (All)
: medium normal
Assignee: Simon McVittie
QA Contact: John (J5) Palmieri
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-29 23:57 UTC by Mark Mikofski
Modified: 2012-07-23 17:57 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Instructions for building dbus-python for windows with mingw (9.96 KB, text/plain)
2012-07-06 14:36 UTC, Mark Mikofski
Details
updated instructions for dbus-python, dbus and dbus-glib (15.52 KB, application/octet-stream)
2012-07-21 01:05 UTC, Mark Mikofski
Details
version 1.1 updated directions to install dbus-python on windows (17.53 KB, text/plain)
2012-07-23 17:57 UTC, Mark Mikofski
Details

Description Mark Mikofski 2012-06-29 23:57:46 UTC
import dbus returns the following traceback

>>> import dbus
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "dbus\__init__.py", line 82, in <module>
    import dbus.types as types
  File "dbus\types.py", line 6, in <module>
    from _dbus_bindings import (
ImportError: DLL load failed: %1 is not a valid Win32 application.

steps to reproduce:
1. install python-2.7.3 using windows installer
2. install pygtk-2.24 using windows all-in-one installer
3. download, build & install dbus-1.6, dbus-python, dbus-glib

mingw32 on windows xp-sp3 (x86)
Python 2.7.3 - win32
GTK 2.0 - win32
PyGTK 2.24 - win32
dbus_glib 0.100 - compiled with mingw32
dbus-python 1.1.1 - compiled with mingw32
dbus 1.6.0 - mingw32

using sh.exe in msys
./configure PYTHON="/c/Python27/python" \
PYTHON_INCLUDES="-I/c/Python27/include/" \
PYTHON_LIBS="-L/c/Python27/libs -lpython27.lib" \
PKG_CONFIG="C:\Python27\Lib\site-packages\gtk-2.0\runtime\bin\pkg-config.exe" \
PKG_CONFIG_PATH=/usr/local/bin:/usr/local/include/dbus-1.0/dbus:/usr/local/lib:/usr/local/lib/dbus-1.0/include/dbus:/usr/local/lib/pkgconfig

* there's also libpython27.a 
* also dbus 1.6.2 compiles very nicely with msvc and cmake, but I haven't tried it yet with dbus-python
* the pkg-config.exe is from the gtk-2.0 win32 build from their all in one windows installer, it all comes in pyGTK 2.24
* I tried LDFLAGS="\$(PYTHON_LIBS) -no-undefined -shrext .pyd" but configure said that no-undefined and shext were unknown
Comment 1 Simon McVittie 2012-07-04 10:56:01 UTC
(In reply to comment #0)
> ./configure PYTHON="/c/Python27/python" \
> PYTHON_INCLUDES="-I/c/Python27/include/" \
> PYTHON_LIBS="-L/c/Python27/libs -lpython27.lib" \

I would have expected PYTHON_LIBS to be more like:

    PYTHON_LIBS="-L/c/Python27/libs -lpython27"

(you don't normally have to use an extension in the argument to -l).

> * I tried LDFLAGS="\$(PYTHON_LIBS) -no-undefined -shrext .pyd" but configure
> said that no-undefined and shext were unknown

Please try the wip-windows branch from dbus-python git, or this snapshot of it:

http://people.freedesktop.org/~smcv/dbus-python-1.1.1.20120704.tar.gz

which should make changing LDFLAGS unnecessary. If it works, I'll merge that branch.
Comment 2 Simon McVittie 2012-07-05 03:55:21 UTC
(In reply to comment #1)
> If it works, I'll merge that branch.

Merged in git based on positive feedback on the mailing list, will be in 1.1.2.

If you want to contribute documentation on how to compile dbus-python with mingw, I'd be happy to review it.
Comment 3 Mark Mikofski 2012-07-06 14:36:50 UTC
Created attachment 63911 [details]
Instructions for building dbus-python for windows with mingw
Comment 4 Mark Mikofski 2012-07-06 14:41:06 UTC
I've attached the instructions to follow to build dbus-python for windows.

But there are still some issues, although I think they are with dbus, and not dbus-python.

Steps to reproduce:
>>> import dbus # this works, yay!
>>> session_bus = dbus.SessionBus() # this does start the daemon
Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "c:\mingw\msys\1.0\local\lib\site-packages\dbus\_dbus.py", line 211, in __new__
        return Bus.__new__(cls, Bus.TYPE_SESSION, private=private, mainloop=mainloop)
      File "c:\mingw\msys\1.0\local\lib\site-packages\dbus\_dbus.py", line 100, in __new__
       bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
      File "c:\mingw\msys\1.0\local\lib\site-packages\dbus\bus.py", line 122, in __new__
        bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
      dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Failed: Failed to get autolaunch address from launched dbus-daemon

System config: see below
Comment 5 Mark Mikofski 2012-07-21 01:05:49 UTC
Created attachment 64472 [details]
updated instructions for dbus-python, dbus and dbus-glib

add `--with-dbus-session-bus-default-address=autolaunch:` so that dbus works on ms-windows out of the box
Comment 6 Mark Mikofski 2012-07-23 17:57:51 UTC
Created attachment 64557 [details]
version 1.1 updated directions to install dbus-python on windows

Remove makefile.patch for dbus-glib/dbus/examples, since not needed. The issue was with GTK setenv.cmd, not dbus-glib, added my comment to existing GTK issue 677470 [https://bugzilla.gnome.org/show_bug.cgi?id=677470]. Do **not** use quotes in MS-Windows PATH environment variable.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.