-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Replace poetry.utils.appdirs with platformdirs #5527
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2f5b7c9
Verify compatibility with platformdirs
dimbleby 9d549be
use platformdirs
dimbleby c2cc80f
remove unused DATA_DIR
dimbleby d997fd9
prefer to use Paths
dimbleby ad960af
linting
dimbleby 12cd138
fix type annotation in tests
dimbleby f8eac5c
provide migration path for OSX CONFIG_DIR change
dimbleby 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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 |
|---|---|---|
| @@ -1,24 +1,47 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| import os | ||
| import sys | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| from poetry.utils.appdirs import user_cache_dir | ||
| from poetry.utils.appdirs import user_config_dir | ||
| from poetry.utils.appdirs import user_data_dir | ||
| from platformdirs import user_cache_path | ||
| from platformdirs import user_config_path | ||
| from platformdirs import user_data_path | ||
|
|
||
|
|
||
| CACHE_DIR = user_cache_dir("pypoetry") | ||
| DATA_DIR = user_data_dir("pypoetry") | ||
| CONFIG_DIR = user_config_dir("pypoetry") | ||
| logger = logging.getLogger(__name__) | ||
|
|
||
| REPOSITORY_CACHE_DIR = Path(CACHE_DIR) / "cache" / "repositories" | ||
| CACHE_DIR = user_cache_path("pypoetry", appauthor=False) | ||
| CONFIG_DIR = user_config_path("pypoetry", appauthor=False, roaming=True) | ||
|
|
||
| REPOSITORY_CACHE_DIR = CACHE_DIR / "cache" / "repositories" | ||
|
|
||
| # platformdirs 2.0.0 corrected the OSX/macOS config directory from | ||
| # /Users/<user>/Library/Application Support/<appname> to | ||
| # /Users/<user>/Library/Preferences/<appname>. | ||
| # | ||
| # For now we only deprecate use of the old directory. | ||
| if sys.platform == "darwin": | ||
| _LEGACY_CONFIG_DIR = CONFIG_DIR.parent.parent / "Application Support" / "pypoetry" | ||
| config_toml = _LEGACY_CONFIG_DIR / "config.toml" | ||
| auth_toml = _LEGACY_CONFIG_DIR / "auth.toml" | ||
|
|
||
| if any(file.exists() for file in (auth_toml, config_toml)): | ||
| logger.warn( | ||
| "Configuration file exists at %s, reusing this directory.\n\nConsider" | ||
| " moving configuration to %s, as support for the legacy directory will be" | ||
| " removed in an upcoming release.", | ||
| _LEGACY_CONFIG_DIR, | ||
| CONFIG_DIR, | ||
| ) | ||
| CONFIG_DIR = _LEGACY_CONFIG_DIR | ||
|
|
||
|
|
||
| def data_dir() -> Path: | ||
| poetry_home = os.getenv("POETRY_HOME") | ||
| if poetry_home: | ||
| return Path(poetry_home).expanduser() | ||
|
|
||
| return Path(user_data_dir("pypoetry", roaming=True)) | ||
| return user_data_path("pypoetry", appauthor=False, roaming=True) | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.