rye icon indicating copy to clipboard operation
rye copied to clipboard

Supporting `.pypirc` in publish command

Open cnpryer opened this issue 1 year ago • 3 comments

Assuming #759 is merged, it'd be nice to add --config-file dispatch to more consciously support .pypirc (I can't remember if Twine will dynamically load this with incomplete arguments).

It might be nice to implement this so that .pypirc can be used in place of Rye's credentials management.

So something like this would tell Rye to disregard managed credentials in favor of the .pypirc file.

rye publish --config-file <path>

And if this pattern works well, we could extend it to support other credentials files.

Originally posted by @cnpryer in https://github.com/astral-sh/rye/issues/759#issuecomment-1963112728

cnpryer avatar Feb 26 '24 17:02 cnpryer

Just found this crate from Charlie Marsh, it is probably what is needed to parse the .pypirc. I tried a little bit with expecting it to be a .toml and that didn't work out at all. I'm pretty sure a .INI-style is used.

https://github.com/charliermarsh/configparser-rs

I just figured I could share this here for future notice.

golgor avatar Mar 05 '24 14:03 golgor

Thanks @cnpryer for pointing this out.

Originally posted by @camilo-s in https://github.com/astral-sh/rye/issues/759#issuecomment-2037687739

Any chance that Twine's --config-file option could be dispatched as well? In my current use-case, this would support the TwineAuthenticate@1 task from Azure Pipelines

camilo-s avatar Apr 05 '24 07:04 camilo-s

@camilo-s just FYI, it is possible to supply them via command line in the current version or Rye. It should be possible to either get this information from Azure or setting it up locally on your machine and look at your local .pypirc. Everything is stored in clear text so it is just copy/pasting.

I.e. you wouldn't have to run the task TwineAuthenticated-task at all. I have this in my Github Action when publishing to a private repo on Google Cloud:

rye publish -r ${{ env.REPO_NAME }} --repository-url ${{ env.REPO_URL }} --username ${{ env.USERNAME }} --token ${{ env.PASSWORD }} -y

And that works great for me.

golgor avatar Apr 05 '24 12:04 golgor