From 6c06857ad2f327a70006040600689781b7e143be Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 17 Sep 2023 19:21:00 +0200 Subject: [PATCH] Add support for python specific legacy dependencies This commit extends support for legacy dependencies format. Specifically dependencies may now also contain following folders for ST4 / python specific code paths: - "st4" = install only on ST4 - "st4_{PY}" = ... and given python version - "st4_{PY}_{OS}" = ... and given OS - "st4_{PY}_{OS}_{ARCH}" = ... and given architecture If both "st3" and "st4" folders are present, the latter one is preferred on ST4 and ignored on ST3. Platform/arch specific ST3 dependencies are restricted to python 3.3 as those are assumed to contain compiled libraries. Support is added to help those more familiar with the old format. It is however not recommended as the whole library with all variants needs to be downloaded which costs more bandwidth and may therefore result in slower installations. It is recommended to create or re-use existing WHEEL files and add a release for each python/platform/arch combination. --- package_control/library.py | 40 +++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/package_control/library.py b/package_control/library.py index e2152e8c..dfd44ba8 100644 --- a/package_control/library.py +++ b/package_control/library.py @@ -145,6 +145,10 @@ def convert_dependency(dependency_path, python_version, name, version, descripti - "st3" - "st3_{OS}" - "st3_{OS}_{ARCH}" + - "st4" + - "st4_{PY}" + - "st4_{PY}_{OS}" + - "st4_{PY}_{OS}_{ARCH}" :param python_version: A unicode string of "3.3" or "3.8" @@ -162,28 +166,42 @@ def convert_dependency(dependency_path, python_version, name, version, descripti An optional unicode string of the homepage for the library """ - ver = 'st3' + py = python_version.replace(".", "") plat = sublime.platform() arch = sublime.arch() - install_rel_paths = { - 'all': 'all', - 'ver': ver, - 'plat': '%s_%s' % (ver, plat), - 'arch': '%s_%s_%s' % (ver, plat, arch) - } + install_rel_paths = [] + # include st4 dependencies on ST4, only + if int(sublime.version()) >= 4000: + install_rel_paths.append(('st4_arch', 'st4_py%s_%s_%s' % (py, plat, arch))) + install_rel_paths.append(('st4_plat', 'st4_py%s_%s' % (py, plat))) + install_rel_paths.append(('st4_py', 'st4_py%s' % py)) + install_rel_paths.append(('st4', 'st4')) + + # platform/arch specific st3 dependencies are most likely only compatible with python 3.3 + if python_version == "3.3": + install_rel_paths.append(('st3_arch', 'st3_%s_%s' % (plat, arch))) + install_rel_paths.append(('st3_plat', 'st3_%s' % plat)) + + # commonly supported variants + install_rel_paths.append(('st3', 'st3')) + install_rel_paths.append(('all', 'all')) + + # Find source paths + # 1. Begin with st4 and fallback to st3 dependencies. + # 2. Begin with most specific followed by more generic variants. src_dir = None plat_specific = False - for variant in ('arch', 'plat', 'ver', 'all'): - install_path = os.path.join(dependency_path, install_rel_paths[variant]) + for variant, rel_path in install_rel_paths: + install_path = os.path.join(dependency_path, rel_path) if os.path.exists(install_path): src_dir = install_path - plat_specific = variant in ('arch', 'plat') + plat_specific = variant in ('st3_arch', 'st3_plat', 'st4_arch', 'st4_plat') break if not src_dir: - raise ValueError('Unrecognized source archive layout') + raise ValueError('Unrecognized or incompatible source archive layout') did_name = '%s-%s.dist-info' % (name, version) did = distinfo.DistInfoDir(src_dir, did_name)