Skip to content

Prepare for python 3.13Β #287

@deathaxe

Description

@deathaxe

It is planned to upgrade ST's plugin ecosystem to python 3.13.

Support for python 3.3 is being sunset. It can already be disabled via settings and will be removed next year.

Therefore plugins need to be prepared to maintain compatible with python 3.13.

I've found references to __file__ and __name__ globals in your package.

As modern python 3.1x releases move on towards __spec__ and drop support for __file__ and __package__ globals, it is recommended to replace relevant references to ensure compatibility with upcoming ST dev builds.

If this package targets ST4 and python 3.8+ it is an easy change by just replacing:

  • __file__ => __spec__.origin
  • __name__ => __spec__.name
  • __package__ => __spec__.parent

Python 3.3 doesn't support __spec__ and would require a fallback.

A common pattern might be

try:
    package_path = os.path.dirname(__spec__.origin)
except (AttributeError, NameError):
    package_path = os.path.dirname(__file__)

FWIW, ST4107+ supports calling sublime.cache_path(), sublime.installed_packages_path() and sublime.packages_path() at import time, which may help to replace/avoid various constructs like given example above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions