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

Modified which() to support executables in workspace #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion pygrgl/clicmd/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def which(exe: str, required=False) -> Optional[str]:
except subprocess.CalledProcessError:
result = None
if result is None:
for p in sys.path:
for p in [*sys.path, os.getcwd()]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the challenge with this approach is that it will change which executables are used based on where the user is running the command from, which would probably lead to some very confusing behavior!

What about something like this?

THISDIR = os.path.dirname(os.path.realpath(__file__))
REPO_ROOT = os.path.join(THISDIR, "..", "..")

...

    for p in [*sys.path, REPO_ROOT]:
...

p = os.path.join(p, exe)
if os.path.isfile(p):
result = p
Expand Down
Loading