84 lines
3.3 KiB
Ruby
84 lines
3.3 KiB
Ruby
class Pipenv < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Python dependency management tool"
|
|
homepage "https://docs.pipenv.org/"
|
|
url "https://files.pythonhosted.org/packages/fd/e9/01822318551caa0d62a181ba3b10f0f3757bb1e270da97165bd52db92776/pipenv-2018.11.26.tar.gz"
|
|
sha256 "a673e606e8452185e9817a987572b55360f4d28b50831ef3b42ac3cab3fee846"
|
|
revision 2
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
rebuild 1
|
|
sha256 "8f084160ecf6fec95317a0a298242040590ded00f5d375796c28697f1e9507c8" => :catalina
|
|
sha256 "df13002254ad48b6586ed47c9c754992dbf669ce630b6c6c90ceca0a79c21e17" => :mojave
|
|
sha256 "41aec81be5fa304ba9cfe4a061ac9088f6d51fac05bc0c6b73afddec431c6bb1" => :high_sierra
|
|
sha256 "d961acb64dbd94b43950f877ce48e0bf519c07b71eed0188acdf81d55876d75c" => :sierra
|
|
end
|
|
|
|
depends_on "python"
|
|
|
|
resource "certifi" do
|
|
url "https://files.pythonhosted.org/packages/41/b6/4f0cefba47656583217acd6cd797bc2db1fede0d53090fdc28ad2c8e0716/certifi-2018.10.15.tar.gz"
|
|
sha256 "6d58c986d22b038c8c0df30d639f23a3e6d172a05c3583e766f4c0b785c0986a"
|
|
end
|
|
|
|
resource "virtualenv" do
|
|
url "https://files.pythonhosted.org/packages/8b/f4/360aa656ddb0f4168aeaa1057d8784b95d1ce12f34332c1cf52420b6db4e/virtualenv-16.3.0.tar.gz"
|
|
sha256 "729f0bcab430e4ef137646805b5b1d8efbb43fe53d4a0f33328624a84a5121f7"
|
|
end
|
|
|
|
resource "virtualenv-clone" do
|
|
url "https://files.pythonhosted.org/packages/14/2f/84b6a8e380439cdfdb71e0ced2a805a66e343ac540d3304bde6bc28fbb46/virtualenv-clone-0.3.0.tar.gz"
|
|
sha256 "b5cfe535d14dc68dfc1d1bb4ac1209ea28235b91156e2bba8e250d291c3fb4f8"
|
|
end
|
|
|
|
def install
|
|
# Using the virtualenv DSL here because the alternative of using
|
|
# write_env_script to set a PYTHONPATH breaks things.
|
|
# https://github.com/Homebrew/homebrew-core/pull/19060#issuecomment-338397417
|
|
venv = virtualenv_create(libexec, "python3")
|
|
venv.pip_install resources
|
|
venv.pip_install buildpath
|
|
|
|
# `pipenv` needs to be able to find `virtualenv` on PATH. So we
|
|
# install symlinks for those scripts in `#{libexec}/tools` and create a
|
|
# wrapper script for `pipenv` which adds `#{libexec}/tools` to PATH.
|
|
(libexec/"tools").install_symlink libexec/"bin/pip", libexec/"bin/virtualenv"
|
|
env = {
|
|
:PATH => "#{libexec}/tools:$PATH",
|
|
}
|
|
(bin/"pipenv").write_env_script(libexec/"bin/pipenv", env)
|
|
|
|
output = Utils.popen_read("SHELL=bash #{libexec}/bin/pipenv --completion")
|
|
(bash_completion/"pipenv").write output
|
|
|
|
output = Utils.popen_read("SHELL=zsh #{libexec}/bin/pipenv --completion")
|
|
(zsh_completion/"_pipenv").write output
|
|
end
|
|
|
|
# Avoid relative paths
|
|
def post_install
|
|
lib_python_path = Pathname.glob(libexec/"lib/python*").first
|
|
lib_python_path.each_child do |f|
|
|
next unless f.symlink?
|
|
|
|
realpath = f.realpath
|
|
rm f
|
|
ln_s realpath, f
|
|
end
|
|
inreplace lib_python_path/"orig-prefix.txt",
|
|
Formula["python"].opt_prefix, Formula["python"].prefix.realpath
|
|
end
|
|
|
|
test do
|
|
ENV["LC_ALL"] = "en_US.UTF-8"
|
|
assert_match "Commands", shell_output("#{bin}/pipenv")
|
|
system "#{bin}/pipenv", "install", "requests"
|
|
system "#{bin}/pipenv", "install", "boto3"
|
|
assert_predicate testpath/"Pipfile", :exist?
|
|
assert_predicate testpath/"Pipfile.lock", :exist?
|
|
assert_match "requests", (testpath/"Pipfile").read
|
|
assert_match "boto3", (testpath/"Pipfile").read
|
|
end
|
|
end
|