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

Suggestion: add an env-var to define --config-file default location/value #559

Closed
iMoses opened this issue Jan 17, 2020 · 7 comments
Closed
Labels
enhancement question Discussion/decision needed from maintainers

Comments

@iMoses
Copy link

iMoses commented Jan 17, 2020

When running in CI, which is a standard use case for twine, it is often considered best practice to use a separate .pypirc file per job meaning that the --config-file cli arg is used a lot.

It would be nice to have an env-var such as TWINE_CONFIG_FILE to set the default for that globally, thus changing the default requirement for .pypirc to be at the home directory.

What says you, yay or nay? :)

@bhrutledge
Copy link
Contributor

This seems reasonable, given the other TWINE_ environment variables already in use. I'd wait for one of the other @pypa/twine-maintainers to sign-off before implementing it.

That said:

it is often considered best practice to use a separate .pypirc file per job

Can you elaborate on this? Do you have links to any docs/discussions that suggest this? What distinguishes the individual files?

@bhrutledge bhrutledge added feature request question Discussion/decision needed from maintainers enhancement and removed feature request labels Jan 18, 2020
@sigmavirus24
Copy link
Member

it is often considered best practice to use a separate .pypirc file per job

I've been working on F/OSS Python with CI for close to a decade and I've never heard of this.

I'm also not fond of providing invisible ways of swapping out where someone might be uploading to. CI configuration can be confusing enough that I'd be willing to bet as soon as someone starts using this they'll upload a private, proprietary package to public PyPI and freak out at us for letting them shoot themselves in the foot.

@iMoses
Copy link
Author

iMoses commented Jan 18, 2020

I've been working on F/OSS Python with CI for close to a decade and I've never heard of this.

Containers are changing quite a lot of practices in recent years as they provide new ways to solve old problems. Having our CI run using Jenkins and the Kubernetes plugin it makes sense for us to have .pypirc in locations other than the home directory, and deployment configurations can change dramatically between different repositories.

I'm also not fond of providing invisible ways of swapping out where someone might be uploading to. CI configuration can be confusing enough that I'd be willing to bet as soon as someone starts using this they'll upload a private, proprietary package to public PyPI and freak out at us for letting them shoot themselves in the foot.

I can understand that and even relate with it.

Perhaps a better suggestion is to have a twine.conf file to contain defaults for twine's CLI args. This way everything will be readable and consolidated in a single file. Maybe it's too big of a feature now, it's just a suggestion, I won't take offence if you decide to pass on it :)

@bhrutledge
Copy link
Contributor

@iMoses Out of curiosity, why aren't the existing environment variables sufficient?

https://twine.readthedocs.io/en/latest/#environment-variables

@iMoses
Copy link
Author

iMoses commented Jan 18, 2020

@bhrutledge technically they could be enough, as each deployment only requires a single set of username, password and repository. It's just easier and better organized in my opinion when we have all the configuration in a single .pypirc file as use the repository arg instead.

Currently my usage looks something like this:

twine upload dist/* --config-file ${WORK_DIR}/twine/.pypirc -r repo

@bhrutledge
Copy link
Contributor

Possibly related: #349 and #350. The comments there reminded me that .pypirc is not exclusive to Twine, so changes on where it's sourced from should be considered as part of the larger packaging ecosystem. In practice, I think that means it's not going to change in the near future.

Also, a quick scan of tools like pip, tox, and pytest didn't yield an obvious environment variable for setting the configuration file. Rather, they seem to support using environment variables for setting individual configuration options (as Twine does).

With all that in mind, I'm going to close this for now, but if folks feel strongly, we can reopen it.

@lfvjimisola
Copy link

Other tools have this such as npm, maven etc. Would be very useful for CI/CD with a TWINE_CONFIG_FILE environment variable that can be used globally instead of the --config-file CONFIG_FILE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement question Discussion/decision needed from maintainers
Projects
None yet
Development

No branches or pull requests

4 participants