diff --git a/bench/app.py b/bench/app.py index bb23f70c..f00f8acc 100755 --- a/bench/app.py +++ b/bench/app.py @@ -11,6 +11,7 @@ import typing from collections import OrderedDict from datetime import date from urllib.parse import urlparse +import os # imports - third party imports import click @@ -27,6 +28,7 @@ from bench.utils import ( is_valid_frappe_branch, log, run_frappe_cmd, + is_frappe_app, ) from bench.utils.bench import ( build_assets, @@ -66,6 +68,8 @@ class AppMeta: self.from_apps = False self.is_url = False self.branch = branch + self.app_name = None + self.git_repo = None self.mount_path = os.path.abspath( os.path.join(urlparse(self.name).netloc, urlparse(self.name).path) ) @@ -94,6 +98,13 @@ class AppMeta: else: self._setup_details_from_name_tag() + if self.git_repo: + self.app_name = os.path.basename( + os.path.normpath(self.git_repo.working_tree_dir) + ) + else: + self.app_name = self.repo + def _setup_details_from_mounted_disk(self): # If app is a git repo self.git_repo = Repo(self.mount_path) @@ -186,7 +197,7 @@ class App(AppMeta): from bench.utils.app import get_app_name verbose = bench.cli.verbose or verbose - app_name = get_app_name(self.bench.name, self.repo) + app_name = get_app_name(self.bench.name, self.app_name) if not resolved and self.repo != "frappe" and not ignore_resolution: click.secho( f"Ignoring dependencies of {self.name}. To install dependencies use --resolve-deps", diff --git a/bench/bench.py b/bench/bench.py index 9d8d23de..c07fd4f4 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -413,7 +413,7 @@ class BenchSetup(Base): for app in apps: path_to_app = os.path.join(self.bench.name, "apps", app) - App(path_to_app, bench=self.bench, to_clone=False).install( + app = App(path_to_app, bench=self.bench, to_clone=False).install( skip_assets=True, restart_bench=False, ignore_resolution=True ) diff --git a/bench/utils/app.py b/bench/utils/app.py index d07422e1..158fdf96 100644 --- a/bench/utils/app.py +++ b/bench/utils/app.py @@ -210,25 +210,25 @@ def get_remote(app, bench_path="."): return contents.splitlines()[0].split()[0] -def get_app_name(bench_path, repo_name): +def get_app_name(bench_path, folder_name): app_name = None apps_path = os.path.join(os.path.abspath(bench_path), "apps") - config_path = os.path.join(apps_path, repo_name, "setup.cfg") + config_path = os.path.join(apps_path, folder_name, "setup.cfg") if os.path.exists(config_path): config = read_configuration(config_path) app_name = config.get("metadata", {}).get("name") if not app_name: # retrieve app name from setup.py as fallback - app_path = os.path.join(apps_path, repo_name, "setup.py") + app_path = os.path.join(apps_path, folder_name, "setup.py") with open(app_path, "rb") as f: app_name = re.search(r'name\s*=\s*[\'"](.*)[\'"]', f.read().decode("utf-8")).group(1) - if app_name and repo_name != app_name: - os.rename(os.path.join(apps_path, repo_name), os.path.join(apps_path, app_name)) + if app_name and folder_name != app_name: + os.rename(os.path.join(apps_path, folder_name), os.path.join(apps_path, app_name)) return app_name - return repo_name + return folder_name def check_existing_dir(bench_path, repo_name): cloned_path = os.path.join(bench_path, "apps", repo_name)