Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up Homebrew installation by shipping a Bottle #102

Closed
simonw opened this issue Jul 12, 2023 · 6 comments
Closed

Speed up Homebrew installation by shipping a Bottle #102

simonw opened this issue Jul 12, 2023 · 6 comments
Labels
help wanted Extra attention is needed research

Comments

@simonw
Copy link
Owner

simonw commented Jul 12, 2023

The downside of my current Homebrew installation flow is that it doesn't use Python wheels, which actually makes it massively slower than installing using pip or pipx.

Originally posted by @simonw in #101 (comment)

simonw added a commit that referenced this issue Jul 12, 2023
@simonw
Copy link
Owner Author

simonw commented Jul 12, 2023

I think the answer is Bottles: https://docs.brew.sh/Bottles

@simonw
Copy link
Owner Author

simonw commented Jul 12, 2023

I ran this on my Mac laptop:

brew uninstall llm             
brew install --build-bottle llm

Then after that finished (it took ages):

cd /tmp
mkdir bottles
cd bottles
brew bottle llm

Here's the output from that command:

==> Determining simonw/llm/llm bottle rebuild...
==> Bottling llm--0.5.arm64_ventura.bottle.1.tar.gz...
==> Detecting if llm--0.5.arm64_ventura.bottle.1.tar.gz is relocatable...
./llm--0.5.arm64_ventura.bottle.1.tar.gz
  bottle do
    rebuild 1
    sha256 cellar: :any, arm64_ventura: "1548e2cf86208c93f766f271cf2f98fbad77b47a48ebfd804665d5210c144735"
  end

And it created a 5.9MB file:

llm--0.5.arm64_ventura.bottle.1.tar.gz

When I extracted that I got a llm folder like this (truncated):

llm/0.5
llm/0.5/INSTALL_RECEIPT.json
llm/0.5/LICENSE
llm/0.5/bin
llm/0.5/bin/llm
llm/0.5/.brew
llm/0.5/.brew/llm.rb
llm/0.5/libexec
llm/0.5/libexec/bin
llm/0.5/libexec/bin/Activate.ps1
llm/0.5/libexec/bin/llm
llm/0.5/libexec/bin/python3
llm/0.5/libexec/bin/python
llm/0.5/libexec/bin/pip3
llm/0.5/libexec/bin/activate.fish
...
llm/0.5/libexec/lib/python3.11/site-packages
llm/0.5/libexec/lib/python3.11/site-packages/multidict-6.0.4.dist-info
llm/0.5/libexec/lib/python3.11/site-packages/multidict-6.0.4.dist-info/RECORD
...
llm/0.5/libexec/lib/python3.11/site-packages/certifi-2023.5.7-py3.11.egg-info/dependency_links.txt
llm/0.5/README.md

Which included this file:

llm/0.5/libexec/lib/python3.11/site-packages/pydantic_core/_pydantic_core.cpython-311-darwin.so

Suggesting that the binary used by Pydantic is bundled that way.

@simonw
Copy link
Owner Author

simonw commented Jul 12, 2023

@simonw
Copy link
Owner Author

simonw commented Jul 12, 2023

Wow installing that is a lot faster:

time brew install llm--0.5.arm64_ventura.bottle.1.tar.gz
==> Fetching simonw/llm/llm
==> Installing llm from simonw/llm
==> Pouring llm--0.5.arm64_ventura.bottle.1.tar.gz
🍺  /opt/homebrew/Cellar/llm/0.5: 1,468 files, 19.8MB
==> Running `brew cleanup llm`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
brew install llm--0.5.arm64_ventura.bottle.1.tar.gz  1.39s user 1.00s system 89% cpu 2.661 total

@simonw
Copy link
Owner Author

simonw commented Jul 19, 2023

I don't yet know how to modify the https://github.com/simonw/homebrew-llm/blob/main/Formula/llm.rb file such that running brew install simonw/llm/llm downloads and installs from that bottle.

I also don't know how to use GitHub Actions to automate the process of compiling and publishing that bottle. I'm worried that might be blocked by the fact that GitHub Actions macOS runners are only Intel, not Apple Silicon.

@simonw simonw added the help wanted Extra attention is needed label Jul 19, 2023
@simonw simonw changed the title Speed up Homebrew installation Speed up Homebrew installation by shipping a Bottle Jul 19, 2023
@simonw
Copy link
Owner Author

simonw commented Jul 24, 2023

No need to do this any more - I got it accepted into Homebrew core:

@simonw simonw closed this as completed Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed research
Projects
None yet
Development

No branches or pull requests

1 participant