brettcannon / python-launcher

Python launcher for Unix

Home Page:https://python-launcher.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate a Homebrew formula

brettcannon opened this issue · comments

From #22 :

https://docs.brew.sh/Acceptable-Formulae

To generate the Homebrew formula, there's a cookbook, class details, and can use ripgrep's formula as guidance. Also might want an alias like ripgrep for rg if "py" is not already taken.

class PythonLauncher < Formula
  desc "Launch your Python interpreter the lazy/smart way"
  homepage "https://github.com/brettcannon/python-launcher"
  url "https://github.com/brettcannon/python-launcher/archive/refs/tags/v0.16.0.tar.gz"
  sha256 "03d4a2813c1639264c5e3e6a9961025d7004d1a85deaa8f97bce6010803fa1a8"
  license "MIT"

  head "https://github.com/brettcannon/python-launcher.git", branch: "main"

  livecheck do
    url :stable
    strategy :github_latest
  end

  depends_on "rust" => :build

  def install
    system "cargo", "install", *std_cargo_args

    man1.install "docs/man-page/py.1"
    fish_completion.install "completions/py.fish"
  end

  test do
    binary = testpath/"python3.6"
    binary.write("Fake Python 3.6 executable")
    with_env("PATH" => testpath) do
      assert_match("3.6 │ #{binary}", shell_output("#{bin}/py --list"))
    end
  end
end

This passes all of the checks I could do and builds from source appropriately.

https://docs.brew.sh/Brew-Livecheck#git-tags suggests the livecheck block needs an update.

class PythonLauncher < Formula
  desc "Launch your Python interpreter the lazy/smart way"
  homepage "https://github.com/brettcannon/python-launcher"
  url "https://github.com/brettcannon/python-launcher/archive/refs/tags/XXX.tar.gz"
  sha256 "XXX"
  license "MIT"

  head "https://github.com/brettcannon/python-launcher.git", branch: "main"

  livecheck do
    url :head
    regex(/^v(\d+\.\d+\.\d+)$/i)
  end

  depends_on "rust" => :build

  def install
    system "cargo", "install", *std_cargo_args

    man1.install "docs/man-page/py.1"
    fish_completion.install "completions/py.fish"
  end

  test do
    binary = testpath/"python3.6"
    binary.write("Fake Python 3.6 executable")
    with_env("PATH" => testpath) do
      assert_match("3.6 │ #{binary}", shell_output("#{bin}/py --list"))
    end
  end
end

Hello, Homebrew maintainer here. There's a pull request open at homebrew/core to add a Formula for python-launcher (Homebrew/homebrew-core#79173). I just noticed that v0.16.0 is a prerelease (according to the Releases tab), which means we can't add it just yet. Is there a plan to make it the latest (stable) release in the near future?

@nandahkrishna It's not quite ready yet (I purposefully marked it as pre-release to hope people wouldn't start submitting it to package managers; guess it didn't quite work out 😅 ). But I'm hoping to release v1.0.0 this month.

As you can see I have already worked out the formula to submit once I'm ready to go since I'm a very happy Homebrew user myself. Is it okay for me to submit the formula myself once 1.0.0 is out? I was planning not to as https://docs.brew.sh/Acceptable-Formulae#niche-or-self-submitted-stuff suggests it shouldn't come from me (at least initially).

I also noticed you suggested on that PR to not set an alias for py. I was actually planning to do that to mirror what ripgrep/rg has set up. Should that be skipped?

I purposefully marked it as pre-release to hope people wouldn't start submitting it to package managers; guess it didn't quite work out 😅

Aha, I see 😅. We should hold off on adding the Formula until you're ready to make a stable release then. It seems like a user wanted to add python-launcher to Homebrew (and may have even seen this issue), so they proceeded to create a PR to do just that.

Is it okay for me to submit the formula myself once 1.0.0 is out?

The "rule" mainly exists to prevent people from submitting every project of their own to Homebrew. We would happily accept requests to add popular software like python-launcher – so yes, you could submit it yourself if you wish to.

I also noticed you suggested on that PR to not set an alias for py. I was actually planning to do that to mirror what ripgrep/rg has set up. Should that be skipped?

That wasn't a strong opinion, I suggested against having the alias because there are quite a few py* formulae. I'd be happy to reconsider if there aren't any objections from other maintainers.

(Just CCing @messense since they created Homebrew/homebrew-core#79173.)

Installation works on macOS but fails on Linux Homebrew/linuxbrew-core#23953