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

Support pipenv #404

Closed
brettcannon opened this issue Dec 12, 2017 · 30 comments · Fixed by #888
Closed

Support pipenv #404

brettcannon opened this issue Dec 12, 2017 · 30 comments · Fixed by #888
Assignees
Labels
feature-request Request for new features or functionality
Milestone

Comments

@brettcannon
Copy link
Member

Not quite sure how this would look (use pipenv whenever we prompt users to install something on their behalf?).

Fork of #301

@daisylb
Copy link

daisylb commented Dec 19, 2017

Just as a suggestion, it would be good if vsc could detect virtualenv that Pipenv creates, and use that for completion etc.

If it helps, pipenv --venv, prints the path to the virtualenv root, and pipenv --py prints the path to the Python binary. The former will exit 1 if it's not inside a project that's been set up with Pipenv, but the latter always exits 0 unfortunately.

@naphta
Copy link

naphta commented Jan 11, 2018

It'd vastly improve my workflow if VSCode automatically detected the pipenv virtual environment and prompted you to install packages inside of the virtual environment via pipenv - to build on that it should also be able to let you choose to install into dev packages or not too.

@brettcannon
Copy link
Member Author

It looks like @kennethreitz is developing a library that could potentially be useful (although if we have to work through TypeScript I'm not sure how much it would buy us to have a Python library versus the CLI): https://github.com/kennethreitz/pipenvlib

@MikhailArkhipov
Copy link

This basically works for me. The only think I needed to to was to add path to pipenv virtual environments to the workspace settings

image

@DonJayamanne
Copy link

DonJayamanne commented Feb 21, 2018

@MikhailArkhipov
All you need to do is modify GlobalVirtualEnvironmentsSearchPathProvider
to tell it to search the .virtualenvs in your home directory.

Currently we don't have any search directories for Windows, its only for Unix systems.

@MikhailArkhipov
Copy link

Yeah, working on it

@brettcannon
Copy link
Member Author

Also realize that with pipenv there is a single virtual environment per directory, so we could automatically select it if found as appropriate.

@ryanhiebert
Copy link

I would really appreciate this feature. In particular, to allow it to autodiscover the python executable, pip executable, and PATH for my virtualenv, so that I don't need to worry about launching vscode via pipenv in order to get it to use a project-specific version of the linter I'm using, etc.

@repentsinner
Copy link

@ryanhiebert if you add a user or workspace setting to point to your .venv python path, VS Code will pick up your linter, interpreter, etc on it's own - you don't need to launch it from within pipenv.

Something like:

{
"python.pythonPath": "${workspaceRoot}/.venv/bin/python",
}

@MikhailArkhipov
Copy link

The feature amounts to this:

  1. Module installation via pipenv instead of pip so the lock file gets properly updated
  2. Interpreters cannot be selected - automatic pick of what the workspace is configured with (looks like there can only be one?)
  3. Option to turn off automatic interpreter identification and allow manual selection? Perhaps for testing with different versions?

Anything else?

@brettcannon
Copy link
Member Author

@MikhailArkhipov

  1. We should also make sure to do it as a dev dependency
  2. Yep, only one interpreter per directory (why pipenv is only for app development and not library development)
  3. I would assume automatic selection would be just like what we do for virtual environments so it shouldn't be anything special (don't we auto-select if python.pythonPath is unset?)

@DonJayamanne
Copy link

DonJayamanne commented Feb 22, 2018

don't we auto-select if python.pythonPath is unset

Yes

assume automatic selection would be just like what we do for virtual environments so it

Yes. It should. I haven't tested this though.
@MikhailArkhipov

  • Please create a workspace
  • Ensure pythonpath is not set in your settings file
  • Ensure you have a pyenv environment in your workspace directory
  • Open a python file in the above workspace (activate the extension)
  • The extension should identify the above environment and set it in settings.json

@MikhailArkhipov
Copy link

MikhailArkhipov commented Feb 22, 2018

