Skip to content

Commit

Permalink
replaced PROJECT_HOME with POETRY_CONFIG_DIR, POETRY_DATA_DIR and POE…
Browse files Browse the repository at this point in the history
…TRY_CACHE_DIR
  • Loading branch information
mohan43u committed May 23, 2022
1 parent 30391b2 commit b24aa13
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
29 changes: 29 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@ menu:
weight: 40
---

# Default Directories

Poetry uses these following default directories

## Config Directory

- Linux: `$XDG_CONFIG_HOME/$appname` or `~/.config/$appname`
- Windows:`%USERPROFILE%\AppData\Local\$appauthor\$appname` (not roaming) or`%USERPROFILE%\AppData\Roaming\$appauthor\$appname` (roaming)
- MacOS: `~/Library/Preferences/$appname/$version`

You can override this Config directory by setting `POETRY_CONFIG_DIR` environment variable


## Data Directory

- Linux: `$XDG_DATA_HOME/$appname` or `~/.local/share/$appname`
- Windows:`%USERPROFILE%\AppData\Local\$appauthor\$appname` (not roaming) or`%USERPROFILE%\AppData\Roaming\$appauthor\$appname` (roaming)
- MacOS: `~/Library/Application Support/$appname/$version`

You can override this Data directory by setting `POETRY_DATA_DIR` environment variable

## Cache Directory

- Linux: `$XDG_CACHE_HOME/$appname` or `~/.cache/$appname`
- Windows:`%USERPROFILE%\AppData\Local\$appauthor\$appname\Cache\$version`
- MacOS: `~/Library/Caches/$appname/$version`

You can override this Cache directory by setting `POETRY_CACHE_DIR` environment variable

# Configuration

Poetry can be configured via the `config` command ([see more about its usage here]({{< relref "cli#config" >}} "config command documentation"))
Expand Down
13 changes: 7 additions & 6 deletions src/poetry/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
logger = logging.getLogger(__name__)

CACHE_DIR = (
Path(os.path.join(os.environ["PROJECT_HOME"], ".cache"))
if sys.platform.startswith("linux") and "PROJECT_HOME" in os.environ
Path(os.path.join(os.environ["POETRY_CACHE_DIR"], "cache"))
if "POETRY_CACHE_DIR" in os.environ
else user_cache_path("pypoetry", appauthor=False)
)

CONFIG_DIR = (
Path(os.path.join(os.environ["PROJECT_HOME"], ".config"))
if sys.platform.startswith("linux") and "PROJECT_HOME" in os.environ
Path(os.path.join(os.environ["POETRY_CONFIG_DIR"], "config"))
if "POETRY_CONFIG_DIR" in os.environ
else user_config_path("pypoetry", appauthor=False, roaming=True)
)

Expand Down Expand Up @@ -53,7 +54,7 @@ def data_dir() -> Path:
return Path(poetry_home).expanduser()

return (
Path(os.path.join(os.environ["PROJECT_HOME"], ".local/share"))
if sys.platform.startswith("linux") and "PROJECT_HOME" in os.environ
Path(os.path.join(os.environ["POETRY_DATA_DIR"], "data"))
if "POETRY_DATA_DIR" in os.environ
else user_data_path("pypoetry", appauthor=False, roaming=True)
)

0 comments on commit b24aa13

Please sign in to comment.