Created patch from upstream commit to remove target depencency to setuptools(pkg_resources) in migrations.py file. See patch for details.
Signed-off-by: Lars Pedersen <[email protected]> --- ...-migrations.py-using-upstream-commit.patch | 147 ++++++++++++++++++ patches/yoyo-migrations-8.2.0/series | 4 + rules/python3-yoyo-migrations.in | 5 +- rules/python3-yoyo-migrations.make | 4 +- 4 files changed, 155 insertions(+), 5 deletions(-) create mode 100644 patches/yoyo-migrations-8.2.0/0001-Patch-migrations.py-using-upstream-commit.patch create mode 100644 patches/yoyo-migrations-8.2.0/series diff --git a/patches/yoyo-migrations-8.2.0/0001-Patch-migrations.py-using-upstream-commit.patch b/patches/yoyo-migrations-8.2.0/0001-Patch-migrations.py-using-upstream-commit.patch new file mode 100644 index 000000000..a122a2f24 --- /dev/null +++ b/patches/yoyo-migrations-8.2.0/0001-Patch-migrations.py-using-upstream-commit.patch @@ -0,0 +1,147 @@ +From: Lars Pedersen <[email protected]> +Date: Wed, 18 Sep 2024 09:08:44 +0000 +Subject: [PATCH] Patch migrations.py using upstream commit + +Removes dependency for setuptools (pkg_resources), since it has been deprecated + +https://hg.sr.ht/~olly/yoyo/rev/d126fcf9f094c4ce00683f664f4aa6e1c0e0c9f1 + +Signed-off-by: Lars Pedersen <[email protected]> +--- + yoyo/migrations.py | 54 ++++++++++++++++++++++++++++-------------------------- + 1 file changed, 28 insertions(+), 26 deletions(-) + +diff --git a/yoyo/migrations.py b/yoyo/migrations.py +index 79d371d79462..cce2c0a27ed6 100755 +--- a/yoyo/migrations.py ++++ b/yoyo/migrations.py +@@ -15,23 +15,26 @@ + from collections import Counter + from collections import OrderedDict + from collections import abc ++from contextlib import ExitStack + from copy import copy + from glob import glob ++from importlib import resources + from itertools import chain + from itertools import count + from itertools import zip_longest + from logging import getLogger ++import atexit + import typing as t + import hashlib + import importlib.util + import os ++import pathlib + import re + import sys + import inspect + import types + import textwrap + +-import pkg_resources + import sqlparse + + from yoyo import exceptions +@@ -43,15 +46,16 @@ default_migration_table = "_yoyo_migration" + hash_function = hashlib.sha256 + + +-def _is_migration_file(path): ++def _is_migration_file(path: pathlib.Path): + """ + Return True if the given path matches a migration file pattern + """ + from yoyo.scripts import newmigration + +- _, extension = os.path.splitext(path) +- return extension in {".py", ".sql"} and not path.startswith( +- newmigration.tempfile_prefix ++ return ( ++ path.is_file() ++ and path.suffix in {".py", ".sql"} ++ and not path.name.startswith(newmigration.tempfile_prefix) + ) + + +@@ -133,7 +137,6 @@ def read_sql_migration( + + + class Migration(object): +- + __all_migrations: t.Dict[str, "Migration"] = {} + + def __init__(self, id, path, source_dir): +@@ -235,7 +238,6 @@ class Migration(object): + self.steps = collector.create_steps(self.use_transactions) + + def process_steps(self, backend, direction, force=False): +- + self.load() + reverse = {"rollback": "apply", "apply": "rollback"}[direction] + +@@ -280,7 +282,6 @@ class PostApplyHookMigration(Migration): + + + class StepBase(object): +- + id = None + + def __repr__(self): +@@ -359,7 +360,6 @@ class MigrationStep(StepBase): + """ + + def __init__(self, id, apply, rollback): +- + self.id = id + self._rollback = rollback + self._apply = apply +@@ -450,29 +450,31 @@ class StepGroup(MigrationStep): + + def _expand_sources(sources) -> t.Iterable[t.Tuple[str, t.List[str]]]: + package_match = re.compile(r"^package:([^\s\/:]+):(.*)$").match ++ ++ filecontext = ExitStack() ++ atexit.register(filecontext.close) ++ + for source in sources: + mo = package_match(source) + if mo: + package_name = mo.group(1) + resource_dir = mo.group(2) +- paths = [ +- pkg_resources.resource_filename( +- package_name, "{}/{}".format(resource_dir, f) +- ) +- for f in sorted( +- pkg_resources.resource_listdir(package_name, resource_dir) +- ) +- if _is_migration_file(f) +- ] +- yield (source, paths) ++ try: ++ pkg_files = resources.files(package_name).joinpath(resource_dir) ++ if pkg_files.is_dir(): ++ all_files = ( ++ filecontext.enter_context(resources.as_file(traversable)) ++ for traversable in pkg_files.iterdir() ++ if traversable.is_file() ++ ) ++ paths = [str(f) for f in sorted(all_files) if _is_migration_file(f)] ++ yield (source, paths) ++ except FileNotFoundError: ++ continue + else: +- for directory in glob(source): +- paths = [ +- os.path.join(directory, path) +- for path in os.listdir(directory) +- if _is_migration_file(path) +- ] +- yield (directory, sorted(paths)) ++ for directory in map(pathlib.Path, glob(source)): ++ paths = [str(f) for f in directory.iterdir() if _is_migration_file(f)] ++ yield (str(directory), sorted(paths)) + + + def read_migrations(*sources): diff --git a/patches/yoyo-migrations-8.2.0/series b/patches/yoyo-migrations-8.2.0/series new file mode 100644 index 000000000..fc17f510c --- /dev/null +++ b/patches/yoyo-migrations-8.2.0/series @@ -0,0 +1,4 @@ +# generated by git-ptx-patches +#tag:base --start-number 1 +0001-Patch-migrations.py-using-upstream-commit.patch +# 0df97c28ea7ab26042fc702923ff6050 - git-ptx-patches magic diff --git a/rules/python3-yoyo-migrations.in b/rules/python3-yoyo-migrations.in index d01286d0b..e90c0264d 100644 --- a/rules/python3-yoyo-migrations.in +++ b/rules/python3-yoyo-migrations.in @@ -4,9 +4,8 @@ config PYTHON3_YOYO_MIGRATIONS tristate prompt "python3-yoyo-migrations" select PYTHON3 - select PYTHON3_SETUPTOOLS - select PYTHON3_INIHERIT - select PYTHON3_TEXT_UNIDECODE + select HOST_PYTHON3_PYBUILD + select PYTHON3_IMPORTLIB_METADATA select PYTHON3_SQLPARSE select PYTHON3_TABULATE help diff --git a/rules/python3-yoyo-migrations.make b/rules/python3-yoyo-migrations.make index d6f9c3c2b..3d774424b 100644 --- a/rules/python3-yoyo-migrations.make +++ b/rules/python3-yoyo-migrations.make @@ -14,8 +14,8 @@ PACKAGES-$(PTXCONF_PYTHON3_YOYO_MIGRATIONS) += python3-yoyo-migrations # # Paths and names # -PYTHON3_YOYO_MIGRATIONS_VERSION := 7.3.2 -PYTHON3_YOYO_MIGRATIONS_MD5 := bf1f70e0198a8dae5eb78e864d545456 +PYTHON3_YOYO_MIGRATIONS_VERSION := 8.2.0 +PYTHON3_YOYO_MIGRATIONS_MD5 := 0b99c4925b14c40fcd5fe4f7c0092b0d PYTHON3_YOYO_MIGRATIONS := yoyo-migrations-$(PYTHON3_YOYO_MIGRATIONS_VERSION) PYTHON3_YOYO_MIGRATIONS_SUFFIX := tar.gz PYTHON3_YOYO_MIGRATIONS_URL := $(call ptx/mirror-pypi, yoyo-migrations, $(PYTHON3_YOYO_MIGRATIONS).$(PYTHON3_YOYO_MIGRATIONS_SUFFIX)) -- 2.46.1
