-
Notifications
You must be signed in to change notification settings - Fork 436
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
Use venv API to get venv paths #907
Conversation
However, some users might not have venv installed (see #853). Maybe we should also support virtualenv? |
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.
I have a gut feeling this may be problematic if the environment path contains non-ASCII characters, since not all terminals can output those characters (say if the encoding is not configured to UTF-8).
It’s probably more reliable to write the path to a temp file instead.
command_str = textwrap.dedent( | ||
f""" | ||
import venv | ||
root_paths = venv.EnvBuilder().ensure_directories(r"{str(root)}") |
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.
root_paths = venv.EnvBuilder().ensure_directories(r"{str(root)}") | |
root_paths = venv.EnvBuilder().ensure_directories({root}) |
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.
Probably raw string should be used? (For handling paths on Windows)
Does virtualenv provide an interface to introspect an environment outside of it? Because an environment created by virtualenv does not have access to the virtualenv module. |
Lines 130 to 137 in 4c0f289
The output is just printed to the terminal in this function and it seems fine? |
I think no. Or probably we can keep this for virtualenv users? if WINDOWS:
def get_venv_paths(root: Path) -> Tuple[Path, Path]:
bin_path = root / "Scripts"
python_path = bin_path / "python.exe"
return bin_path, python_path
else:
def get_venv_paths(root: Path) -> Tuple[Path, Path]:
bin_path = root / "bin"
python_path = bin_path / "python"
return bin_path, python_path |
If we need to keep the |
Yes, for example python-poetry/poetry#4467 and python-poetry/poetry#3713. |
I will open another PR for this. (#908) |
docs/changelog.md
Summary of changes
Use venv API to get venv paths.
Closes #701
Test plan
Tested by running