diff options
| author | Franck Cuny <franckcuny@gmail.com> | 2016-08-04 11:45:44 -0700 |
|---|---|---|
| committer | Franck Cuny <franckcuny@gmail.com> | 2016-08-04 11:45:44 -0700 |
| commit | 585b48b6a605cb71ef99dd767880e1b7ee5bf24e (patch) | |
| tree | c65377350d12bd1e62e0bdd58458c1044541c27b /posts/2012-10-31-virtualenv-and-checkouts.org | |
| parent | Use Bullet list for the index. (diff) | |
| parent | Mass convert all posts from markdown to org. (diff) | |
| download | lumberjaph-585b48b6a605cb71ef99dd767880e1b7ee5bf24e.tar.gz | |
Merge branch 'convert-to-org'
Diffstat (limited to 'posts/2012-10-31-virtualenv-and-checkouts.org')
| -rw-r--r-- | posts/2012-10-31-virtualenv-and-checkouts.org | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/posts/2012-10-31-virtualenv-and-checkouts.org b/posts/2012-10-31-virtualenv-and-checkouts.org new file mode 100644 index 0000000..40e37cc --- /dev/null +++ b/posts/2012-10-31-virtualenv-and-checkouts.org @@ -0,0 +1,48 @@ +I've started to do some Clojure in my spare time. The default tool +adopted by the community to manage projects is +[[http://leiningen.org][leiningen]]. For those of you who don't know +what =lein= is, it's a tool to automate your Clojure project: it will +boostrap a new project, install the dependencies, and there's a plugin +mechanism to extend the default possibilities of the tool. + +One of the nice feature of the tool is the *checkouts* directory. From +the +[[https://github.com/technomancy/leiningen/blob/preview/doc/FAQ.md][FAQ]]: + +#+BEGIN_QUOTE + If you create a directory named checkouts in your project root and + symlink some other project roots into it, Leiningen will allow you to + hack on them in parallel. +#+END_QUOTE + +For Python projects at [[http://www.saymedia.com/careers][$work]] I use +[[http://virtualenvwrapper.readthedocs.org/en/latest/][virtualenvwrapper]] +to easily work on them without having to deal with conflicting +dependencies. When I need to change a library that is used by one of the +project, usually I go to the virtualenv directory and create a symlink +so it uses the one I'm editing. + +What I really want is a mechanism similar to =lein=, where I can have a +*checkouts/* directory inside the main project, where I can clone a +library or create a symlink. Since =virtualenvwrapper= provides a hook +mechanism, I wrote a small hook inside *~/.virtualenvs/postactivate*: + +#+BEGIN_SRC sh + #!/bin/bash + + # move to the directory of the project + proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') + proj_path=/home/vagrant/src/$proj_name + + cd $proj_path + + if [ -d checkouts ]; then + for ext in $(ls checkouts); do + export PYTHONPATH=proj_path/checkouts/$ext:$PYTHONPATH + done + fi +#+END_SRC + +Then, when I type =workon $project_name= in my shell, the environment is +activated, I'm moved to the right directory, and the library inside the +*checkouts/* directory are added to my *PYTHONPATH*. |