@brettcannon, @DonJayamanne - yes, this is exaclty what I have atm :-)

Basically pyenv is checked first and always wins. Working on auto-set and testing

image

@DonJayamanne
Copy link

Basically pyenv is checked first and always wins

@MikhailArkhipov
Does the extension automatically update settings.json without you having to do anything?

@MikhailArkhipov
Copy link

It is a good question. Currently one can still override interpreter path manually in settings. If nothing is there then pipenv is used. This may come useful if one wants to try different interpreter without actually removing or modifying pipenv environment.

@naphta
Copy link

naphta commented Feb 23, 2018

@MikhailArkhipov Maybe a flag for that override right now I have my interpreter path set to a default which if I was in a pipenv project I'd want overridden to use the pipenv interpreter.

It'd also be quite neat if we had a command for installing pipenv packages. e.g. cmd+shift+p <dev yes/no>

@ryanhiebert
Copy link

if you add a user or workspace setting to point to your .venv python path, VS Code will pick up your linter, interpreter, etc on it's own - you don't need to launch it from within pipenv.

Thanks for this, @repentsinner . I had assumed that the process PATH would need to be updated, I didn't expect that just setting the interpreter would be sufficient. I guess it uses the pythonpath instead, which is cool. It's just what I needed.

@brettcannon
Copy link
Member Author

@naphta package installation would be a separate issue as we would have to solve that for pip and conda as well.

@guaguanco
Copy link

I updated to 2018.2.0 but my Pipfiles are not picked up (I also tried to rename it to pipfile). In the debug console I don't see any error/warning (apart the missing packages due to the fact that environment is not activated) and the select interpreter command is listing only the system pythons.

I'm on OSX Sierra with vscode 1.21, pipenv installed via homebrew

Can I do anything to help tracking down the problem?

--sergio

@brot
Copy link

brot commented Mar 9, 2018

Same for me. I read the announcement https://blogs.msdn.microsoft.com/pythonengineering/2018/03/08/python-in-visual-studio-code-feb-2018-release/, but the detection of the pipenv venv does not work. Tried already with three projects/directories using pipenv

@brettcannon
Copy link
Member Author

@guaguanco not sure what you mean by "Pipfiles are not picked up"?

@brot please open a new issue as we need details about your setup that are requested in the new issue template.

@naphta
Copy link

naphta commented Mar 9, 2018

Getting a similar issue to @guaguanco and @brot.

Open up VSCode in a folder which has a Pipfile and nothing is being detected. I didn't get prompted to upgrade the Python plugin after I reinstalled (not sure if that's now managed in the regular upgrade process now)

I'm also using pipenv on mac installed via homebrew. (available in $PATH though)

Version:
Version 1.22.0-insider (1.22.0-insider) 3817c899cae312e0e989da8bfbc61308cfbf45f1

@brettcannon
Copy link
Member Author

@brot @guaguanco @naphta We think someone found the bug and we are working on a 2018.2.1 release as we speak. Assuming the fix passes our testing it should be out in less than an hour.

@brettcannon
Copy link
Member Author

2018.2.1 is now live and should (hopefully) fix this issue (it was a case-sensitivity bug). Sorry about missing this in our testing 😞

@brettcannon
Copy link
Member Author

And we have opened #1007 to make sure this specific bug isn't a problem in the future.

@frostming
Copy link

@brettcannon The issue seems still exists on 2018.2.1. I am using pipenv on Mac, installed from pip. The project has a Pipfile inside.

image

@DonJayamanne
Copy link

@frostming please could you create a separate Issue.

@eomeara
Copy link

eomeara commented Mar 12, 2018

Same problem as @frostming Also on a mac.

@DonJayamanne
Copy link

@frostming @eomeara please could you create a separate Issue.

@joshfriend
Copy link

can someone just lock this issue? we are definitely past the point of having any relevant conversation happen here.

@microsoft microsoft locked as resolved and limited conversation to collaborators Mar 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.