-
-
Notifications
You must be signed in to change notification settings - Fork 776
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
Make install_xbuildenv work even if user doesn't source the venv #4518
base: main
Are you sure you want to change the base?
Conversation
This was written assuming that the user sourced the virtual environment explicitly, but it fails if they do `.venv/bin/pyodide venv .venv-pyodide`.
c83543a
to
184a6a6
Compare
Probably the added functions should be in |
The standard way to detect a venv is to check for |
Well the situation is that I want someone to be able to say I thought |
d6a93e4
to
2c9fad6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good to me.
@@ -363,3 +372,27 @@ def check_emscripten_version() -> None: | |||
raise RuntimeError( | |||
f"Incorrect Emscripten version {installed_version}. Need Emscripten version {needed_version}" | |||
) | |||
|
|||
|
|||
def calculate_venv_environment(env: _ENV | None = None) -> dict[str, str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have some tests for this.
Here's a recent example: https://github.com/astral-sh/uv/pull/1504/files. (Edit, that looks problematic, I like the way you did it better) |
Do you need to compute |
I guess we could also do {sys.executable} -m pyodide_cli ... instead of |
@henryiii I think I found the most to-the-point version of this that I can come up with: def _calculate_venv_path() -> str:
"""Make sure that the current executable is the first one on the path."""
path = os.environ["PATH"]
if shutil.which(Path(sys.executable).name) == sys.executable:
return path
# We aren't the first entry on the path. Add current executable directory to
# the front of path to correct this.
bin_dir = str(Path(sys.executable).parent)
return f"{bin_dir}:{path}" Though perhaps an even simpler option would be to unconditionally prepend |
9fc64a1
to
cde2636
Compare
for more information, see https://pre-commit.ci
Okay, just using |
Hmm well the last iteration seems particularly broken... |
This was written assuming that the user sourced the virtual environment explicitly, but it fails if they do
.venv/bin/pyodide venv .venv-pyodide
. There's probably some other places with similar problems.@henryiii does this look reasonable to you?