GNOME Bugzilla – Bug 444366
Nautilus doesn't load Python extensions
Last modified: 2008-01-11 14:13:12 UTC
Please describe the problem: After copying some example python extensions into ~/.nautilus/python-extensions Nautilus seems to load them, but they are useless - they don't provide any additional functionality. Is there a way to fix it somehow? Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
I just tried some python nautilus extension examples and I'm seeing the same problem. Actually, I also saw the library loading bug in <URL:http://bugzilla.gnome.org/show_bug.cgi?id=327739> as well, though I worked around it by manually creating a symlink. I am using GNOME nautilus 2.19.91 in Ubuntu Gutsy Gibbon. I copied the examples from Ubuntu's python-nautilus package to ~/.nautilus/python. I then ran a new instance of nautilus with "nautilus --no-desktop" and got the following in the terminal: ----------------------------------------------------------------------- Initializing nautilus-open-terminal extension Initializing nautilus-share extension Initializing gnome-mount extension seahorse nautilus module initialized sys:1: GtkWarning: Refusing to add non-unique action 'submenu_file:\s\s\shome\sjrogers\s.gnome2\snautilus-scripts\sicons' to action group 'ScriptsGroup' Nautilus-Share-Message: REFRESHING SHARES Nautilus-Share-Message: ------------------------------------------ Nautilus-Share-Message: spawn arg "net" Nautilus-Share-Message: spawn arg "usershare" Nautilus-Share-Message: spawn arg "info" Nautilus-Share-Message: end of spawn args; SPAWNING Nautilus-Share-Message: returned from spawn: SUCCESS: Nautilus-Share-Message: exit code 255 Nautilus-Share-Message: ------------------------------------------ Nautilus-Share-Message: Called "net usershare info" but it failed: 'net usershare' returned error 255: net usershare: usershares are currently disabled ----------------------------------------------------------------------- I expected to see messages about initializing the python modules in addition to the native C ones. After starting nautilus, I found a newly created .pyc file for each .py file, so I know the python interpreter read and compiled them. However, there are no effects from any of the plugins on the nautilus GUI and no messages in the terminal regarding any of them.
I have experimented more with nautilus and nautilus-python. By setting the environment variable NAUTILUS_PYTHON_DEBUG to "misc", I persuaded nautilus-python to spit out a bunch of debug messages. It prints the message "nautilus-python:Loaded python modules" after loading each python extension. After all python extensions have been loaded, it prints "nautilus_module_list_types: entered" then "nautilus_module_shutdown: entered". So, apparently, nautilus-python shuts itself down immediately after loading all the extensions, rendering itself completely useless. I compiled SVN trunk of nautilus-python, which is over a year old. Though it successfully builds, I get the following messages in the middle of the build: ---------------------------------------------------------------------------- Warning: generating old-style constructor for:nautilus_column_new Warning: generating old-style constructor for:nautilus_menu_item_new Warning: generating old-style constructor for:nautilus_property_page_new Could not write function nautilus_file_info_list_copy: No ArgType for GList* Could not write function nautilus_file_info_list_free: No ArgType for GList* Warning: Constructor for NautilusColumn needs to be updated to new API See http://live.gnome.org/PyGTK_2fWhatsNew28#update-constructors Warning: Constructor for NautilusMenuItem needs to be updated to new API See http://live.gnome.org/PyGTK_2fWhatsNew28#update-constructors Warning: Constructor for NautilusPropertyPage needs to be updated to new API See http://live.gnome.org/PyGTK_2fWhatsNew28#update-constructors ---------------------------------------------------------------------------- Apparently, PyGTK, which nautilus-python depends on, had significant API changes in version 2.8. I tried to follow the instructions referred to by the Warning messages (the URL isn't quite right, so I had to search a bit). I succeeded in getting rid of Constructor warnings, but barely understood what I was doing, since I was editing Scheme code which apparently generates Gobject C code in order to interface with Python code. I did not succeed in getting rid of the errors about "No ArgType". Whether I really fixed any problems or not, nautilus still shuts down nautilus-python as soon as it initializes. I suspect that nautilus-python is failing to initialize the nautilus objects properly, so appears useless to nautilus, which swiftly discards it. PyGTK has had major changes, but nautilus-python hasn't changed in quite a while, so it's rotted. I really hope someone can figure this out, since writing nautilus extensions in Python should be really easy and fun. I don't want to think about all that Gobject nastiness any more than I have to.
I believe I've fixed this problem. It was due to a change in the Python/C API, not in PyGTK. Python 2.5 changed its C API to use Py_ssize_t in the PyDict_Next function instead of int. This causes Python extension classes to not be detected properly on amd64, though it still works on i386, probably because Py_ssize_t is the same size as int on i386, but they are different on amd64. So, nautilus-python probably needs to use different signatures depending on which version of Python it's building againts.
Created attachment 99874 [details] [review] Fixes amd64 builds against Python 2.5
I should have checked earlier, but this issue is discussed in detail in PEP 353: <URL:http://www.python.org/dev/peps/pep-0353/>.
Created attachment 99895 [details] [review] Improved patch for both Python 2.4 and 2.5 Following <URL:http://www.python.org/dev/peps/pep-0353/>, this should allow proper compilation and execution on i386 and amd64 linked with Python 2.4 and 2.5 and hopefully other versions and architectures.
*** Bug 501212 has been marked as a duplicate of this bug. ***
I've downloaded and applied your patch. Python extensions seem to work, but now, unfortunately, Nautilus crashes and hangs often. What could be the source of the problem?
It's really impossible to know what the problem is without more information, like what Nautilus or Python extension code is doing at the time. I have submitted another patch for freezes I triggered with specific Python extension code. <URL:http://bugzilla.gnome.org/show_bug.cgi?id=500996>
*** Bug 505594 has been marked as a duplicate of this bug. ***
Seems OK. Will it hit the trunk?
Made it work for me too.
2008-01-11 Jonathan Rogers <jonner@teegra.net> reviewed by: Johan Dahlin * src/nautilus-python-object.c: * src/nautilus-python.c: (nautilus_python_load_file): * src/nautilus-python.h: Use Py_ssize_t instead of int, so nautilus-python works on Python 2.5 fixes #444366