pghilardi / atom-python-virtualenv

Python virtualenv support for Atom
MIT License
16 stars 6 forks source link

How to activate Virtual Environments in the root of the project #11

Closed RAbraham closed 7 years ago

RAbraham commented 7 years ago

Hi, I was very happy to see this plugin. Thanks!

I don't use virtualenvwrapper. I just create a venv folder in the root of my project. How do I select that virtual environment(and not virtual environments in $WORKON_HOME as the select feature shows)?

kekearif commented 7 years ago

I'm having issues too. Added my project folder to atom. I copied my previously created virtualenv folder titled default. This is in the root. I now try to select this by typing the name default and get "No matches found". What am I doing wrong?

pghilardi commented 7 years ago

Hi @RAbraham and @kekearif ,

The behavior described is a bug. I am able to reproduce the bug here and I am working to fix it in the next few days.

Thanks,

pghilardi commented 7 years ago

@RAbraham and @kekearif ,

I have fixed the bug and now virtualenvs are working inside the HOME folder. By default the plug-in is configured to get virtualenvs using the virtualenvwrapper, but you can change this on settings:

settings

Let me know if your problems were solved with my change.

P.S: Update to the latest version of the plug-in!

RAbraham commented 7 years ago

Hi Pedro, I may have not been clear. My workflow is not to use a single folder(HOME) to manage my virtual environments. I create my virtual environment in the project folder :). So if I have a project folder called ~/myproject, then I create a venv environment inside that project i.e. ~/myproject/venv. In another IDE, I am able to set project specific settings and one of the settings is a project interpreter which I point to ~/myproject/venv/bin/python and it automatically loads my virtual environment into the IDE. This is something I prefer doing(I work with AWS Lambda and I have to deploy the virtual environment with my scripts which need to run on all the dev machines. It is just easy for my scripts to assume that the virtualenv folder is within the project directory).

pghilardi commented 7 years ago

@RAbraham ,

I am working to support this kind of set up. :D I will expose some variables like $PROJECT and $PROJECT_NAME to be able to configure the locations to search for virtual envs, based in the current project opened.

I will return to you soon with a solution. I will keep you informed in this thread.

RAbraham commented 7 years ago

Appreciate the effort you are putting into this. 👍 .

pghilardi commented 7 years ago

I am working in the auto-discovery branch to support this workflow!

RAbraham commented 7 years ago

auto-discovery sounds cooler than what I wanted. A question, what if I have multiple Python projects open in the IDE and they have different/conflicting virtual environments? How does auto-discovery work in this case?

Just to note, if auto-discovery is complex, I would be very happy with 'manual-discovery' as well i.e. like I mentioned above, when I set the project specific settings, I manually specify the virtual environment path(or as in my current IDE, specify a path to the python executable in my_env/bin)

pghilardi commented 7 years ago

@RAbraham,

I also think so. Therefore I will integrate first the "manual" solution and then I will integrate the final one. I am planning to integrate the first solution as soon as possible.

RAbraham commented 7 years ago

Looking forward to it!

pghilardi commented 7 years ago

Hey @RAbraham and @kekearif ,

I have updated the plug-in for the version 0.9.0 and now I am supporting manual input of virtual envs :) The plug-in searches for envs inside the virtualenvwrapper (usually $HOME/.virtualenvs), inside the $HOME and allows to specify additional virtual envs on settings.

Let me know if this solved your problems!

RAbraham commented 7 years ago

Hi Pedro, I am getting a few errors which I'm unable to reproduce. When I open up Atom, put the project path in settings(without the venv), do a select virtualenv, it shows the project (but not the venv). I then add the specify the venv folder as well in the settings, it then shows the venv when I do a select virtualenv(but it also shows the project home folder as well). I can then select my venv folder and it works. Also, when I play with it, I get a lot of path.join errors, one of which I have created a ticket for(https://github.com/pghilardi/atom-python-virtualenv/issues/14)

I may not be able to give more feedback as I am trying another IDE for the moment but thank you for your prompt response!

pghilardi commented 7 years ago

@RAbraham ,

I have fixed the issues related to paths.

Thanks for all the support and the feedback and sorry for the late reply!

davidlever commented 4 years ago

Hi,

I am trying to select a particular virtual environment using your plugin (0.9.7) but when I input the the project folder manually as C:/Users/name/Documents/project, where the virtualenv is in the root of this project folder, the virtualenv does not show up as an option. How is this possible?

Thank you!