poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Use env vars if either `--username` or `--password` (or both) is missing

Open dszakallas opened this issue 2 years ago • 1 comments

Pull Request Check List

Resolves: #5526

  • [ ] Added tests for changed code.
  • [ ] Updated documentation for changed code.

This PR changes authentication logic for publishing:

  • If both username and password is missing, consider PyPI token env var.
  • If no PyPI token and either username or password is missing, consider http basic env var for the missing field.

Previously, env vars were only considered if both CLI options where missing. This PR effectively makes it possible to mix the CLI options with the env vars.

This way both

poetry config repositories.myrepo $REPO_URL \
  && POETRY_HTTP_BASIC_MYREPO_PASSWORD=$PASSWORD \
     poetry publish -r myrepo -u $USERNAME

poetry config repositories.myrepo $REPO_URL \
  && POETRY_HTTP_BASIC_MYREPO_USERNAME=$USERNAME \
     poetry publish -r myrepo -p $PASSWORD

will work. I am doubtful about whether it is worth supporting the second use case.

dszakallas avatar May 09 '22 21:05 dszakallas

I'm still not sure on this myself, but I would like to see tests (plus dropping the second case) to consider this for merging.

neersighted avatar Jun 04 '22 04:06 neersighted