Sublime Forum

Workflow for ST3 plugin development

#1

Hello, new to the forums here. I’m delving into python for the first time and looking at sublime packages to learn from the code. I’m using a fresh install of ST3 on Windows 10 and I have python 3.7.2 installed. Right now I’m just testing import commands and have run into errors that make me think that I’m not set up correctly.

Traceback (most recent call last):
  File "C:\test\url\test.py", line 2, in <module>
    import sublime
ModuleNotFoundError: No module named 'sublime'
[Finished in 0.1s with exit code 1]

and also…

Traceback (most recent call last):
  File "C:\test\url\test.py", line 2, in <module>
    import sublime_plugin
ModuleNotFoundError: No module named 'sublime_plugin'
[Finished in 0.1s with exit code 1]

According to this topic it only works in the ST3 console and not the build system which I can confirm. My question is then, how do I set up a workflow where I can test scripts that require these imports if they’re only available from the ST2 embedded Python interpreter?

I’m sure there’s something obvious that I’m not getting.

Thanks!

1 Like

Sublime Text versus Visual Studio Code in 2019
#2

I use the UnitTesting package, which provides an implementation of Python’s unittest framework.

1 Like

#3

Thanks @ThomSmith, I didn’t phrase the question correctly. I’m wondering how to step through the code for an ST3 module to inspect variables and expressions during run time. Specifically, when that module uses import statements for sublime and sublime_plugin like in the modules I’m currently learning from.

Do I need to install ST2 in parallel and is there additional set-up?

Can someone point me to a tool chain or workflow that describes how to develop and debug modules for ST?

0 Likes

#4

There is the Plugin Debugger package, but I haven’t used that in quite a while. I generally debug with print calls and logging.

ST2 and ST3 are completely separate, so I don’t see how installing that in parallel would help with anything.

Also, if you’d like to inspect the sublime and sublime_plugin modules, you can find those in the installation directory of ST.

0 Likes

#5

Thanks for the pointer to the plugin and module information @FichteFoll. Being new to all of this, I was trying to rule out whether or not you had to develop ST plugins in ST2 exclusively so thanks for clearing that up as well.

I’ll continue to look for resources that explain tooling for and developing plugins for ST with examples. Meanwhile, I’d love to hear other useful suggestions for the newb attempting to reverse engineer plugins if anyone has them and are willing to share!

0 Likes

Sublime Text versus Visual Studio Code in 2019
#6

I’ll admit I use print statements quite a bit for debugging my own ST3 package. Sometimes logging as well. It may not be fancy but it gets the job done.

0 Likes

#7

It should be possible to hook up sublime’s runtime to a debugger like web_pdb. I hacked together a proof of concept, and it’s flaky but functional. Some motivated individual could turn this into a robust package.

(You could also just use pbd or hook that up to a sublime-based GUI, but if you traced code on the main thread it would block the UI anyway.)

1 Like