diff --git a/Formula/poetry.rb b/Formula/poetry.rb index a6f51739317b..5db074105743 100644 --- a/Formula/poetry.rb +++ b/Formula/poetry.rb @@ -17,7 +17,8 @@ class Poetry < Formula sha256 cellar: :any_skip_relocation, x86_64_linux: "e33f71e0e2507519a6f11ecf51fc9657f932d01676ddf98186c55931441d4116" end - depends_on "python@3.9" + depends_on "python@3.9" => :test + depends_on "python@3.10" depends_on "six" resource "backports.entry-points-selectable" do @@ -80,11 +81,6 @@ class Poetry < Formula sha256 "9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d" end - resource "importlib-metadata" do - url "https://files.pythonhosted.org/packages/2e/6d/4508b1922b1610f6646fd95681fa1b0c092df35ec14018218f4638b7342a/importlib_metadata-4.8.2.tar.gz" - sha256 "75bdec14c397f528724c1bfd9709d660b33a4d2e77387a3358f20b848bb5e5fb" - end - resource "keyring" do url "https://files.pythonhosted.org/packages/19/c7/e1a9c556745518c9c3d46613c10a968757b16e29341ec8e0815fd07e0f93/keyring-21.8.0.tar.gz" sha256 "1746d3ac913d449a090caf11e9e4af00e26c3f7f7e81027872192b2398b98675" @@ -165,11 +161,6 @@ class Poetry < Formula sha256 "d7a454f319a7e9bd2e249f239168729327e4dd2d27b17dc68be264ad1ce36754" end - resource "typing-extensions" do - url "https://files.pythonhosted.org/packages/1a/23/748b0c9a5578110b31580c8d2643319adcb3ec91f601b50a955051b51f1d/typing_extensions-4.0.0.tar.gz" - sha256 "2cdf80e4e04866a9b3689a51869016d36db0814d84b8d8a568d22781d45d27ed" - end - resource "urllib3" do url "https://files.pythonhosted.org/packages/80/be/3ee43b6c5757cabea19e75b8f46eaf05a2f5144107d7db48c7cf3a864f73/urllib3-1.26.7.tar.gz" sha256 "4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece" @@ -185,44 +176,13 @@ class Poetry < Formula sha256 "b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923" end - resource "zipp" do - url "https://files.pythonhosted.org/packages/02/bf/0d03dbdedb83afec081fefe86cae3a2447250ef1a81ac601a9a56e785401/zipp-3.6.0.tar.gz" - sha256 "71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832" - end - def install - xy = Language::Python.major_minor_version Formula["python@3.9"].opt_bin/"python3" - - 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 Formula["python@3.9"].opt_bin/"python3", *Language::Python.setup_install_args(libexec/"vendor") - end - end - - site_packages = libexec/"lib/python#{xy}/site-packages" - ENV.prepend_create_path "PYTHONPATH", site_packages - system Formula["python@3.9"].opt_bin/"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 - #!/usr/bin/env 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 + virtualenv_install_with_resources # 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 @@ -241,5 +201,16 @@ def install assert_predicate testpath/"homebrew/poetry.lock", :exist? assert_match "requests", (testpath/"homebrew/pyproject.toml").read assert_match "boto3", (testpath/"homebrew/pyproject.toml").read + + # Check using different python versions + # See https://github.com/Homebrew/homebrew-core/issues/62910 + pythons = deps.map(&:to_formula).select { |f| f.name.match?(/^python@3\.\d+$/) } + cd testpath/"homebrew" do + inreplace "pyproject.toml", /^python = "\^3.*"/, 'python = "^3"' + pythons.each do |python| + system bin/"poetry", "env", "use", python.opt_bin/"python3" + assert_match python.version.to_s, shell_output("#{bin}/poetry run python --version") + end + end end end diff --git a/pypi_formula_mappings.json b/pypi_formula_mappings.json index 9f3a5fbd94ef..124a7bff38de 100644 --- a/pypi_formula_mappings.json +++ b/pypi_formula_mappings.json @@ -237,8 +237,7 @@ "exclude_packages": ["tabulate"] }, "poetry": { - "exclude_packages": ["six"], - "extra_packages": ["importlib-metadata", "typing-extensions"] + "exclude_packages": ["six"] }, "pre-commit": { "exclude_packages": ["six"]