Merge pull request #18129 from cho-m/python-macos-linux-diffs

This commit is contained in:
Mike McQuaid 2024-08-23 08:07:25 +01:00 committed by GitHub
commit 69ae7eecd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -350,6 +350,18 @@ module Language
prefix_file.atomic_write prefix_path
end
# Reduce some differences between macOS and Linux venv
lib64 = @venv_root/"lib64"
lib64.make_symlink "lib" unless lib64.exist?
if (cfg_file = @venv_root/"pyvenv.cfg").exist?
cfg = cfg_file.read
framework = "Frameworks/Python.framework/Versions"
cfg.match(%r{= *(#{HOMEBREW_CELLAR}/(python@[\d.]+)/[^/]+(?:/#{framework}/[\d.]+)?/bin)}) do |match|
cfg.sub! match[1].to_s, Formula[match[2]].opt_bin
cfg_file.atomic_write cfg
end
end
# Remove unnecessary activate scripts
(@venv_root/"bin").glob("[Aa]ctivate*").map(&:unlink)
end