Skip to content

Commit 9d07e87

Browse files
committed
Cleaned up brew install file and added Python package dependencies to brew's specifications.
1 parent 9abeb87 commit 9d07e87

File tree

3 files changed

+393
-76
lines changed

3 files changed

+393
-76
lines changed

Formula/vivaria.rb

+117-76
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,96 @@
11
class Vivaria < Formula
2-
# A brief description of the software
2+
include Language::Python::Virtualenv
33
desc "Task environment setup tool for AI research"
4-
5-
# The official website of the software
4+
# AUTHORS: METR <[email protected]>
65
homepage "https://vivaria.metr.org/"
7-
8-
# URL to the tarball of the release
9-
# This should point to a specific version, not a branch
10-
# This gets put into the temporary $(brew --cache)/downloads directory
11-
# Then gets extracted into $(brew --cache)/vivaria--[version].tar.gz/ directory
12-
# Install is then relied on to copy the necessary files to the Cellar
13-
url "https://github.com/GatlenCulp/vivaria/archive/refs/tags/v0.1.0.tar.gz"
14-
15-
# SHA256 checksum of the tarball for security verification
16-
# Generate this with: curl -L <tarball_url> | shasum -a 256
17-
sha256 "eabcf6b3d0d63ba37cd6af03c0566e981d333b5a06fd38dd61102e9f72941ecd"
18-
19-
# The license of the software
6+
url "https://github.com/GatlenCulp/vivaria/archive/refs/tags/v0.1.1.tar.gz"#, tag: "v0.1.0"
7+
version "0.1.0" # TODO: Grab the version from the tag(?)
8+
sha256 "3360781d374e010e2b6c7a86b2cc5a91b51d6b2c5337d14788858a719af943d2"
209
license "MIT"
10+
head "https://github.com/METR/vivaria.git", branch: "main"
2111

22-
# TODO: AUTHORS: METR <[email protected]>
12+
# TODO: Make these options work
13+
# option "with-dev-mode", "Install Vivaria for development of the software itself."
14+
# option "without-cli", "Only install the Docker setup scripts and not the CLI."
2315

24-
# Dependencies required to run the software
25-
# Brew will make sure these are installed before installing the software
26-
# `:run` means these are runtime dependencies
2716
# This was fixed after I ran `brew link docker`
2817
depends_on "docker" => :run
2918
depends_on "docker-compose" => :run
30-
# TODO: Depends on python >= 3.11
31-
# python=">=3.11,<4"
32-
# For the CLI
33-
# Might not be necessary? I think homebrew already has python installed
34-
depends_on "python" => :build
19+
depends_on "[email protected]"
3520

3621
DEV_MODE = false
3722

38-
# The installation method
39-
# Brew tracks the files installed by the formula. But only removes files in the prefix directory
40-
# Cellar is within the prefix directory for formulas.
41-
def install
42-
# binding.pry for debugging, not set up yet
43-
# Create necessary directories in the Cellar
44-
# The `prefix` variable refers to the root directory of this formula in the Cellar
45-
# (prefix/"scripts").mkpath
46-
# (prefix/"docker").mkpath
23+
resource "annotated-types" do
24+
url "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz"
25+
sha256 "aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"
26+
end
27+
28+
resource "certifi" do
29+
url "https://files.pythonhosted.org/packages/b0/ee/9b19140fe824b367c04c5e1b369942dd754c4c5462d5674002f75c4dedc1/certifi-2024.8.30.tar.gz"
30+
sha256 "bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9"
31+
end
32+
33+
resource "charset-normalizer" do
34+
url "https://files.pythonhosted.org/packages/63/09/c1bc53dab74b1816a00d8d030de5bf98f724c52c1635e07681d312f20be8/charset-normalizer-3.3.2.tar.gz"
35+
sha256 "f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"
36+
end
37+
38+
resource "fire" do
39+
url "https://files.pythonhosted.org/packages/1b/1b/84c63f592ecdfbb3d77d22a8d93c9b92791e4fa35677ad71a7d6449100f8/fire-0.6.0.tar.gz"
40+
sha256 "54ec5b996ecdd3c0309c800324a0703d6da512241bc73b553db959d98de0aa66"
41+
end
42+
43+
resource "idna" do
44+
url "https://files.pythonhosted.org/packages/00/6f/93e724eafe34e860d15d37a4f72a1511dd37c43a76a8671b22a15029d545/idna-3.9.tar.gz"
45+
sha256 "e5c5dafde284f26e9e0f28f6ea2d6400abd5ca099864a67f576f3981c6476124"
46+
end
4747

