Giter Club home page Giter Club logo

Comments (8)

econchick avatar econchick commented on June 19, 2024

wat?! We're not supposed to have the virtualenv in the same dir as the cloned code?!? I know that says that in the README but is that really best practice?

from pyladies.

merwok avatar merwok commented on June 19, 2024

It is, see how virtualenvwrapper works. What virtualenv does is actually not complicated, but many people are confused by it, and imo this confusion leads to non-optimal patterns such as creating the venv alongside the source code. I’ll expand more later : )

from pyladies.

econchick avatar econchick commented on June 19, 2024

So I had the realization just now that because of the way that I originally setup virtualenv and wrapper, it sets up the virtualenv elsewhere, in ~/.venv

But yeah, you're right that the executables should not be where your git repo is. We don't want to see the bin/ dir in there.

If you set up virtualenvwrapper the way that it shows you in the docs (where the actual env is in ~/.venv or some other directory), then it doesn't matter which order you do it (git clone then mkvirtualenv or vis-versa).

I was just confused because I always git cloned then mkvirtualenv not even realizing that the actual venv is elsewhere. Don't judge...it's Friday.

from pyladies.

svaksha avatar svaksha commented on June 19, 2024

@merwok , I should have been explicit. Here is how I do it:
1.] cd .virtualenvs/
2.] mkvirtualenv --python=/usr/bin/python3.3 pyladiesCom --no-site-packages (# assuming the repo supports 3.x.)
3.] source pyladiesCom/bin/activate
4.] workon pyladiesCom (# note the foldername is different and this is where the /bin, /lib and /include folders are located as I only clone the "pyladies" git repo in the next steps.)
5.] cd pyladiesCom/
6.] git clone [email protected]:pyladies/pyladies.git

Currently, this is how the 'pyladies' repo looks:
/.virtualenvs/pyladiesCom/pyladies$ ls
atl boston dc LICENSE mtl pdx requirements.txt sf tunisia vienna
berlin CONTRIBUTING.md helsinki london nyc README.md sandiego TODOs.md tw www

This method seems cleaner and keeps my virtualenv packages and dependencies away from my code repo. Feel free to let me know if any steps need to be changed, and if you think its ok, I'm happy to include these steps in the README file. Thanks.

from pyladies.

merwok avatar merwok commented on June 19, 2024

The steps you describe confuse me a little. First, you don’t need to cd and source activate: mkvirtualenv will work in the defined $WORKON_HOME directory without you needing to cd there.

Second, workon merely sources activates and runs post-activate hooks, so if you run it after step 3 it does nothing.

Your repository does not have to (and IMO should not) be located in your virtualenv. Venvs are throw-away.

I’m busy now but will write more later with links to the venv and venvwrapper docs.

from pyladies.

svaksha avatar svaksha commented on June 19, 2024

On Mon, Aug 19, 2013 at 5:00 PM, Éric Araujo [email protected] wrote:

First, you don’t need to cd and source activate: mkvirtualenv will work in the defined $WORKON_HOME directory without you needing to cd there.

True. Fwiw, I use the 'mkvirtualenv' command only while creating a new
venv for cloning a repo. For activating an existing repo, its
'virtualenv'

Second, workon merely sources activates and runs post-activate hooks, so if you run it after step 3 it does nothing.
Ok.

Your repository does not have to (and IMO should not) be located in your virtualenv. Venvs are throw-away.

While I agree that venv's are throw-away, care to explain why the repo
should not be located inside the env - fwiw, the repo is inside
another directory (note the path: /.virtualenvs/pyladiesCom/pyladies
<-- this is where the pyladies repo sits, whilst /pyladiesCom contains
the /bin and /lib

svaksha ॥ स्वक्ष

from pyladies.

econchick avatar econchick commented on June 19, 2024

@svaksha it's bad to have executables in your git repo.

Here's my layout:

/Users/lynnroot/.virtualenvs/pyladies.com
/Users/lynnroot/Dev/pyladies.com

Whenever I am about to start a project, I am within my ~/Dev directory, and I clone a project, e.g. git clone https://github.com/pyladies/a-new-project which starts a new directory inside ~/Dev, or create a new directory my-new-project and just do git init.

Then I make or turn on the virtual env. The mkvirtualenv and workon <env_name> is tied to the $WORKON directory, and the executables within the env directory. When you downloaded and installed the virtualenvwrapper package, it tells you to export the $WORKON dir and source it. So for instance, when I'm working on PyLadies, I do workon pyladies.com. Now I have access to the libraries and python version I want (rather than the default system python and the libraries that are installed globally).

There's actually no physical relation between the $WORKON/env dir and the ~/Dev/pyladies.com dir....yet. I just happened to run the workon pyladies.com command in ~/Dev/pyladies.com. Theoretically, if I wanted to use the same libraries and same python version on another project, for whatever reason, I can leave the virtualenv "on", and move to another directory, like ~/Dev/SQLadies.

If I want to map a virtualenv to a project directory, I can, within the desired project dir, do setvirtualenvproject. Or from the start, pair the virtualenv and the project directory with mkproject. Doug's docs here [http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html#mkproject] show there's a clear difference between envs and project dirs.

from pyladies.

econchick avatar econchick commented on June 19, 2024

If this still remains an issue, please reopen to discuss.

from pyladies.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.