/
uv.rb
69 lines (57 loc) 路 2.83 KB
/
uv.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class Uv < Formula
desc "Extremely fast Python package installer and resolver, written in Rust"
homepage "https://github.com/astral-sh/uv"
url "https://github.com/astral-sh/uv/archive/refs/tags/0.1.39.tar.gz"
sha256 "28e030baa64704f7929cee3b25842a54f1df978154d8a8155d4f6b817657d058"
license any_of: ["Apache-2.0", "MIT"]
head "https://github.com/astral-sh/uv.git", branch: "main"
bottle do
sha256 cellar: :any, arm64_sonoma: "7feef25c67a6222d1575aada0cb3ca72e8b4a08f0c849fff5801dfad05565c86"
sha256 cellar: :any, arm64_ventura: "569d62517f6b91dd2acbf38f71706362ae1637dfbeff1539f7d4701304e5629e"
sha256 cellar: :any, arm64_monterey: "d8451f81e887c01da944dc4204d0a420c6c56be5da7b6c322bf4bf6e4f9198dd"
sha256 cellar: :any, sonoma: "1a7bcb927e6b8177eb411d546c204b406dbb35c36e2cc175a4a9476563b71dd1"
sha256 cellar: :any, ventura: "9311a9f7c0f158b4e5258bb35f04b087e84c7b3af5a6fb1ee80ea645ed301b07"
sha256 cellar: :any, monterey: "11476c35d653375c80f9696080ab631209c672b63eecfd5c86b7a92dc8287da2"
sha256 cellar: :any_skip_relocation, x86_64_linux: "1dadfc41a0c67917691b86fb906e0978d8ba6abdfcc50223b839a27591d7032a"
end
depends_on "pkg-config" => :build
depends_on "rust" => :build
depends_on "libgit2"
depends_on "openssl@3"
uses_from_macos "python" => :test
on_linux do
# On macOS, bzip2-sys will use the bundled lib as it cannot find the system or brew lib.
# We only ship bzip2.pc on Linux which bzip2-sys needs to find library.
depends_on "bzip2"
end
def install
ENV["LIBGIT2_NO_VENDOR"] = "1"
# Ensure that the `openssl` crate picks up the intended library.
ENV["OPENSSL_DIR"] = Formula["openssl@3"].opt_prefix
ENV["OPENSSL_NO_VENDOR"] = "1"
system "cargo", "install", "--no-default-features", *std_cargo_args(path: "crates/uv")
generate_completions_from_executable(bin/"uv", "generate-shell-completion")
end
def check_binary_linkage(binary, library)
binary.dynamically_linked_libraries.any? do |dll|
next false unless dll.start_with?(HOMEBREW_PREFIX.to_s)
File.realpath(dll) == File.realpath(library)
end
end
test do
(testpath/"requirements.in").write <<~EOS
requests
EOS
compiled = shell_output("#{bin}/uv pip compile -q requirements.in")
assert_match "This file was autogenerated by uv", compiled
assert_match "# via requests", compiled
[
Formula["libgit2"].opt_lib/shared_library("libgit2"),
Formula["openssl@3"].opt_lib/shared_library("libssl"),
Formula["openssl@3"].opt_lib/shared_library("libcrypto"),
].each do |library|
assert check_binary_linkage(bin/"uv", library),
"No linkage with #{library.basename}! Cargo is likely using a vendored version."
end
end
end