48-
# These commands are ruby methods wrapping shell commands
49-
# Copy the setup scripts to the Cellar
50-
# The `buildpath` refers to the directory where the tarball was extracted
48+
resource "pydantic" do
49+
url "https://files.pythonhosted.org/packages/14/15/3d989541b9c8128b96d532cfd2dd10131ddcc75a807330c00feb3d42a5bd/pydantic-2.9.1.tar.gz"
50+
sha256 "1363c7d975c7036df0db2b4a61f2e062fbc0aa5ab5f2772e0ffc7191a4f4bce2"
51+
end
52+
53+
resource "pydantic-core" do
54+
url "https://files.pythonhosted.org/packages/5c/cc/07bec3fb337ff80eacd6028745bd858b9642f61ee58cfdbfb64451c1def0/pydantic_core-2.23.3.tar.gz"
55+
sha256 "3cb0f65d8b4121c1b015c60104a685feb929a29d7cf204387c7f2688c7974690"
56+
end
57+
58+
resource "requests" do
59+
url "https://files.pythonhosted.org/packages/63/70/2bf7780ad2d390a8d301ad0b550f1581eadbd9a20f896afe06353c2a2913/requests-2.32.3.tar.gz"
60+
sha256 "55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"
61+
end
62+
63+
resource "sentry-sdk" do
64+
url "https://files.pythonhosted.org/packages/3c/23/6527e56fb17817153c37d702d6b9ed0a2f75ed213fd98a176c1b8894ad20/sentry_sdk-2.14.0.tar.gz"
65+
sha256 "1e0e2eaf6dad918c7d1e0edac868a7bf20017b177f242cefe2a6bcd47955961d"
66+
end
67+
68+
resource "six" do
69+
url "https://files.pythonhosted.org/packages/71/39/171f1c67cd00715f190ba0b100d606d440a28c93c7714febeca8b79af85e/six-1.16.0.tar.gz"
70+
sha256 "1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"
71+
end
72+
73+
resource "termcolor" do
74+
url "https://files.pythonhosted.org/packages/10/56/d7d66a84f96d804155f6ff2873d065368b25a07222a6fd51c4f24ef6d764/termcolor-2.4.0.tar.gz"
75+
sha256 "aab9e56047c8ac41ed798fa36d892a37aca6b3e9159f3e0c24bc64a9b3ac7b7a"
76+
end
77+
78+
resource "typeguard" do
79+
url "https://files.pythonhosted.org/packages/8d/e1/3178b3e5369a98239ed7301e3946747048c66f4023163d55918f11b82d4e/typeguard-4.3.0.tar.gz"
80+
sha256 "92ee6a0aec9135181eae6067ebd617fd9de8d75d714fb548728a4933b1dea651"
81+
end
82+
83+
resource "typing-extensions" do
84+
url "https://files.pythonhosted.org/packages/df/db/f35a00659bc03fec321ba8bce9420de607a1d37f8342eee1863174c69557/typing_extensions-4.12.2.tar.gz"
85+
sha256 "1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"
86+
end
87+
88+
resource "urllib3" do
89+
url "https://files.pythonhosted.org/packages/ed/63/22ba4ebfe7430b76388e7cd448d5478814d3032121827c12a2cc287e2260/urllib3-2.2.3.tar.gz"
90+
sha256 "e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9"
91+
end
92+
93+
def install
5194

5295
# Copy everything except certain directories
5396
prefix.install Dir["*"]
@@ -58,10 +101,9 @@ def install
58101
rm_rf prefix/".github"
59102
rm_rf prefix/".vscode"
60103

61-
62104
# Set permissions for scripts
63-
chmod 0755, prefix/"scripts/setup-docker-compose.sh"
64-
chmod 0755, prefix/"scripts/configure-cli-for-docker-compose.sh"
105+
# chmod 0755, prefix/"scripts/setup-docker-compose.sh"
106+
# chmod 0755, prefix/"scripts/configure-cli-for-docker-compose.sh"
65107

66108
# These scripts must be run in the prefix directory to generate the files in the correct location
67109
Dir.chdir(prefix) do
@@ -70,56 +112,55 @@ def install
70112
system "./scripts/setup-docker-compose.sh"
71113
raise "Setup script failed" unless $?.success?
72114

