Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] replace pkg_resources with importlib.metadata #68

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions oca_port/migrate_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import tempfile
import urllib.parse
import pkg_resources
from importlib import metadata

import click

Expand Down Expand Up @@ -154,10 +154,12 @@ def run(self):
with tempfile.TemporaryDirectory() as patches_dir:
self._generate_patches(patches_dir)
self._apply_patches(patches_dir)
if pkg_resources.get_distribution("odoo-module-migrator") is None:
g.run_pre_commit(self.app.repo, self.app.addon)
else:

try:
metadata.metadata("odoo-module-migrator")
adapted = self._apply_code_pattern()
except metadata.PackageNotFoundError:
g.run_pre_commit(self.app.repo, self.app.addon)
# Check if the addon has commits that update neighboring addons to
# make it work properly
PortAddonPullRequest(self.app, push_branch=False).run()
Expand Down Expand Up @@ -296,3 +298,4 @@ def _apply_code_pattern(self):
return True
except KeyboardInterrupt:
pass
return False
Loading