facelessuser / SerializedDataConverter

Convert between serialized data formats (plist | json | yaml)
Other
26 stars 4 forks source link

Custom python2.6 in sublime text 2 #7

Closed tummychow closed 10 years ago

tummychow commented 10 years ago

I am using SerializedDataConverter on Sublime Text 2 with Arch Linux (NOT ubuntu). Due to an issue with ctypes brought up by SublimeClang, I am not using the standard python2.6 packaged with sublime, but a custom build which fixes that issue. The build is using the instructions provided in that package's readme.

However, SerializedDataConverter does not work in this environment. I imagine the python is part of the problem. (Doesn't really help that Arch has problems building this archaic version of python because readline doesn't play nice with it.)

Here is the console content indicating the issue with loading the plugin:

Reloading plugin /home/sjung/.config/sublime-text-2/Packages/SerializedDataConverter/json_yaml.py
Traceback (most recent call last):
  File "./sublime_plugin.py", line 62, in reload_plugin
  File "./json_yaml.py", line 17, in <module>
    from lib.language_converter import LanguageConverter as _LanguageConverter
  File "./lib/language_converter.py", line 6, in <module>
    from .common_include import *
  File "./lib/common_include.py", line 2, in <module>
    from .sublime_include import load_settings, ST3, ST2
  File "./lib/sublime_include/__init__.py", line 21, in <module>
    linux_lib = load_settings().get("linux_python2.6_lib", "/usr/lib/python2.6/lib-dynload")
TypeError: load_settings() takes at least 1 argument (0 given)
Reloading plugin /home/sjung/.config/sublime-text-2/Packages/SerializedDataConverter/on_save_converter.py
Traceback (most recent call last):
  File "./sublime_plugin.py", line 62, in reload_plugin
  File "./on_save_converter.py", line 6, in <module>
    from lib.common_include import *
  File "./lib/common_include.py", line 2, in <module>
    from .sublime_include import load_settings, ST3, ST2
  File "./lib/sublime_include/__init__.py", line 21, in <module>
    linux_lib = load_settings().get("linux_python2.6_lib", "/usr/lib/python2.6/lib-dynload")
TypeError: load_settings() takes at least 1 argument (0 given)
Reloading plugin /home/sjung/.config/sublime-text-2/Packages/SerializedDataConverter/plist_json.py
Traceback (most recent call last):
  File "./sublime_plugin.py", line 62, in reload_plugin
  File "./plist_json.py", line 18, in <module>
    from lib.language_converter import LanguageConverter as _LanguageConverter
  File "./lib/language_converter.py", line 6, in <module>
    from .common_include import *
  File "./lib/common_include.py", line 2, in <module>
    from .sublime_include import load_settings, ST3, ST2
  File "./lib/sublime_include/__init__.py", line 21, in <module>
    linux_lib = load_settings().get("linux_python2.6_lib", "/usr/lib/python2.6/lib-dynload")
TypeError: load_settings() takes at least 1 argument (0 given)
Reloading plugin /home/sjung/.config/sublime-text-2/Packages/SerializedDataConverter/plist_yaml.py
Traceback (most recent call last):
  File "./sublime_plugin.py", line 62, in reload_plugin
  File "./plist_yaml.py", line 16, in <module>
    from lib.language_converter import LanguageConverter as _LanguageConverter
  File "./lib/language_converter.py", line 6, in <module>
    from .common_include import *
  File "./lib/common_include.py", line 2, in <module>
    from .sublime_include import load_settings, ST3, ST2
  File "./lib/sublime_include/__init__.py", line 21, in <module>
    linux_lib = load_settings().get("linux_python2.6_lib", "/usr/lib/python2.6/lib-dynload")
TypeError: load_settings() takes at least 1 argument (0 given)

What build settings do I need to apply for SDC to work correctly on a custom python?

tummychow commented 10 years ago

Some more notes:

This occurs out-of-the-box with the sublime text 64-bit tarball (ie with no custom python I still encounter this error on arch linux), and the error text is exactly the same.

I also have lib-dynload in my custom python; specifying the path to it in SDC's settings file does not affect the error.

Sorry if this is not really clear, I'm not sure where to begin debugging so I'm just rebuilding and testing various pythons over and over. (I don't really speak python so I can't make any sense of the code.) Let me know if there is something specific you want to try.

tummychow commented 10 years ago

Okay, so I kept experimenting and here is the environment where the plugin worked:

I'll close this since that seems to fix the problem, but there seems to be all kinds of weirdness about loading python into sublime, so if you want more information on my environment, let me know.

facelessuser commented 10 years ago

ST2 Linux support always needs some tweaking for this plugin. ST3 is much more reliable for plugins like this.

You shouldn't have to remove anything from init.py. Just set "linux_python2.6_lib" to an empty string in your settings file and then it won't import any unnecessary paths.

tummychow commented 10 years ago

I get the same error with the empty string /shrug

I'd migrate to ST3 but I can't live without the C autocompletion, so for now I can live with the other issues of ST2.

facelessuser commented 10 years ago

That doesn't make sense. The code won't include a library path if the path does not exist. You would have to restart Sublime after the change.

    linux_lib = load_settings().get("linux_python2.6_lib", "/usr/lib/python2.6/lib-dynload")
    if not linux_lib in sys.path and exists(linux_lib):
        sys.path.append(linux_lib)

You could try setting it something that doesn't exist /SomePathThatDoesNotExist, but that shouldn't be required. os.path.exists("") evaluates to False.

If your okay with updating the plugin manually every time you sync up to the main branch, I guess that is fine. But I can't understand why removing the lines would be any different than setting the path to something that doesn't exist.

facelessuser commented 10 years ago

Now that I think about it, I am betting you didn't restart. As soon as you added back the line, it probably tried to import that folder. Then changing the setting wouldn't matter because the folder was already included. A restart is mandatory.

tummychow commented 10 years ago

I don't speak Python, so I can't claim to understand the issue either. For what it's worth, I tried hacking at it in a few other ways beforehand, like this:

    linux_lib = load_settings("linux_python2.6_lib", "/usr/lib/python2.6/lib-dynload")
    if not linux_lib in sys.path and exists(linux_lib):
        sys.path.append(linux_lib)

And then I got a new error, along the lines of sys being an unknown identifier. If I removed the left side of the AND, like this:

    linux_lib = load_settings("linux_python2.6_lib", "/usr/lib/python2.6/lib-dynload")
    if exists(linux_lib):
        sys.path.append(linux_lib)

Then I got an error about exists being an unknown identifier.

I'm guessing there's something really wrong with my custom python, not with the code. I'm willing to hack at things to keep the ship afloat, but it's too bad I'm chained to it by SublimeClang.

tummychow commented 10 years ago

And no, I restarted every time.

facelessuser commented 10 years ago

Cool. Well I tried :).