class PipTools < Formula
  include Language::Python::Virtualenv

  desc "Locking and sync for Pip requirements files"
  homepage "https://pip-tools.readthedocs.io"
  url "https://files.pythonhosted.org/packages/9a/0a/b1bad74966a949a07b57d0ce0be241a8d8c75afde1be915b7a66008f696c/pip-tools-6.5.1.tar.gz"
  sha256 "80f562aa699fc76a424539697e0bef41e490a050e57a6a21468531981a9d419e"
  license "BSD-3-Clause"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "681b35dc35ec671ad2efb1eb9466998f950e9690587053c011920552a7a2f5c0"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "41f06137bb0978c3370d06a5483f8955ae1deece0e6e820d4134a58ebc3626fc"
    sha256 cellar: :any_skip_relocation, monterey:       "44eb4b7d99b1ee8446e5e3903b066fbfef3d42debb837ef174bb3031033bffe4"
    sha256 cellar: :any_skip_relocation, big_sur:        "97c90660263662076919a16b565ccb37c2a144122fb49641998713a5cfd56e12"
    sha256 cellar: :any_skip_relocation, catalina:       "442b083464be96c10fdee9a99f1c543211dbdfbc2b9f71f880386eec4adb97ce"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "a8e0332779dd108ccaeb26ee93ce62564eee46779916dbeb8e04c62fb9bde4b5"
  end

  depends_on "python@3.10"

  resource "click" do
    url "https://files.pythonhosted.org/packages/f4/09/ad003f1e3428017d1c3da4ccc9547591703ffea548626f47ec74509c5824/click-8.0.3.tar.gz"
    sha256 "410e932b050f5eed773c4cda94de75971c89cdb3155a72a0831139a79e5ecb5b"
  end

  resource "pep517" do
    url "https://files.pythonhosted.org/packages/0a/65/6e656d49c679136edfba25f25791f45ffe1ea4ae2ec1c59fe9c35e061cd1/pep517-0.12.0.tar.gz"
    sha256 "931378d93d11b298cf511dd634cf5ea4cb249a28ef84160b3247ee9afb4e8ab0"
  end

  resource "tomli" do
    url "https://files.pythonhosted.org/packages/c0/3f/d7af728f075fb08564c5949a9c95e44352e23dee646869fa104a3b2060a3/tomli-2.0.1.tar.gz"
    sha256 "de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"
  end

  resource "wheel" do
    url "https://files.pythonhosted.org/packages/c0/6c/9f840c2e55b67b90745af06a540964b73589256cb10cc10057c87ac78fc2/wheel-0.37.1.tar.gz"
    sha256 "e9a504e793efbca1b8e0e9cb979a249cf4a0a7b5b8c9e8b65a5e39d49529c1c4"
  end

  def install
    virtualenv_install_with_resources
  end

  test do
    (testpath/"requirements.in").write <<~EOS
      pip-tools
      typing-extensions
    EOS

    compiled = shell_output("#{bin}/pip-compile requirements.in -q -o -")
    assert_match "This file is autogenerated by pip-compile", compiled
    assert_match "# via pip-tools", compiled
  end
end
