commit
8615b7495e
6 changed files with 64 additions and 0 deletions
15
docs/buckets/pip.md
Normal file
15
docs/buckets/pip.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# [pip](https://pip.pypa.io/)
|
||||
|
||||
Compatible with probably any type of linux guest distro, will hook into pip's
|
||||
http and wheels cache directory under `$HOME/.cache/pip/http` and `$HOME/.cache/pip/wheels` as
|
||||
the default SSH user (usually `vagrant`) on your guest.
|
||||
|
||||
To manually enable it:
|
||||
|
||||
```ruby
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = 'some-box-with-pip-installed'
|
||||
config.cache.enable :pip
|
||||
end
|
||||
```
|
||||
|
|
@ -96,6 +96,7 @@
|
|||
<li><a tabindex="-1" href="buckets/rvm">rvm</a></li>
|
||||
<li><a tabindex="-1" href="buckets/yum">Yum</a></li>
|
||||
<li><a tabindex="-1" href="buckets/zypper">Zypper</a></li>
|
||||
<li><a tabindex="-1" href="buckets/pip">pip</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -101,3 +101,4 @@ require_relative "bucket/bower"
|
|||
require_relative "bucket/npm"
|
||||
require_relative "bucket/zypper"
|
||||
require_relative "bucket/generic"
|
||||
require_relative "bucket/pip"
|
||||
|
|
22
lib/vagrant-cachier/bucket/pip.rb
Normal file
22
lib/vagrant-cachier/bucket/pip.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
module VagrantPlugins
|
||||
module Cachier
|
||||
class Bucket
|
||||
class Pip < Bucket
|
||||
def self.capability
|
||||
:pip_cache_dir
|
||||
end
|
||||
|
||||
def install
|
||||
if guest.capability?(:pip_cache_dir)
|
||||
if guest_path = guest.capability(:pip_cache_dir)
|
||||
symlink("#{guest_path}/http", "/tmp/vagrant-cache/#{@name}/http")
|
||||
symlink("#{guest_path}/wheels", "/tmp/vagrant-cache/#{@name}/wheels")
|
||||
end
|
||||
else
|
||||
@env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'pip')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
20
lib/vagrant-cachier/cap/linux/pip_cache_dir.rb
Normal file
20
lib/vagrant-cachier/cap/linux/pip_cache_dir.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module VagrantPlugins
|
||||
module Cachier
|
||||
module Cap
|
||||
module Linux
|
||||
module PipCacheDir
|
||||
def self.pip_cache_dir(machine)
|
||||
pip_cache_dir = nil
|
||||
machine.communicate.tap do |comm|
|
||||
return unless comm.test('which pip')
|
||||
comm.execute 'echo $HOME' do |buffer, output|
|
||||
pip_cache_dir = output.chomp if buffer == :stdout
|
||||
end
|
||||
end
|
||||
return "#{pip_cache_dir}/.cache/pip"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -36,6 +36,11 @@ module VagrantPlugins
|
|||
Cap::Linux::NpmCacheDir
|
||||
end
|
||||
|
||||
guest_capability 'linux', 'pip_cache_dir' do
|
||||
require_relative 'cap/linux/pip_cache_dir'
|
||||
Cap::Linux::PipCacheDir
|
||||
end
|
||||
|
||||
guest_capability 'debian', 'apt_cache_dir' do
|
||||
require_relative 'cap/debian/apt_cache_dir'
|
||||
Cap::Debian::AptCacheDir
|
||||
|
|
Loading…
Reference in a new issue