From 8db23dd23028d83b625cd55d237aa4d5f0caee2b Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 23 Feb 2024 21:07:27 +0530 Subject: [PATCH 1/3] perf: Avoid use of glob for fetching python executable glob on env/**/bin is slowest operation in terms of overhead on CLI. --- bench/utils/bench.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bench/utils/bench.py b/bench/utils/bench.py index 701e37804..9eba296a7 100644 --- a/bench/utils/bench.py +++ b/bench/utils/bench.py @@ -32,8 +32,13 @@ @lru_cache(maxsize=None) def get_env_cmd(cmd: str, bench_path: str = ".") -> str: - # this supports envs' generated by patched virtualenv or venv (which may cause an extra 'local' folder to be created) + exact_location = os.path.abspath( + os.path.join(bench_path, "env", "bin", cmd.strip("*")) + ) + if os.path.exists(exact_location): + return exact_location + # this supports envs' generated by patched virtualenv or venv (which may cause an extra 'local' folder to be created) existing_python_bins = glob( os.path.join(bench_path, "env", "**", "bin", cmd), recursive=True ) @@ -41,8 +46,7 @@ def get_env_cmd(cmd: str, bench_path: str = ".") -> str: if existing_python_bins: return os.path.abspath(existing_python_bins[0]) - cmd = cmd.strip("*") - return os.path.abspath(os.path.join(bench_path, "env", "bin", cmd)) + return exact_location def get_venv_path(verbose=False, python="python3"): From 014358d02a1f72e3741a67c6ff566df40cb044b6 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 23 Feb 2024 21:09:55 +0530 Subject: [PATCH 2/3] fix!: Unconditionally assume frappe_cmd --- bench/cli.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bench/cli.py b/bench/cli.py index 215d47cd1..d7a9b4cc4 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -132,10 +132,7 @@ def cli(): bench_command() if in_bench: - if cmd_from_sys in get_frappe_commands(): - frappe_cmd() - else: - app_cmd() + frappe_cmd() bench_command() From c1bf94d12a874a2d2f5c5d15a1075654b1ed8202 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 24 Feb 2024 06:40:48 +0000 Subject: [PATCH 3/3] chore(release): Bumped to Version 5.22.3 ## [5.22.3](https://github.com/frappe/bench/compare/v5.22.2...v5.22.3) (2024-02-24) ### Performance Improvements * Avoid use of glob for fetching python executable ([8db23dd](https://github.com/frappe/bench/commit/8db23dd23028d83b625cd55d237aa4d5f0caee2b)) --- bench/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/__init__.py b/bench/__init__.py index 45dcd8143..431b5a4e7 100644 --- a/bench/__init__.py +++ b/bench/__init__.py @@ -1,4 +1,4 @@ -VERSION = "5.22.2" +VERSION = "5.22.3" PROJECT_NAME = "frappe-bench" FRAPPE_VERSION = None current_path = None