78 lines
3.2 KiB
Ruby
78 lines
3.2 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/90/48/337668b471ffa26006bc768ce5857bc0e6f2eaf3ecd686c945c81b27d29e/pipenv-11.10.1.tar.gz"
|
|
sha256 "9acfd4d4b6a36e35ec3d255211224506c9983c30e4b57b3047e61d690c2d82cb"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "2ea083aff30a537d810fc95d075373b34dc720ef8d3862e2934f514e75adcd42" => :high_sierra
|
|
sha256 "cf242964122af6cde0645063dd0a43afacca1ab7d6de51829b787da046924497" => :sierra
|
|
sha256 "d3c9aac16ae2bf5d2c889c4a14dc6c50f33906c9c1fcdff6b5596a17b371df18" => :el_capitan
|
|
end
|
|
|
|
depends_on "python"
|
|
|
|
resource "certifi" do
|
|
url "https://files.pythonhosted.org/packages/4d/9c/46e950a6f4d6b4be571ddcae21e7bc846fcbb88f1de3eff0f6dd0a6be55d/certifi-2018.4.16.tar.gz"
|
|
sha256 "13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7"
|
|
end
|
|
|
|
resource "virtualenv" do
|
|
url "https://files.pythonhosted.org/packages/b1/72/2d70c5a1de409ceb3a27ff2ec007ecdd5cc52239e7c74990e32af57affe9/virtualenv-15.2.0.tar.gz"
|
|
sha256 "1d7e241b431e7afce47e77f8843a276f652699d1fa4f93b9d8ce0076fd7b0b54"
|
|
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` and `pewtwo` 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/pewtwo", libexec/"bin/pip",
|
|
libexec/"bin/virtualenv"
|
|
env = {
|
|
:PATH => "#{libexec}/tools:$PATH",
|
|
}
|
|
(bin/"pipenv").write_env_script(libexec/"bin/pipenv", env)
|
|
|
|
output = Utils.popen_read("#{libexec}/bin/pipenv --completion")
|
|
(bash_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
|