Skip to content
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

poetry: migrate to [email protected] #86776

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions Formula/poetry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Poetry < Formula
url "https://files.pythonhosted.org/packages/57/93/30798f4df5633eaae1de4d851428fa72d281f949366c116eb21ed41530c5/poetry-1.1.11.tar.gz"
sha256 "7d7d22f55fbebb830cc85b1c69cd7a91fd85f49e5396e7a14b953645a470f69e"
license "MIT"
revision 1

bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "1d5b4426cff6cce5bce2d71bd91f4e6f24dd3b7437dfad54839dc113fe360e7a"
Expand All @@ -15,7 +16,7 @@ class Poetry < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "e33f71e0e2507519a6f11ecf51fc9657f932d01676ddf98186c55931441d4116"
end

depends_on "python@3.9"
depends_on "python@3.10"
depends_on "six"

resource "backports.entry-points-selectable" do
Expand Down Expand Up @@ -189,23 +190,21 @@ class Poetry < Formula
end

def install
xy = Language::Python.major_minor_version Formula["[email protected]"].opt_bin/"python3"

vendor_site_packages = libexec/"vendor/lib/python#{xy}/site-packages"
vendor_site_packages = libexec/"vendor"/Language::Python.site_packages("python3")
ENV.prepend_create_path "PYTHONPATH", vendor_site_packages
resources.each do |r|
r.stage do
system Formula["[email protected]"].opt_bin/"python3", *Language::Python.setup_install_args(libexec/"vendor")
system "python3", *Language::Python.setup_install_args(libexec/"vendor")
end
end

site_packages = libexec/"lib/python#{xy}/site-packages"
site_packages = libexec/Language::Python.site_packages("python3")
ENV.prepend_create_path "PYTHONPATH", site_packages
system Formula["[email protected]"].opt_bin/"python3", *Language::Python.setup_install_args(libexec)
system "python3", *Language::Python.setup_install_args(libexec)

# We don't hardcode Homebrew Python here on purpose. See
# https://github.com/Homebrew/homebrew-core/issues/62910
(bin/"poetry").write <<~PYTHON
(libexec/"bin/poetry").atomic_write <<~PYTHON
#!/usr/bin/env python3
import sys

Expand All @@ -217,10 +216,14 @@ def install
main()
PYTHON

# Make sure Poetry can find our keg-only Python, but don't override the user's Python
(bin/"poetry").write_env_script libexec/"bin/poetry",
PATH: "${PATH:+${PATH}:}#{Formula["[email protected]"].opt_bin}"

# Install shell completions
(bash_completion/"poetry").write Utils.safe_popen_read("#{libexec}/bin/poetry", "completions", "bash")
(fish_completion/"poetry.fish").write Utils.safe_popen_read("#{libexec}/bin/poetry", "completions", "fish")
(zsh_completion/"_poetry").write Utils.safe_popen_read("#{libexec}/bin/poetry", "completions", "zsh")
(bash_completion/"poetry").write Utils.safe_popen_read(libexec/"bin/poetry", "completions", "bash")
(fish_completion/"poetry.fish").write Utils.safe_popen_read(libexec/"bin/poetry", "completions", "fish")
(zsh_completion/"_poetry").write Utils.safe_popen_read(libexec/"bin/poetry", "completions", "zsh")
end

test do
Expand Down