{"action":"created","issue":{"url":"https://api.github.com/repos/conda-forge/staged-recipes/issues/1139","repository_url":"https://api.github.com/repos/conda-forge/staged-recipes","labels_url":"https://api.github.com/repos/conda-forge/staged-recipes/issues/1139/labels{/name}","comments_url":"https://api.github.com/repos/conda-forge/staged-recipes/issues/1139/comments","events_url":"https://api.github.com/repos/conda-forge/staged-recipes/issues/1139/events","html_url":"https://github.com/conda-forge/staged-recipes/issues/1139","id":167191016,"number":1139,"title":"Patch and add virtualenv","user":{"login":"kalefranz","id":1418419,"avatar_url":"https://avatars.githubusercontent.com/u/1418419?v=3","gravatar_id":"","url":"https://api.github.com/users/kalefranz","html_url":"https://github.com/kalefranz","followers_url":"https://api.github.com/users/kalefranz/followers","following_url":"https://api.github.com/users/kalefranz/following{/other_user}","gists_url":"https://api.github.com/users/kalefranz/gists{/gist_id}","starred_url":"https://api.github.com/users/kalefranz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalefranz/subscriptions","organizations_url":"https://api.github.com/users/kalefranz/orgs","repos_url":"https://api.github.com/users/kalefranz/repos","events_url":"https://api.github.com/users/kalefranz/events{/privacy}","received_events_url":"https://api.github.com/users/kalefranz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-23T16:13:53Z","updated_at":"2016-08-02T23:21:36Z","closed_at":null,"body":"Python's virtualenv has always been problematic with conda.  A detailed explanation of what usually happens is here: https://github.com/conda/conda/issues/1367#issuecomment-195596461\r\n\r\n> Let's say I have conda installed at `/conda` and so my python executable indicated by `which python` is at `/conda/bin/python`.  That means the shared library that python runs against at startup/load time is `/conda/lib/libpython2.7.dylib`.  Actually, it links against `../lib/libpython2.7.dylib`.  That is, the link path is relative.\r\n\r\n> Say I delete that file though... The OS X system loader has a library search path similar to the executable path `PATH`. By default on OS X, this library search path is `$HOME/lib:/usr/local/lib:/lib:/usr/lib` (see `man dyld`). So, when I delete `/conda/lib/libpython2.7.dylib`, then when `/conda/bin/python` runs, the loader will end up finding a `libpython2.7.dylib` at `/usr/lib/libpython2.7.dylib`.  The problem is, that library is compiled for the *system* python at `/usr/bin/python`, and thus we get that symbol error.\r\n\r\n> Now let's look at virtualenv.  Say I'm working on myproject located at `~/projects/myproject`, and in that directoryI create a virtualenv with `virtualenv ve --python=/conda/bin/python2.7`. Now after `source ~/projects/myproject/ve/bin/activate`, `which python` shows `~/projects/myproject/ve/bin/python`. What dynamic library is that python going to load against? Well, it would be `../lib/libpython2.7.dylib` or `~/projects/myproject/ve/lib/libpython2.7.dylib`. Except that file doesn't exist. (In fact, `~/projects/myproject/ve/lib/` will probably be completely empty.)  So the loader falls back to the library search path and finds `/usr/lib/libpython2.7.dylib`.\r\n\r\n> :boom: Symbol error.\r\n\r\nLater in that thread, @stuarteberg suggested a workaround hack https://github.com/conda/conda/issues/1367#issuecomment-217958169.\r\n\r\n> It turns out you can *pre-emptively* create the virtual environment (as an empty directory), and then symlink the missing file *before* running `virtualenv` (`libpython2.7.dylib`).  Then `virtualenv` works as expected.\r\n\r\n> In other words:\r\n\r\n> ```bash\r\n$ mkdir -p ve/lib\r\n$ cd ve/lib && ln -s /path/to/miniconda/lib/libpython2.7.dylib && cd -\r\n$ virtualenv ve\r\n```\r\n\r\n**Bottom line:** I would love the community's help to build virtualenv as a conda package, but patch the source code itself to work \"as expected.\"\r\n\r\nIf someone wants to start digging in, the entry point I'd suggest would be looking closely at the `install_python` function https://github.com/pypa/virtualenv/blob/4b707b87d43e7e0a945ad831e6ce483b45440149/virtualenv.py#L1089"},"comment":{"url":"https://api.github.com/repos/conda-forge/staged-recipes/issues/comments/237079758","html_url":"https://github.com/conda-forge/staged-recipes/issues/1139#issuecomment-237079758","issue_url":"https://api.github.com/repos/conda-forge/staged-recipes/issues/1139","id":237079758,"user":{"login":"kalefranz","id":1418419,"avatar_url":"https://avatars.githubusercontent.com/u/1418419?v=3","gravatar_id":"","url":"https://api.github.com/users/kalefranz","html_url":"https://github.com/kalefranz","followers_url":"https://api.github.com/users/kalefranz/followers","following_url":"https://api.github.com/users/kalefranz/following{/other_user}","gists_url":"https://api.github.com/users/kalefranz/gists{/gist_id}","starred_url":"https://api.github.com/users/kalefranz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalefranz/subscriptions","organizations_url":"https://api.github.com/users/kalefranz/orgs","repos_url":"https://api.github.com/users/kalefranz/repos","events_url":"https://api.github.com/users/kalefranz/events{/privacy}","received_events_url":"https://api.github.com/users/kalefranz/received_events","type":"User","site_admin":false},"created_at":"2016-08-02T23:21:36Z","updated_at":"2016-08-02T23:21:36Z","body":"Cross-linking: http://stackoverflow.com/questions/38594047/error-running-tests-with-conda-and-tox/38731951"}}
{"actor":{"display_login":"kalefranz"}}