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

Fix poetry show package dir #182

Merged
merged 7 commits into from
Dec 18, 2023

Conversation

blast-hardcheese
Copy link
Collaborator

@blast-hardcheese blast-hardcheese commented Dec 15, 2023

How poetry calculates the env path has changed, so instead of trying to guess, just delegate to poetry env. If the environment hasn't been created we don't get a path, which is only relevant if we're in a completely blank environment, so it's hopefully not that bad.

  • Renaming Python3Backend to PythonPoetryBackend
  • Rely on poetry env list to find the active environment
  • General housekeeping

@blast-hardcheese blast-hardcheese requested a review from a team as a code owner December 15, 2023 20:48
@blast-hardcheese blast-hardcheese requested review from cdmistman and removed request for a team December 15, 2023 20:48
@blast-hardcheese blast-hardcheese added the bug Something isn't working label Dec 15, 2023
@blast-hardcheese blast-hardcheese enabled auto-merge (squash) December 15, 2023 23:16
@blast-hardcheese
Copy link
Collaborator Author

A question from @airportyh around how to test this seems to have been eaten by GitHub, but the following is an example:

upm (nix) ((f547cb7...)) dstewart$ cd /tmp/poetry-test
poetry-test (nix) dstewart$ ~/Projects/upm/cmd/upm/upm show-package-dir
--> poetry env list --full-path
poetry-test (nix) dstewart$ ~/Projects/upm/cmd/upm/upm add requests
--> poetry add requests
Creating virtualenv poetry-test-cX6xfNfC-py3.10 in /Users/dstewart/Library/Caches/pypoetry/virtualenvs
Using version ^2.31.0 for requests

Updating dependencies
Resolving dependencies... (0.2s)

Package operations: 5 installs, 0 updates, 0 removals

  • Installing certifi (2023.11.17)
  • Installing charset-normalizer (3.3.2)
  • Installing idna (3.6)
  • Installing urllib3 (2.1.0)
  • Installing requests (2.31.0)

Writing lock file
poetry-test (nix) dstewart$ ~/Projects/upm/cmd/upm/upm show-package-dir
--> poetry env list --full-path
/Users/dstewart/Library/Caches/pypoetry/virtualenvs/poetry-test-cX6xfNfC-py3.10

Since we are delegating the show-package-dir subcommand directly to poetry env list, the virtualenv doesn't exist until the first time a package operation has been performed, hence the result being empty in the first invocation.

The logic we had before didn't work and didn't support all of the functionaity available in Poetry.

Better to not be able to look up the path if the path is wrong than to not be able to give reliably correct results.
@blast-hardcheese blast-hardcheese force-pushed the dstewart/fix-poetry-show-package-dir branch from 9a02a42 to 1ffaff6 Compare December 18, 2023 20:45
Copy link
Contributor

@cdmistman cdmistman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool! thanks!

@blast-hardcheese blast-hardcheese merged commit f513fa3 into main Dec 18, 2023
2 checks passed
@blast-hardcheese blast-hardcheese deleted the dstewart/fix-poetry-show-package-dir branch December 18, 2023 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants