This repository has been archived by the owner on Dec 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for caching pip packages
These directories are chached for pip packages: $HOME/.cache/pip/http $HOME/.cache/pip/wheels
- Loading branch information
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters