nox-poetry icon indicating copy to clipboard operation
nox-poetry copied to clipboard

Allow installing packages from private indexes

Open dasm-tmlt opened this issue 1 year ago • 10 comments

Poetry allows dependencies to be installed from private package indexes (https://python-poetry.org/docs/repositories/#private-repository-example). This PR passes the extra indexes and credentials from poetry to pip so that they can be properly installed in nox.

Includes new and updated unit tests, and an integration test for private sources.

dasm-tmlt avatar Jan 10 '23 23:01 dasm-tmlt

@cjolowicz Is this something you can review? Can you suggest another reviewer? The contributing guide was a little unclear on that point :)

dasm-tmlt avatar Jan 18 '23 17:01 dasm-tmlt

I believe this is related to #887.

  • #887

MicaelJarniac avatar Jun 29 '23 12:06 MicaelJarniac

Bumping this @cjolowicz

FFace32 avatar Dec 11 '23 18:12 FFace32

Does this dump credentials in clear into the generated constraints file under .nox?

cjolowicz avatar Dec 12 '23 15:12 cjolowicz

Does this dump credentials in clear into the generated constraints file under .nox?

Yup, this adds --extra-index-urls inside .nox/<session>/tmp/requirements.txt.

In case you believe that's not always wanted, I could make it so this PR's code is disabled by default and only ran under a certain argument passed to export

FFace32 avatar Dec 12 '23 21:12 FFace32

Does this dump credentials in clear into the generated constraints file under .nox?

Yup, this adds --extra-index-urls inside .nox/<session>/tmp/requirements.txt.

In case you believe that's not always wanted, I could make it so this PR's code is disabled by default and only ran under a certain argument passed to export

I'm also happy to make revisions. If we want to go down the route of making the behavior optional, we'd want to plumb the option all the way to the session decorator so users can trigger the new behavior. I can definitely see the argument for doing so.

dasm-tmlt avatar Dec 12 '23 21:12 dasm-tmlt

Sorry but dumping secrets in the generated requirements file is not a behavior I want to support, even as an option. Please export the secrets as an environment variable for pip instead.

cjolowicz avatar Dec 17 '23 14:12 cjolowicz

Sorry but dumping secrets in the generated requirements file is not a behavior I want to support, even as an option. Please export the secrets as an environment variable for pip instead.

Ah, that does sound like a better approach, if a little less straightforward to implement. I'll make the changes.

dasm-tmlt avatar Dec 18 '23 22:12 dasm-tmlt

I don't think nox-poetry should handle credentials at all. You can export the secrets as environment variables in CI.

cjolowicz avatar Dec 19 '23 21:12 cjolowicz

You can, but I find that suggestion unsatisfying. Setting environment variables is not the recommended approach for using private sources with poetry, so users who follow the poetry instructions are likely going to have a tough time. Additionally, there's no way to set environment variables that will be used by both poetry and nox - the two require different environment variable names with different formats (poetry wants you to set POETRY_HTTP_BASIC_<SOURCE>_USERNAME=<username> and POETRY_HTTP_BASIC_<SOURCE>_PASSWORD=<password>, while to get nox to work you have to set PIP_EXTRA_INDEX_URL=https://<username>:<password>@<source_url>).

To me, the great thing about nox-poetry is that it pretty much just works. Requiring the user to set specific environment variables seems to break that.

While I do understand your concerns about dumping credentials to a file, I don't really see the issue with automatically populating those environment variables inside the nox session?

dasm-tmlt avatar Dec 20 '23 21:12 dasm-tmlt