Skip to content

Commit

Permalink
Formula rename
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-astus committed Feb 23, 2024
1 parent 06699c7 commit 026cfd2
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
uses: actions/checkout@v4
- name: Install formula
run: |
brew install -s Formula/snowcli.rb
brew install --formula -s Formula/snowcli.rb
brew install --formula -s Formula/snowflake-cli.rb
- name: Check snow commands
run: |
snow --help
2 changes: 1 addition & 1 deletion Formula/snowcli.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Snowcli < Formula
include Language::Python::Virtualenv
desc "A CLI for Snowflake development"
homepage "https://github.com/snowflake-labs/snowcli"
homepage "https://github.com/snowflake-labs/snowflake-cli"
url "https://files.pythonhosted.org/packages/03/69/b508427075311424de383944ecdd484918516e67081bda932779ef5360e5/snowflake_cli_labs-2.0.0.tar.gz"
sha256 "28ba342cf7b55a4d7aebb97bc1da4cd3ba7b05cd247dee11f52f80a1234ffdda"

Expand Down
2 changes: 1 addition & 1 deletion Formula/snowcli.tmpl.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Snowcli < Formula
include Language::Python::Virtualenv
desc "A CLI for Snowflake development"
homepage "https://github.com/snowflake-labs/snowcli"
homepage "https://github.com/snowflake-labs/snowflake-cli"
url "{{ sf_url }}"
sha256 "{{ sf_sha }}"

Expand Down
24 changes: 24 additions & 0 deletions Formula/snowflake-cli.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class SnowflakeCli < Formula
include Language::Python::Virtualenv
desc "A CLI for Snowflake development"
homepage "https://github.com/snowflake-labs/snowflake-cli"
url "https://files.pythonhosted.org/packages/03/69/b508427075311424de383944ecdd484918516e67081bda932779ef5360e5/snowflake_cli_labs-2.0.0.tar.gz"
sha256 "28ba342cf7b55a4d7aebb97bc1da4cd3ba7b05cd247dee11f52f80a1234ffdda"

depends_on "python3"

def install
ENV["CARGO_NET_GIT_FETCH_WITH_CLI"] = "true"
#without_pip=false because of https://github.com/Homebrew/brew/pull/15792
venv = virtualenv_create(libexec, "python3", system_site_packages: false, without_pip: false)
venv.instance_variable_get(:@formula).system venv.instance_variable_get(:@venv_root)/"bin/python",
"-m", "pip", "install", "pip==22.3.1"
venv.instance_variable_get(:@formula).system venv.instance_variable_get(:@venv_root)/"bin/pip",
"install", "snowflake-cli-labs==2.0.0"
bin.install_symlink "#{libexec}/bin/snow" => "snow"
end

test do
false
end
end
24 changes: 24 additions & 0 deletions Formula/snowflake-cli.tmpl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class SnowflakeCli < Formula
include Language::Python::Virtualenv
desc "A CLI for Snowflake development"
homepage "https://github.com/snowflake-labs/snowflake-cli"
url "{{ sf_url }}"
sha256 "{{ sf_sha }}"

depends_on "python3"

def install
ENV["CARGO_NET_GIT_FETCH_WITH_CLI"] = "true"
#without_pip=false because of https://github.com/Homebrew/brew/pull/15792
venv = virtualenv_create(libexec, "python3", system_site_packages: false, without_pip: false)
venv.instance_variable_get(:@formula).system venv.instance_variable_get(:@venv_root)/"bin/python",
"-m", "pip", "install", "pip==22.3.1"
venv.instance_variable_get(:@formula).system venv.instance_variable_get(:@venv_root)/"bin/pip",
"install", "snowflake-cli-labs=={{ version }}"
bin.install_symlink "#{libexec}/bin/snow" => "snow"
end

test do
false
end
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# homebrew-snowcli
# homebrew-snowflake-cli

Homebrew formula allowing for installation of Snowflake CLI using homebrew tap.

Expand Down
33 changes: 33 additions & 0 deletions update-snowcli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import re
import subprocess
from pathlib import Path
from textwrap import indent

import jinja2


def main():
env = jinja2.Environment(
loader=jinja2.loaders.FileSystemLoader(Path(__file__).parent)
)
template = env.get_template("Formula/snowflake.tmpl.rb")
packages = subprocess.check_output(["poet", "snowflake-cli-labs"], encoding="utf-8")

sf_pattern = r'\s+resource \"snowflake-cli-labs\" do\s+url \"(.+)\"\s+sha256 \"(\w+)\"\s+end\n'
match = re.findall(sf_pattern, packages)
if not match:
raise ValueError("snowflake dependency not present in deps")
sf_url, sf_sha = match[0]

version = subprocess.check_output(["snow", "--version"], encoding="utf-8").split()[-1]

with open("Formula/snowcli.rb", "w+") as fh:
fh.write(template.render(
sf_url=sf_url,
sf_sha=sf_sha,
version=version,
))


if __name__ == '__main__':
main()
4 changes: 2 additions & 2 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def main():
env = jinja2.Environment(
loader=jinja2.loaders.FileSystemLoader(Path(__file__).parent)
)
template = env.get_template("Formula/snowcli.tmpl.rb")
template = env.get_template("Formula/snowflake-cli.tmpl.rb")
packages = subprocess.check_output(["poet", "snowflake-cli-labs"], encoding="utf-8")

sf_pattern = r'\s+resource \"snowflake-cli-labs\" do\s+url \"(.+)\"\s+sha256 \"(\w+)\"\s+end\n'
Expand All @@ -21,7 +21,7 @@ def main():

version = subprocess.check_output(["snow", "--version"], encoding="utf-8").split()[-1]

with open("Formula/snowcli.rb", "w+") as fh:
with open("Formula/snowflake-cli.rb", "w+") as fh:
fh.write(template.render(
sf_url=sf_url,
sf_sha=sf_sha,
Expand Down

0 comments on commit 026cfd2

Please sign in to comment.