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

Conversation

landrumb
Copy link
Contributor

@landrumb landrumb commented Oct 7, 2024

Was previously only checking directories in PATH, added cwd as a directory to search.

@@ -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]:
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants