Merge pull request #7146 from Bo98/virtualenv

language/python: fix virtualenv symlinks for versioned Python
This commit is contained in:
Michka Popoff 2020-03-10 22:29:34 +01:00 committed by GitHub
commit a0cdfe176e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -220,14 +220,21 @@ module Language
next unless f.symlink?
next unless (rp = f.realpath.to_s).start_with? HOMEBREW_CELLAR
new_target = rp.sub %r{#{HOMEBREW_CELLAR}/python/[^/]+}, Formula["python"].opt_prefix
version = rp.match %r{^#{HOMEBREW_CELLAR}/python@(.*?)/}
version = "@#{version.captures.first}" unless version.nil?
new_target = rp.sub %r{#{HOMEBREW_CELLAR}/python#{version}/[^/]+}, Formula["python#{version}"].opt_prefix
f.unlink
f.make_symlink new_target
end
Pathname.glob(@venv_root/"lib/python*/orig-prefix.txt").each do |prefix_file|
prefix_path = prefix_file.read
prefix_path.sub! %r{^#{HOMEBREW_CELLAR}/python/[^/]+}, Formula["python"].opt_prefix
version = prefix_path.match %r{^#{HOMEBREW_CELLAR}/python@(.*?)/}
version = "@#{version.captures.first}" unless version.nil?
prefix_path.sub! %r{^#{HOMEBREW_CELLAR}/python#{version}/[^/]+}, Formula["python#{version}"].opt_prefix
prefix_file.atomic_write prefix_path
end
end