homebrew-core/Formula/pipenv.rb
2017-12-19 09:33:40 -08:00

119 lines
5.1 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/b5/3f/80a09ea5f279e90122600d24cfa25d698008dc7e5b261cb582de8966bbe2/pipenv-8.3.2.tar.gz"
sha256 "20be245ad2a7908a04b302e9568ee26e57f8dacc558468d2a84e699b2622e9af"
revision 2
bottle do
cellar :any_skip_relocation
sha256 "b50a81af85bfa8bf0bf4ee360f9aba93d21214314bc38452ab2d0a682d08c3e0" => :high_sierra
sha256 "2bc5de5058bea1f0c684cca36241462a41ad4e4dfa6e98c194cb05e0c5ba9f77" => :sierra
sha256 "5a0fa00b8069b2bae918af6e2f2a13c929e1103940245f4edf5d1dc8374d1e8b" => :el_capitan
end
depends_on :python3
resource "certifi" do
url "https://files.pythonhosted.org/packages/23/3f/8be01c50ed24a4bd6b8da799839066ce0288f66f5e11f0367323467f0cbc/certifi-2017.11.5.tar.gz"
sha256 "5ec74291ca1136b40f0379e1128ff80e866597e4e2c1e755739a913bbc3613c0"
end
resource "chardet" do
url "https://files.pythonhosted.org/packages/fc/bb/a5768c230f9ddb03acc9ef3f0d4a3cf93462473795d18e9535498c8f929d/chardet-3.0.4.tar.gz"
sha256 "84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"
end
resource "flake8" do
url "https://files.pythonhosted.org/packages/1e/ab/7730f6d6cdf73a3b7f98a2fe3b2cdf68e9e760a4a133e083607497d4c3a6/flake8-3.5.0.tar.gz"
sha256 "7253265f7abd8b313e3892944044a365e3f4ac3fcdcfb4298f55ee9ddf188ba0"
end
resource "idna" do
url "https://files.pythonhosted.org/packages/f4/bd/0467d62790828c23c47fc1dfa1b1f052b24efdf5290f071c7a91d0d82fd3/idna-2.6.tar.gz"
sha256 "2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f"
end
resource "mccabe" do
url "https://files.pythonhosted.org/packages/06/18/fa675aa501e11d6d6ca0ae73a101b2f3571a565e0f7d38e062eec18a91ee/mccabe-0.6.1.tar.gz"
sha256 "dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
end
resource "pew" do
url "https://files.pythonhosted.org/packages/a4/be/efe77f7dcb088f263bfc5eac09121b2f9a6e59c3bdfdff7a801d2253f2ac/pew-1.1.0.tar.gz"
sha256 "d0f9d127cf321c959bb857e59080f7eaa59c8bbeb2d53aa07d3350aae50e1f2d"
end
resource "pycodestyle" do
url "https://files.pythonhosted.org/packages/e1/88/0e2cbf412bd849ea6f1af1f97882add46a374f4ba1d2aea39353609150ad/pycodestyle-2.3.1.tar.gz"
sha256 "682256a5b318149ca0d2a9185d365d8864a768a28db66a84a2ea946bcc426766"
end
resource "pyflakes" do
url "https://files.pythonhosted.org/packages/26/85/f6a315cd3c1aa597fb3a04cc7d7dbea5b3cc66ea6bd13dfa0478bf4876e6/pyflakes-1.6.0.tar.gz"
sha256 "8d616a382f243dbf19b54743f280b80198be0bca3a5396f1d2e1fca6223e8805"
end
resource "requests" do
url "https://files.pythonhosted.org/packages/b0/e1/eab4fc3752e3d240468a8c0b284607899d2fbfb236a56b7377a329aa8d09/requests-2.18.4.tar.gz"
sha256 "9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e"
end
resource "urllib3" do
url "https://files.pythonhosted.org/packages/ee/11/7c59620aceedcc1ef65e156cc5ce5a24ef87be4107c2b74458464e437a5d/urllib3-1.22.tar.gz"
sha256 "cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f"
end
resource "virtualenv" do
url "https://files.pythonhosted.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz"
sha256 "02f8102c2436bb03b3ee6dede1919d1dac8a427541652e5ec95171ec8adbc93a"
end
resource "virtualenv-clone" do
url "https://files.pythonhosted.org/packages/36/66/d95f83255138ded1aec242de5ee51536226fa7b2582a7ce0863fea5dc4f2/virtualenv-clone-0.2.6.tar.gz"
sha256 "6b3be5cab59e455f08c9eda573d23006b7d6fb41fae974ddaa2b275c93cc4405"
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 `pew` 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/pew", libexec/"bin/pip",
libexec/"bin/virtualenv"
env = {
:PATH => "#{libexec}/tools:$PATH",
}
(bin/"pipenv").write_env_script(libexec/"bin/pipenv", env)
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["python3"].opt_prefix, Formula["python3"].prefix.realpath
end
test do
ENV["LC_ALL"] = "en_US.UTF-8"
assert_match "Commands", shell_output("#{bin}/pipenv")
system "#{bin}/pipenv", "install", "requests"
assert_predicate testpath/"Pipfile", :exist?
assert_predicate testpath/"Pipfile.lock", :exist?
assert_match "requests", (testpath/"Pipfile").read
end
end