mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Lars Pedersen <lapeddk@gmail.com>
To: ptxdist@pengutronix.de
Cc: Lars Pedersen <lapeddk@gmail.com>
Subject: [ptxdist] [PATCH 4/4] python3-yoyo-migrations: Version bump 7.3.2 -> 8.2.0
Date: Fri, 27 Sep 2024 13:38:30 +0200	[thread overview]
Message-ID: <20240927113830.415517-4-lapeddk@gmail.com> (raw)
In-Reply-To: <20240927113830.415517-1-lapeddk@gmail.com>

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 <lapeddk@gmail.com>
---
 ...-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 <laa@kamstrup.com>
+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 <laa@kamstrup.com>
+---
+ 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




      parent reply	other threads:[~2024-09-27 11:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27 11:38 [ptxdist] [PATCH 1/4] python3-zipp: version bump 3.1.0 -> 3.20.1 Lars Pedersen
2024-09-27 11:38 ` [ptxdist] [PATCH 2/4] host-python3-setuptools-scm: Version bump 4.1.2 -> 8.1.0 Lars Pedersen
2024-09-30  6:32   ` Michael Olbrich
2024-10-03  9:16     ` Lars Pedersen
2024-10-16 10:49       ` Michael Olbrich
2024-09-27 11:38 ` [ptxdist] [PATCH 3/4] python3-importlib-metadata: Version bump 1.7.0 -> 8.4.0 Lars Pedersen
2024-09-27 11:38 ` Lars Pedersen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240927113830.415517-4-lapeddk@gmail.com \
    --to=lapeddk@gmail.com \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox