Skip to content

Instantly share code, notes, and snippets.

@innovid-rnd
Created March 8, 2018 21:42
Show Gist options
  • Save innovid-rnd/cc05f67b7511fb9d905a71165910fc7b to your computer and use it in GitHub Desktop.
Save innovid-rnd/cc05f67b7511fb9d905a71165910fc7b to your computer and use it in GitHub Desktop.
# Helper method for the common case of installing a Python application.
# Creates a virtualenv in `libexec`, installs all `resource`s defined
# on the formula, and then installs the formula.
def virtualenv_install_with_resources(options = {})
python = options[:using]
if python.nil?
wanted = %w[python python@2 python@3 python3].select { |py| needs_python?(py) }
raise FormulaAmbiguousPythonError, self if wanted.size > 1
python = wanted.first || "python2.7"
end
venv = virtualenv_create(libexec, python.delete("@"))
venv.pip_install resources
venv.pip_install_and_link buildpath
venv
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment