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

perf: faster cli #1542

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions bench/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
10 changes: 7 additions & 3 deletions bench/utils/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,21 @@

@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
)

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"):
Expand Down
Loading