Comments (8)
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.
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.
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.
@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.
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.
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.
@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.
If this still remains an issue, please reopen to discuss.
from pyladies.
Related Issues (20)
- PyLadies Website 2.0 Migration HOT 4
- Update the instructions on how to build the pyladies website locally HOT 1
- Setup Netlify for PyLadies website HOT 7
- CircleCI Deploy Broken: CircleCI Unable to Find Identity File HOT 1
- PyLadies website: Clean up the deploy setup HOT 1
- PyLadies website: Clean up the "Forum" page HOT 4
- Request to Join Project Tech & Infra: ks--ks HOT 4
- dublin.pyladies.com returns a Heroku Application error page HOT 1
- Adjust social media, netlify badge in footer & add social page to website HOT 4
- Add HTTPS cert on Netlify HOT 1
- Fix broken link in the "Announcement for Registering PyLadies Members" post on the website. HOT 2
- Moving old website repos from monolith HOT 1
- Request to Join Project Tech & Infra: <rutujak24> HOT 1
- Replace the "sponsor" email address
- Get Swag Button redirects to https://pyladies.spreadshirt.com/ which is currently unavailable HOT 2
- Blog URL is not working HOT 3
- Request to Join Project Tech & Infra: maud-lv HOT 1
- Create a TXT record for Pyladies Tokyo HOT 2
- Org maintenance HOT 9
- Hopefully the final attempt to migrate the PyLadies static website HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyladies.