diff options
| author | Martin Afanasjew | 2016-08-02 22:37:15 +0200 | 
|---|---|---|
| committer | Tim D. Smith | 2016-08-02 13:37:15 -0700 | 
| commit | b77a695b7a0c9094d49993d26921a47da919364d (patch) | |
| tree | 7959aa2ad66ad1efbebba94161acfcb99268d5fc /Library/Homebrew/language/python.rb | |
| parent | a6033529cfdcfc6458aaa83a0bc9c4c141c60f96 (diff) | |
| download | brew-b77a695b7a0c9094d49993d26921a47da919364d.tar.bz2 | |
python: tweak script linking in virtualenv (#613)
* python: tweak script linking in virtualenv
Instead of making the formula author use a slightly awkward block like
  venv.link_scripts(bin) { venv.pip_install buildpath }
avoid exposing this implementation detail and offer the more familiar:
  venv.pip_install buildpath, :link_scripts => bin
* Add non-block form and use instead of recursion
* Update 'pip_install' documentation
* Remove obsolete 'link_scripts'
* Add test for 'pip_install' with linking scripts
Also drop no longer relevant (and broken) `link_scripts` test, that
served as a template for the new test.
* Restore compatibility with Ruby 1.8.7
* Replace option hash with 'pip_install_and_link'
* Avoid confusing 'Object#tap' and fix silly bug
* Avoid side effects in mock object parameter check
* Simplify argument check (no need for a block)
Diffstat (limited to 'Library/Homebrew/language/python.rb')
| -rw-r--r-- | Library/Homebrew/language/python.rb | 22 | 
1 files changed, 11 insertions, 11 deletions
| diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index 4249a911c..68e6f86ca 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -145,7 +145,7 @@ module Language        def virtualenv_install_with_resources          venv = virtualenv_create(libexec)          venv.pip_install resources -        venv.link_scripts(bin) { venv.pip_install buildpath } +        venv.pip_install_and_link buildpath          venv        end @@ -218,18 +218,18 @@ module Language            end          end -        # Compares the venv bin directory before and after executing a block, -        # and symlinks any new scripts into `destination`. -        # Use like: venv.link_scripts(bin) { venv.pip_install my_package } -        # @param destination [Pathname, String] Destination into which new -        #   scripts should be linked. -        # @return [void] -        def link_scripts(destination) +        # Installs packages represented by `targets` into the virtualenv, but +        #   unlike {#pip_install} also links new scripts to {Formula#bin}. +        # @param (see #pip_install) +        # @return (see #pip_install) +        def pip_install_and_link(targets)            bin_before = Dir[@venv_root/"bin/*"].to_set -          yield + +          pip_install(targets) +            bin_after = Dir[@venv_root/"bin/*"].to_set -          destination = Pathname.new(destination) -          destination.install_symlink((bin_after - bin_before).to_a) +          bin_to_link = (bin_after - bin_before).to_a +          @formula.bin.install_symlink(bin_to_link)          end          private | 
