-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
instructlab 0.21.2 (new formula) #200460
base: master
Are you sure you want to change the base?
instructlab 0.21.2 (new formula) #200460
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
class Instructlab < Formula | ||
include Language::Python::Virtualenv | ||
|
||
desc "Use a novel synthetic data-based alignment tuning method for LLMs" | ||
homepage "https://github.com/instructlab/instructlab" | ||
url "https://github.com/instructlab/instructlab/releases/download/v0.21.2/instructlab-0.21.2.tar.gz" | ||
sha256 "99c2ba360214005088f6ee1a94d60fb89c622e78e5b6c1d8df2f67b8cbf36fd3" | ||
license "Apache-2.0" | ||
|
||
depends_on "ccache" => :build | ||
depends_on "cmake" => :build | ||
depends_on "pkgconf" => :build | ||
depends_on "python@3.11" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not the latest? |
||
|
||
def fix_dylib_paths(target_files: nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This really shouldn't be part of a formula. If this is broken it should be reported to brew and fixed there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you so much for your feedback.This is my first time to write the formula. May I know any possible situations that will hit the |
||
require "macho" | ||
|
||
dylibs_path = libexec/"lib/python3.11/site-packages/PIL/.dylibs" | ||
files_to_process = target_files || dylibs_path.glob("*.dylib") | ||
|
||
files_to_process.each do |dylib| | ||
next unless dylib.exist? | ||
|
||
macho = MachO.open(dylib) | ||
|
||
new_id = "@loader_path/#{dylib.basename}" | ||
macho.change_dylib_id(new_id) | ||
|
||
macho.dylib_load_commands.each do |cmd| | ||
old_path = cmd.name.to_s | ||
next unless old_path.include?("PIL/.dylibs") | ||
|
||
new_path = "@loader_path/#{File.basename(old_path)}" | ||
macho.change_install_name(old_path, new_path) | ||
end | ||
|
||
macho.write! | ||
|
||
MachO.codesign!(dylib) | ||
|
||
validation_output = `otool -L #{dylib}` | ||
if validation_output.include?("@loader_path/#{dylib.basename}") | ||
ohai "Successfully fixed and validated: #{dylib.basename}" | ||
else | ||
opoo "Validation failed for: #{dylib.basename}. Please check manually using `otool -L #{dylib}`." | ||
end | ||
end | ||
end | ||
|
||
# Fix -flat_namespace being used on Big Sur and later. | ||
patch do | ||
url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-big_sur.diff" | ||
sha256 "35acd6aebc19843f1a2b3a63e880baceb0f5278ab1ace661e57a502d9d78c93c" | ||
end | ||
Comment on lines
+50
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be reported and fixed upstream There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just hit -flat_namespace in local test, so tried to add it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If that's the case the upstream configure script should be regenerated with a modern version of autoconf. This was fixed years ago. |
||
|
||
def install | ||
Check failure on line 56 in Formula/i/instructlab.rb GitHub Actions / Linux`brew install --verbose --formula --build-bottle instructlab` failed on Linux!
Check failure on line 56 in Formula/i/instructlab.rb GitHub Actions / macOS 15-arm64`brew install --verbose --formula --build-bottle instructlab` failed on macOS Sequoia (15) on Apple Silicon!
Check failure on line 56 in Formula/i/instructlab.rb GitHub Actions / macOS 14-arm64`brew install --verbose --formula --build-bottle instructlab` failed on macOS Sonoma (14) on Apple Silicon!
|
||
odie "This tool only supports Apple Silicon (M1/M2/M3) systems. Installation aborted." unless Hardware::CPU.arm? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That should be |
||
|
||
venv = virtualenv_create(libexec, "python3.11", system_site_packages: false) | ||
system libexec/"bin/python", "-m", "ensurepip" | ||
system libexec/"bin/python", "-m", "pip", "install", "--upgrade", "pip", "setuptools", "wheel" | ||
system libexec/"bin/python", "-m", "pip", "cache", "remove", "llama_cpp_python" | ||
venv.pip_install_and_link buildpath | ||
system libexec/"bin/python", "-m", "pip", "install", "-r", buildpath/"requirements.txt" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not allowed, all downloads should be resources There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please share a good example of this(similar with this install with pip and python project)? thanks a lot. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anything in this repo that mentions venv will probably do exactly that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May i confirm only can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All resources for Homebrew formula need to be built from source. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an Depending on Homebrew formulae means less time spent compiling dependencies (because other Homebrew formulae have already been compiled before), not more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, yeah, already used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, I still can see some using
I mean I tried many times on some packages, still failed, e.g.
so I would like to try .whl, if you have any ideas, feel free to share, thanks a lot. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is only accepted when the |
||
|
||
# Replace universal binaries with native slices. | ||
deuniversalize_machos | ||
Comment on lines
+66
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it building universal binaries if it doesn't support non ARM? |
||
end | ||
|
||
def post_install | ||
# Fix dynamic library paths in PIL dependencies | ||
fix_dylib_paths(target_files: [libexec/"lib/python3.11/site-packages/PIL/.dylibs/libpng16.16.dylib"]) | ||
|
||
# Installation success message | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a caveat if it's specific to Homebrew and removed if it's not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I tried caveat, but it is strange, it called twice at the end.. |
||
ohai "✅ InstructLab has been installed successfully." | ||
ohai "Next Steps:" | ||
ohai " Run `ilab config init` to initialize your configuration." | ||
ohai "Use `ilab --help` to get started." | ||
end | ||
|
||
test do | ||
# check dylibs | ||
dylibs_path = libexec/"lib/python3.11/site-packages/PIL/.dylibs" | ||
|
||
dylib_path = dylibs_path/"libpng16.16.dylib" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use Homebrew libpng instead of vendoring a different one. |
||
if dylib_path.exist? | ||
otool_output = shell_output("otool -L #{dylib_path}") | ||
assert_match "@loader_path/libpng16.16.dylib", otool_output, "Incorrect or missing path in dylib linkage" | ||
end | ||
# Verify installation and functionality of the CLI tool | ||
assert_match "Usage:", shell_output("#{bin}/ilab --help") | ||
EricFromCanada marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean why use "ccache"? I also tested from different local machines, one need, another is no need, I not sure whether missed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can you tell it needs ccache?