@@ 31,7 31,7 @@ import inspect
import types
import textwrap
-import pkg_resources
+from importlib.resources import files
import sqlparse
from yoyo import exceptions
@@ 133,7 133,6 @@ def read_sql_migration(
class Migration(object):
-
__all_migrations: t.Dict[str, "Migration"] = {}
def __init__(self, id, path, source_dir):
@@ 235,7 234,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 278,6 @@ class PostApplyHookMigration(Migration):
class StepBase(object):
-
id = None
def __repr__(self):
@@ 359,7 356,6 @@ class MigrationStep(StepBase):
"""
def __init__(self, id, apply, rollback):
-
self.id = id
self._rollback = rollback
self._apply = apply
@@ 455,16 451,17 @@ def _expand_sources(sources) -> t.Iterab
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 = files(package_name).joinpath(resource_dir)
+ if pkg_files.is_dir():
+ paths = [
+ str(file)
+ for file in sorted(pkg_files.iterdir())
+ if _is_migration_file(file.name)
+ ]
+ yield (source, paths)
+ except FileNotFoundError:
+ continue
else:
for directory in glob(source):
paths = [