Sha256: 02b8cb6cb44f098b339fb7bf4ee843ff33aaff95ced2c6d81cad34b2d4718d22

Contents?: true

Size: 1.4 KB

Versions: 16

Compression:

Stored size: 1.4 KB

Contents

require 'fileutils'
require_relative 'helper'

module Dply
  class Venv

    include Helper

    def install(system_site_packages: false, pip_version: "9.0.1", setuptools_version: "38.4.1", &block)
      init(system_site_packages)
      update_pip_setuptools(pip_version, setuptools_version)
      yield if block_given?
      pip_install
    end

    def build(system_site_packages: false, pip_version: "9.0.1", setuptools_version: "38.4.1", &block)
      FileUtils.mkdir_p "tmp/venv"
      symlink "tmp/venv", "venv"
      init(system_site_packages)
      update_pip_setuptools(pip_version, setuptools_version)
      yield if block_given?
      pip_install
      sh "virtualenv-relocate -s venv"
    end

    def unpack
      sh "virtualenv-relocate -d venv"
    end

    private

    def init(system_site_packages = false)
      return if File.exist? "venv/.setup_done"
      system_flag = system_site_packages ? "--system-site-packages" : ""
      sh "virtualenv #{system_flag} venv"
      FileUtils.touch "venv/.setup_done"
    end

    def pip_install
      sh "venv/bin/pip install -r requirements.txt"
    end

    def python(command)
      sh "venv/bin/python #{command}"
    end

    def update_pip_setuptools(pip_version, setuptools_version)
      sh "venv/bin/pip install pip==#{pip_version}"
      sh "venv/bin/pip install setuptools==#{setuptools_version}"
#      sh "venv/bin/pip install urllib3[secure]"
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dply-0.3.15 lib/dply/venv.rb
dply-0.3.14 lib/dply/venv.rb
dply-0.3.13 lib/dply/venv.rb
dply-0.3.12 lib/dply/venv.rb
dply-0.3.11 lib/dply/venv.rb
dply-0.3.10 lib/dply/venv.rb
dply-0.3.9 lib/dply/venv.rb
dply-0.3.8 lib/dply/venv.rb
dply-0.3.7 lib/dply/venv.rb
dply-0.3.6 lib/dply/venv.rb
dply-0.3.5 lib/dply/venv.rb
dply-0.3.4 lib/dply/venv.rb
dply-0.3.3 lib/dply/venv.rb
dply-0.3.2 lib/dply/venv.rb
dply-0.3.1 lib/dply/venv.rb
dply-0.3.0 lib/dply/venv.rb