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: invoke poetry.console.main instead of using env_script_all_files #51121

Closed
wants to merge 1 commit 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
20 changes: 16 additions & 4 deletions Formula/poetry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Poetry < Formula
homepage "https://python-poetry.org/"
url "https://files.pythonhosted.org/packages/2c/79/7fc6e1ac5ebff02e39f24a17ddf56ef6370797a8371e6cfc5c7b56d3a1ea/poetry-1.0.5.tar.gz"
sha256 "8e195ea8a4bce4f418a23fd828aa2f9ce06be7655720efd1d95beb0ee641030a"
revision 1

bottle do
cellar :any_skip_relocation
Expand Down Expand Up @@ -173,18 +174,29 @@ class Poetry < Formula
def install
xy = Language::Python.major_minor_version "python3"

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

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

bin.install libexec/"bin/poetry"
bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"])
(bin/"poetry").write <<~PYTHON
#!#{Formula["python"].opt_bin/"python3"}
import sys

sys.path.insert(0, "#{site_packages}")
sys.path.insert(0, "#{vendor_site_packages}")

if __name__ == "__main__":
from poetry.console import main
main()
PYTHON
end

test do
Expand Down