-
Notifications
You must be signed in to change notification settings - Fork 319
Support XDG Base Directory Specification #830
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,20 @@ | |
DEFAULT_REPOSITORY = "https://upload.pypi.org/legacy/" | ||
TEST_REPOSITORY = "https://test.pypi.org/legacy/" | ||
|
||
DEFAULT_CONFIG_FILE = "~/.pypirc" | ||
# Obtain config file location following XDG spec | ||
XDG_CONFIG_HOME = os.environ.get( | ||
"XDG_CONFIG_HOME", os.path.join(os.path.expanduser("~"), ".config") | ||
) | ||
XDG_CONFIG_FILE = os.path.join(XDG_CONFIG_HOME, "pypi", "pypirc") | ||
|
||
# Obtain old config file location to add backward compatibility | ||
OLD_CONFIG_FILE = os.path.join(os.path.expanduser("~"), ".pypirc") | ||
|
||
# Obtain config file, ${HOME}/.pypirc if exists else | ||
# ${XDG_CONFIG_HOME}/pypi/pypirc | ||
DEFAULT_CONFIG_FILE = ( | ||
OLD_CONFIG_FILE if os.path.isfile(OLD_CONFIG_FILE) else XDG_CONFIG_FILE | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer using XDG_CONFIG_HOME = os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")
XDG_CONFIG_FILE = XDG_CONFIG_HOME / "pypa" / "pypirc"
HOME_CONFIG_FILE = Path.home() / ".pypirc"
DEFAULT_CONFIG_FILE = (
HOME_CONFIG_FILE if HOME_CONFIG_FILE.is_file() else XDG_CONFIG_FILE
) |
||
|
||
# TODO: In general, it seems to be assumed that the values retrieved from | ||
# instances of this type aren't None, except for username and password. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have noticed this in your suggestion on the PR: I don't think Twine should unilaterally decide to put its configuration in a
pypi
directory. First, I don't think it's accurate; despite the name,.pypirc
can be used to define other package repositories besides PyPI. It could betwine
, but I think it's also worth keeping in mind that other tools (like flit) can use.pypirc
. So maybe it should be bepypa
, but I'd want buy-in from other PyPA maintainers before claiming that name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pradyunsg I'm particularly interested in your thoughts from pip's perspective.
Maybe also @takluyver, with flit's perspective.