{"action":"created","issue":{"url":"https://api.github.com/repos/Homebrew/brew/issues/344","repository_url":"https://api.github.com/repos/Homebrew/brew","labels_url":"https://api.github.com/repos/Homebrew/brew/issues/344/labels{/name}","comments_url":"https://api.github.com/repos/Homebrew/brew/issues/344/comments","events_url":"https://api.github.com/repos/Homebrew/brew/issues/344/events","html_url":"https://github.com/Homebrew/brew/pull/344","id":159808209,"number":344,"title":"Add helper class for Python virtualenvs","user":{"login":"tdsmith","id":173889,"avatar_url":"https://avatars.githubusercontent.com/u/173889?v=3","gravatar_id":"","url":"https://api.github.com/users/tdsmith","html_url":"https://github.com/tdsmith","followers_url":"https://api.github.com/users/tdsmith/followers","following_url":"https://api.github.com/users/tdsmith/following{/other_user}","gists_url":"https://api.github.com/users/tdsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/tdsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdsmith/subscriptions","organizations_url":"https://api.github.com/users/tdsmith/orgs","repos_url":"https://api.github.com/users/tdsmith/repos","events_url":"https://api.github.com/users/tdsmith/events{/privacy}","received_events_url":"https://api.github.com/users/tdsmith/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Homebrew/brew/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2016-06-12T05:02:10Z","updated_at":"2016-06-20T14:55:24Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Homebrew/brew/pulls/344","html_url":"https://github.com/Homebrew/brew/pull/344","diff_url":"https://github.com/Homebrew/brew/pull/344.diff","patch_url":"https://github.com/Homebrew/brew/pull/344.patch"},"body":"- [x] Have you followed the guidelines in our [Contributing](https://github.com/Homebrew/brew/blob/master/.github/CONTRIBUTING.md) document?\r\n- [x] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/Homebrew/brew/pulls) for the same change?\r\n- [x] Have you added an explanation of what your changes do and why you'd like us to include them?\r\n- [x] Have you written new tests for your changes? [Here's an example](https://github.com/Homebrew/homebrew/pull/49031).\r\n- [x] Have you successfully run `brew tests` with your changes locally?\r\n\r\n-----\r\n\r\nThis PR proposes a new class for interacting with Python virtualenvs which enables a new way to write formulas for Python applications. \r\n\r\nThis approach resolves a few problems with the existing approach:\r\n* UX: Installing applications with this method yields [clearer and much less code](https://gist.github.com/tdsmith/cf2ef71adae2718075fef17bd9f6d938) than [the current method](https://github.com/Homebrew/homebrew-core/blob/master/Formula/jrnl.rb#L52-L65). If we trust pip to talk to pypi, we can pass a list of requirements instead of using resources, which means [even less code](https://gist.github.com/f9e83e9ce66fa19349ac711b1c170462).\r\n* Functional: In order that installing an application which uses Python packages does not disturb the global Python environment, we presently install packages and their dependencies into a Cellar-only prefix and write wrapper scripts that set PYTHONPATH to help Python find the installed tools. This generally works, with caveats. One is that namespace packages don't work very well, requiring formula authors to add `touch foo/\"__init__.py\"` manually. Another is PYTHONPATH propagates to child processes, which makes it difficult for a script installed with python2 to launch another script written in python3, since the Python 2 packages in PYTHONPATH may be incompatible. This has been a problem for e.g. Ansible. Virtualenvs do not have either problem.\r\n\r\nThis is functionally similar to [pipsi](https://github.com/mitsuhiko/pipsi). I expect this approach to work in general but I'll plan to ask some people in the Python packaging community for review.\r\n\r\nSome highlights for review:\r\n* Where is the right place to store the virtualenv package's URL and hash? Should we just package a tarball in the Homebrew repository?\r\n* Is the hack I'm using to make sure that pip is invoked with `Formula#system` appropriate? I don't really like separating Virtualenv#create! from Virtualenv#initialize but we need an opportunity to monkeypatch the singleton class. :p I think I like this better than teaching the Virtualenv class about formula objects because they don't otherwise interact. Should this happen in Language::Python or is it more logical to write a `Formula#python_virtualenv` method that handles the hackery?\r\n* Can we usefully define tests for this class? (An example would be helpful!)\r\n* Does this belong in the evolution process?\r\n\r\nSome work to do:\r\n* Make sure we do what we can to ensure that these don't break on revision or patch-level bumps for python3 virtualenvs -- python2 virtualenvs should be created against system Python and should be rock-solid\r\n\r\nThoughts welcome!"},"comment":{"url":"https://api.github.com/repos/Homebrew/brew/issues/comments/227166784","html_url":"https://github.com/Homebrew/brew/pull/344#issuecomment-227166784","issue_url":"https://api.github.com/repos/Homebrew/brew/issues/344","id":227166784,"user":{"login":"dstufft","id":145979,"avatar_url":"https://avatars.githubusercontent.com/u/145979?v=3","gravatar_id":"","url":"https://api.github.com/users/dstufft","html_url":"https://github.com/dstufft","followers_url":"https://api.github.com/users/dstufft/followers","following_url":"https://api.github.com/users/dstufft/following{/other_user}","gists_url":"https://api.github.com/users/dstufft/gists{/gist_id}","starred_url":"https://api.github.com/users/dstufft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dstufft/subscriptions","organizations_url":"https://api.github.com/users/dstufft/orgs","repos_url":"https://api.github.com/users/dstufft/repos","events_url":"https://api.github.com/users/dstufft/events{/privacy}","received_events_url":"https://api.github.com/users/dstufft/received_events","type":"User","site_admin":false},"created_at":"2016-06-20T14:55:24Z","updated_at":"2016-06-20T14:55:24Z","body":"> diffing installed scripts should be reliable since we're sending --no-deps to all of the pip invocations to force the dependency tree to be fixed in the formula.\r\n\r\nOh, are you doing a multi-stage install then to install the \"real\" thing separately from it's dependencies? Diffing scripts will work in that case, I just assumed you were doing a single shot and done."}}
{"actor":{"display_login":"dstufft"}}