73-
# # NOTE: Viv must be available via the command line before this is run.
115+
# NOTE: Viv must be available via the command line before this is run.
74116
# system "./scripts/configure-cli-for-docker-compose.sh"
75117
# raise "Configuration script failed" unless $?.success?
76118
end
77119

78-
def cli_setup
79-
# TODO: Set up a "developer install" of the CLI. Is this useful or should they just work from a cloned repo?
80-
# TODO: Include Version: 1.0.0 from the pyproject.toml file
81-
Dir.chdir(prefix) do
82-
# Install python dependencies
83-
system "python3 -m venv venv"
84-
system "source ./venv/bin/activate"
85-
# Makes the CLI available in the command line
86-
# Non-editable mode are slightly faster, but editable mode is better for development
87-
if DEV_MODE then
88-
system "pip install -e cli"
89-
else
90-
system "pip install cli"
91-
end
92-
end
93-
94-
# # Create necessary symlinks (to either /usr/local/bin or /opt/homebrew/bin)
95-
# # This is properly set up by homebrew, but this sets up the files in the CWD.
96-
# bin.install_symlink prefix/"scripts/setup-docker-compose.sh" => "vivaria-setup"
97-
# bin.install_symlink prefix/"scripts/configure-cli-for-docker-compose.sh" => "vivaria-cli-setup"
98-
99-
100-
# etc = editable text configurations
101-
# It is non-standard for homebrew to use ~/.config or ~/.<name> for configuration
102-
# Rather, it prefers to use /opt/homebrew/etc/<name> or /usr/local/etc/<name>
103-
# Create a directory for user configurations
120+
# def cli_setup
121+
# # TODO: Set up a "developer install" of the CLI. Is this useful or should they just work from a cloned repo?
122+
# Dir.chdir(prefix) do
123+
124+
# venv = libexec/"venv"
125+
# ENV["VIRTUAL_ENV"] = venv
126+
# venv.mkpath
127+
# system "python3", "-m", "venv", venv
128+
129+
# with_env(PATH: "#{venv}/bin:#{ENV["PATH"]}") do
130+
# system "#{venv}/bin/pip", "install", "-v", "--no-deps", buildpath/"cli"
131+
# end
132+
133+
# # Create the wrapper script in the bin directory
134+
# (bin/"viv").write <<~EOS
135+
# #!/bin/bash
136+
# VENV_PATH="#{venv}"
137+
# source "$VENV_PATH/bin/activate"
138+
# "$VENV_PATH/bin/viv" "$@"
139+
# deactivate
140+
# EOS
141+
# chmod 0755, bin/"viv"
142+
# end
143+
104144
(etc/"vivaria").mkpath
105145

106-
# If there's a default configuration file, copy it to the etc directory
107-
# cp buildpath/"config.default", etc/"vivaria/config" if File.exist? buildpath/"config.default"
108146
end
109147

110-
def post_install
111-
ohai "Lol"
112-
end
113148
# Information displayed after installation
114149
def caveats
115150
<<~EOS
116-
TODO: Add post-installation instructions here
117-
This will include steps to set up and run the Docker server
151+
Post-installation instructions:
152+
153+
To set up and run the Docker server, run:
154+
viv setup-docker-compose
155+
156+
For more information, visit:
157+
https://vivaria.metr.org/
118158
EOS
119159
end
120160

121-
# Test to ensure the formula was installed correctly
122161
test do
123-
# TODO: Add a simple test to check if the installation was successful
162+
# TODO: Make this test work.
163+
output = shell_output("#{bin}/viv --version")
164+
assert_match "vivaria version #{version}", output.strip
124165
end
125166
end

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,21 @@ Uncertain why this is needed before installing:
1717
`gem install ruby-lsp`
1818
`gem install debug`
1919

20+
https://rubydoc.brew.sh/Formula#homepage%3D-class_method
21+
22+
TODO: Use for language specific dependencies (resources):
23+
https://rubydoc.brew.sh/Formula#resource-class_method
24+
Ex: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/j/jrnl.rb
25+
26+
TODO: Add man pages to `prefix/share/man`
27+
TODO: Add docs to `prefix/share/doc/<name>`
2028

2129
TODO: Make a `.gitattributes` file to exclude files from releases for install.
2230

31+
TODO: `brew audit --strict --online` to check whether this fits the brew style guide.
32+
33+
I really should have just read the docs.
34+
2335
## How do I install these formulae?
2436

2537
`brew tap gatlenculp/vivaria` and then `brew install vivaria`.

0 commit comments

Comments
 (0)