Sublime Forum

Python API

#1

Long time user of Sublime text and I love the Python API. I have wondered how this is done. In the application folder I see python33.zip and python33.dll. How can I do this in an application of my own. Is this a common thing or something Sublime invented? If it is not proprietary, what tools are used to make this portable python interpreter?

Thanks,
wsware

2 Likes

#2

It’s just extending and embedding the python interpreter within an application.

You can start learning here -> https://docs.python.org/3/extending/index.html

0 Likes

#3

Is this a common thing or something Sublime invented?

This is not something Sublime inventend, there are a lot of software out there using python as scripting or extension language behind the curtains (ie: blender, max, maya…).

In addition to the official link @ccw provided maybe you’ll also be interested on reading some of the early Jon’s blog article about this interesting subject, ie: https://www.sublimetext.com/blog/articles/extending-with-python and https://www.sublimetext.com/blog/articles/choosing-an-extension-language

One piece of advice, If you’re going to explore that road it’d be probably interesting that your application would be able to switch between python versions (system-wide or virtualenvs)… that way your users will be able to execute the whole set of libraries available out there.

Python usually is good keeping backwards compatibility although in some cases it won’t… so for instance, working python3.6 code won’t work on python3.3 and so on.

About shipping pythonxy.zip and pythonxy.dll … another alternative is providing python as extension as uncompressed content ie: {DLLs, include, Lib, libs}

ps: Btw, the specific part of the official docs answering your questions here.

0 Likes

#4

This is very easy to achieve with pybind11 (or more historically boost.python, but don’t use that as it doesn’t support unique pointers and shared pointers, and more).

0 Likes