replicate / cog

Containers for machine learning
https://cog.run
Apache License 2.0
8.08k stars 562 forks source link

Create Homebrew formula #822

Closed mattt closed 1 year ago

mattt commented 1 year ago

Homebrew is a popular way to install developer tools on macOS. It would be great to be able to install cog in a single command, like this:

$ brew install cog
mattt commented 1 year ago

I have a Homebrew formula working locally that should be ready to submit to the default homebrew-core repository once https://github.com/replicate/cog/pull/823 lands. Here's the source for that:

class Cog < Formula
  desc "Containers for machine learning"
  homepage "https://github.com/replicate/cog"
  url "https://github.com/replicate/cog.git",
      tag:      "v0.4.4",
      revision: "12dfcaa4d47adb586b75a60842e22f0e5d3a41f5"
  license "Apache-2.0"

  # TODO: remove once PR is merged
  head "https://github.com/mattt/cog.git", branch: "refactor-makefile"

  livecheck do
    url :stable
    strategy :github_latest
  end

  depends_on "go" => :build
  depends_on "python@3.10" => :build

  def install
    args = %W[
      BINDIR=#{bin}
      PYTHON=python3

      COG_VERSION=#{version}
    ]

    system "make", "install", *args
    generate_completions_from_executable(bin/"cog", "completion")
  end

  test do
    assert_match "cog version #{version}", shell_output("#{bin}/cog --version")
  end
end

/cc @zeke

mattt commented 1 year ago

Now that #823 is merged, we (edit: almost [^1]) have a working Homebrew formula that's ready for submission to core:

class Cog < Formula
  desc "Containers for machine learning"
  homepage "https://github.com/replicate/cog"
  url "https://github.com/replicate/cog.git",
      tag:      "v0.5.0",
      revision: "1f8fec1a52eb407d4be4271726ce29f46f8e543b"
  license "Apache-2.0"

  head "https://github.com/replicate/cog.git", branch: "main"

  livecheck do
    url :stable
    strategy :github_latest
  end

  depends_on "go" => :build
  depends_on "python@3.10" => :build
  depends_on "redis"

  def install
    args = %W[
      COG_VERSION=#{version}
      PYTHON=python3
    ]

    system "make", *args
    bin.install "cog"

    generate_completions_from_executable(bin/"cog", "completion")
  end

  test do
    assert_match "cog version #{version}", shell_output("#{bin}/cog --version")
  end
end

[^1]: Just one more thing: A new tagged release with the latest changes.

  @zeke @nickstenning Can either of you please cut a release when you have a chance?
zeke commented 1 year ago
  1. Can either of you please cut a release when you have a chance?

Fine by me! We've historically kept the main branch releasable, but we've recently had a few situations where changes accumulated on main that required a bit of team coordination before releasing. @evilstreak @bfirsh @nickstenning are we out of the woods now that 0.5.0 has shipped?

zeke commented 1 year ago

Hey @mattt. Sorry the delay. I cut a new release! You should be good to go.

https://github.com/replicate/cog/releases/tag/v0.5.1

mattt commented 1 year ago

@zeke Thanks for cutting that new release. I just opened a PR to homebrew/core here: https://github.com/Homebrew/homebrew-core/pull/117929

mattt commented 1 year ago

We can now install cog with brew install cog. Thanks for all of your help with this, @zeke 🥳

https://github.com/replicate/cog/pull/849