-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Create environment using venv
or conda
#19848
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
Create environment using venv
or conda
#19848
Conversation
389156c
to
303d763
Compare
8fa2d0d
to
7e38079
Compare
@@ -549,3 +549,82 @@ export namespace SwitchToDefaultLS { | |||
"The Microsoft Python Language Server has reached end of life. Your language server has been set to the default for Python in VS Code, Pylance.\n\nIf you'd like to change your language server, you can learn about how to do so [here](https://devblogs.microsoft.com/python/python-in-visual-studio-code-may-2021-release/#configuring-your-language-server).\n\nRead Pylance's license [here](https://marketplace.visualstudio.com/items/ms-python.vscode-pylance/license).", | |||
); | |||
} | |||
|
|||
export namespace CreateEnv { |
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.
@luabud Strings here need your input.
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.
Neatly done, most comments are similar related to wording.
Btw, are we not doing the "show log" hyperlink? @luabud
|
||
def get_venv_path(name: str) -> str: | ||
if sys.platform == "win32": | ||
return os.fspath(CWD / name / "Scripts" / "python.exe") |
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.
Any documentation for this assumption?
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.
This is the same assumption we have in the extension. The docs here describe the "Scripts" or "bin" : https://docs.python.org/3/library/venv.html#creating-virtual-environments
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.
Gotcha.
Maybe still add a one line comment linking the doc? I'm asking because it looks like we actually don't use that assumption in discovery and identification:
vscode-python/src/client/pythonEnvironments/common/environmentManagers/simplevirtualenvs.ts
Lines 13 to 31 in e26a1ed
function getPyvenvConfigPathsFrom(interpreterPath: string): string[] { | |
const pyvenvConfigFile = 'pyvenv.cfg'; | |
// Check if the pyvenv.cfg file is in the parent directory relative to the interpreter. | |
// env | |
// |__ pyvenv.cfg <--- check if this file exists | |
// |__ bin or Scripts | |
// |__ python <--- interpreterPath | |
const venvPath1 = path.join(path.dirname(path.dirname(interpreterPath)), pyvenvConfigFile); | |
// Check if the pyvenv.cfg file is in the directory as the interpreter. | |
// env | |
// |__ pyvenv.cfg <--- check if this file exists | |
// |__ python <--- interpreterPath | |
const venvPath2 = path.join(path.dirname(interpreterPath), pyvenvConfigFile); | |
// The paths are ordered in the most common to least common | |
return [venvPath1, venvPath2]; | |
} |
and this is the first time.
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.
The purpose of the code here and in the discovery is different. In discovery we are tyring to find the .cfg
file. in the create env, we created the env, so we know what type it is and where the python.exe will be. I can add the docs nonetheless.
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.
Yes, I think the comment is misleading:
// envFolder
// |__ pyvenv.cfg <--- check if this file exists
// |__ python <--- interpreterPath
It seems to indicate python
binary can be directly under the env folder.
src/client/pythonEnvironments/creation/provider/condaCreationProvider.ts
Outdated
Show resolved
Hide resolved
src/client/pythonEnvironments/creation/provider/condaCreationProvider.ts
Outdated
Show resolved
Hide resolved
src/client/pythonEnvironments/creation/provider/condaCreationProvider.ts
Show resolved
Hide resolved
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.
Thanks for addressing, LGTM. I still think we could do the hyperlink to log channel #19848 (review) given it so nicely shows the command progress, otherwise looks good.
I will definitely add that in an update. |
Closes #19676
Closes #19850