Skip to content

Discuss installable Python package support for Python 3.8 plugin_host and beyond #1652

@kylebebak

Description

@kylebebak

Hey @wbond @deathaxe @BenjaminSchaaf @FichteFoll

I'm creating this issue to discuss PC 4.0, specifically adding support for installing Python packages that plugins can depend on, and allowing the 3.8 plugin_host to be upgraded at some point.

I know very little about the PC source code, but I've read about design decisions and constraints, and how PC has evolved. From what I can tell:

  • We'll probably always want to run a Python 3.3 plugin host
  • There aren't a lot of plugins yet that depend on the 3.8 host, and there probably aren't many 3.8 plugins that depend on compiled code
    • If this is the case, replacing the 3.8 host with an e.g. 3.11 host wouldn't break too many plugins, but it would very likely break some
  • One of the flagship features for PC 4 is support for installing Python packages, so plugins can depend on these without plugin devs having to vendor them, or having to rely on/create "dependencies" with vendored Python packages

Here are some thoughts on installable packages:

  • They're a great feature!
    • Plugins with package deps would be much easier to write and maintain
    • Vendoring packages works, but it's a pain
    • For packages that use shared objects, it makes the plugin dev responsible for vendoring these for every platform that ST supports
    • This is even more of a pain if the plugin host version changes
      • Package devs have to revendor compiled code for the new Python version
  • So we should definitely add installable packages
  • But we shouldn't support this for the 3.3 plugin host, because it would be a mess and place painful constraints on the design
    • That four-point-oh is 540 commits ahead of master suggests there are already painful constraints on the design

On upgrading the plugin host:

  • The 3.8 plugin host will have to be upgraded at some point, because Python 3.8 will become obsolete just like 3.3 did
  • At the same time, for the long-term success of PC it's probably best to not support a third plugin host
    • Not good to e.g. have 3.3, 3.8 and 3.11 hosts run in parallel
    • If we do this eventually we'll have 4 plugin hosts...
  • We could instead replace 3.8 with 3.11 or 3.12 or whatever

On how to build installable packages in PC:

  • Installing just wheels is a great idea
  • But building our own pip to do this is not
  • pip is solid, sophisticated, extremely well-tested, etc
    • We should just use pip, e.g. pip install --only-binary
  • Just like ST ships a bundled Python for the plugin host, it should ship a bundled pip for the same Python version as the plugin host
  • Plugins can specify package deps in something standard, like requirements.txt
  • pip can install them and PC can put them on the plugin host's Python path, so they're importable by plugin code
  • In the future, when we replace the 3.8 plugin host with e.g. 3.11, PC can remove site-packages or wherever the old pip installed its packages, then reinstall them with the new pip
    • With --only-binary, and a plugin host that doesn't use a bleeding edge Python, this is unlikely to break packages, even those that depend on compiled code
    • This "dynamic" plugin host can be upgraded every few years to a new Python version that's been in production for at least a year
    • E.g. later this year would be a reasonable time to upgrade the host to 3.11, but not to 3.12

On backwards compatibility with 3.3:

  • Relying on pip means packages aren't supported for the 3.3 plugin host, but that's fine
  • It's actually desirable to have a break between the 3.3 plugin host, which will have to stick around forever, and the "dynamic" plugin host (3.8 now, maybe 3.11 next, etc)
  • Otherwise constraints in Python 3.3 (released 11 years ago!) prevent innovation on the 3.8 plugin host, and all future plugin host versions, and hence on all future ST plugins

In summary, I think installable packages and a "dynamic" plugin host dovetail nicely, and are key to the future of ST plugin development. New plugin devs don't want to write code against obsolete Python versions, and vendor & patch obsolete Python packages.

Either one of these features (installable packages in PC, new plugin host) could be shipped on its own. If we plan on doing both of them, we'd first need to ship a PC release with existing (legacy) code for 3.3 plugins, and code for dynamic 3.X plugins with installable packages.

Changing the plugin host version every few years is bound to break some plugins, but installable packages make this less likely and less painful. The alternatives, running more and more plugin hosts or freezing the second plugin host at 3.8, are worse.

four-point-oh notwithstanding, PC hasn't changed much in the last 3 years. If it stops getting better people will eventually stop writing plugins. I love ST, I've used it and pretty much only it for my entire career, but I would have switched to something else if it weren't for LSP support, and that's a plugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions