Skip to content

Commit 9e97303

Browse files
authored
Merge pull request #247811 from Homebrew/certifi-single-build
certifi: build once and symlink
2 parents 46f20cb + 985b74b commit 9e97303

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

Formula/c/certifi.rb

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,40 @@ class Certifi < Formula
44
url "https://files.pythonhosted.org/packages/4c/5b/b6ce21586237c77ce67d01dc5507039d444b630dd76611bbca2d8e5dcd91/certifi-2025.10.5.tar.gz"
55
sha256 "47c09d31ccf2acf0be3f701ea53595ee7e0b8fa08801c6624be771df09ae7b43"
66
license "MPL-2.0"
7+
revision 1
78

89
bottle do
9-
sha256 cellar: :any_skip_relocation, all: "de6342b72b69a473c6420dc822d0e103989bb68d8d06bc28fce4d82ec2da376f"
10+
sha256 cellar: :any_skip_relocation, all: "d1eb3e86754cc51d5fb9513b6067c75fd90005cea0fab11134f6a7b482989015"
1011
end
1112

12-
depends_on "python@3.12" => [:build, :test]
13-
depends_on "python@3.13" => [:build, :test]
13+
depends_on "python@3.14" => [:build, :test]
14+
depends_on "python@3.12" => :test # keep on oldest python to support (externally managed and not EOL)
1415
depends_on "ca-certificates"
1516

1617
def pythons
17-
deps.map(&:to_formula).sort_by(&:version).filter { |f| f.name.start_with?("python@") }
18+
deps.filter_map { |dep| dep.to_formula if dep.name.start_with?("python@") }
1819
end
1920

2021
def install
21-
pythons.each do |python|
22-
python_exe = python.opt_libexec/"bin/python"
23-
system python_exe, "-m", "pip", "install", *std_pip_args(build_isolation: true), "."
22+
oldest_python, python = pythons.sort_by(&:version)
23+
python_exe = python.opt_libexec/"bin/python"
24+
system python_exe, "-m", "pip", "install", *std_pip_args(build_isolation: true), "."
25+
26+
# Use brewed ca-certificates PEM file instead of the bundled copy
27+
site_packages = prefix/Language::Python.site_packages(python_exe)
28+
rm site_packages/"certifi/cacert.pem"
29+
(site_packages/"certifi").install_symlink Formula["ca-certificates"].pkgetc/"cert.pem" => "cacert.pem"
30+
31+
link_dirs = site_packages.children - [site_packages/"certifi"]
32+
python.versioned_formulae.each do |extra_python|
33+
next if extra_python.version < oldest_python.version
34+
35+
# Cannot use Python.site_packages as that requires formula to be installed
36+
extra_site_packages = lib/"python#{extra_python.version.major_minor}/site-packages"
37+
extra_site_packages.install_symlink link_dirs
2438

25-
# Use brewed ca-certificates PEM file instead of the bundled copy
26-
site_packages = Language::Python.site_packages("python#{python.version.major_minor}")
27-
rm prefix/site_packages/"certifi/cacert.pem"
28-
(prefix/site_packages/"certifi").install_symlink Formula["ca-certificates"].pkgetc/"cert.pem" => "cacert.pem"
39+
# Symlink grandchildren so cache ends up in correct directory
40+
(extra_site_packages/"certifi").install_symlink site_packages.glob("certifi/*")
2941
end
3042
end
3143

0 commit comments

Comments
 (0)