Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ crashtest = "^0.3.0"
entrypoints = "^0.3"
html5lib = "^1.0"
importlib-metadata = { version = ">=1.6.0", python = "<3.8" }
# packaging uses calver, so version is unclamped
# keyring uses calver, so version is unclamped
keyring = ">=21.2.0"
# packaging uses calver, so version is unclamped
packaging = ">=20.4"
pexpect = "^4.7.0"
pkginfo = "^1.5"
platformdirs = "^2.5.2"
requests = "^2.18"
requests-toolbelt = "^0.9.1"
shellingham = "^1.1"
Expand Down
6 changes: 3 additions & 3 deletions src/poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def unique_config_values(self) -> dict[str, tuple[Any, Any, Any]]:
"cache-dir": (
str,
lambda val: str(Path(val)),
str(Path(CACHE_DIR) / "virtualenvs"),
str(CACHE_DIR / "virtualenvs"),
),
"virtualenvs.create": (boolean_validator, boolean_normalizer, True),
"virtualenvs.in-project": (boolean_validator, boolean_normalizer, False),
Expand All @@ -75,7 +75,7 @@ def unique_config_values(self) -> dict[str, tuple[Any, Any, Any]]:
"virtualenvs.path": (
str,
lambda val: str(Path(val)),
str(Path(CACHE_DIR) / "virtualenvs"),
str(CACHE_DIR / "virtualenvs"),
),
"virtualenvs.prefer-active-python": (
boolean_validator,
Expand Down Expand Up @@ -112,7 +112,7 @@ def handle(self) -> int | None:
from poetry.locations import CONFIG_DIR

config = Factory.create_config(self.io)
config_file = TOMLFile(Path(CONFIG_DIR) / "config.toml")
config_file = TOMLFile(CONFIG_DIR / "config.toml")

try:
local_config_file = TOMLFile(self.poetry.file.parent / "poetry.toml")
Expand Down
7 changes: 4 additions & 3 deletions src/poetry/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import logging

from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
from typing import cast
Expand All @@ -24,6 +23,8 @@


if TYPE_CHECKING:
from pathlib import Path

from cleo.io.io import IO

from poetry.repositories.legacy_repository import LegacyRepository
Expand Down Expand Up @@ -110,7 +111,7 @@ def create_config(cls, io: IO | None = None) -> Config:

config = Config()
# Load global config
config_file = TOMLFile(Path(CONFIG_DIR) / "config.toml")
config_file = TOMLFile(CONFIG_DIR / "config.toml")
if config_file.exists():
if io.is_debug():
io.write_line(
Expand All @@ -122,7 +123,7 @@ def create_config(cls, io: IO | None = None) -> Config:
config.set_config_source(FileConfigSource(config_file))

# Load global auth config
auth_config_file = TOMLFile(Path(CONFIG_DIR) / "auth.toml")
auth_config_file = TOMLFile(CONFIG_DIR / "auth.toml")
if auth_config_file.exists():
if io.is_debug():
io.write_line(
Expand Down
39 changes: 31 additions & 8 deletions src/poetry/locations.py
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)
Comment thread
abn marked this conversation as resolved.

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)
224 changes: 0 additions & 224 deletions src/poetry/utils/appdirs.py

This file was deleted.

Loading