Skip to content

Commit

Permalink
Expose HF_HOME in constants (#1825)
Browse files Browse the repository at this point in the history
* Expose HF_HOME in constants

* style
  • Loading branch information
Wauplin authored Nov 15, 2023
1 parent 2ba956b commit a1b90fa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/huggingface_hub/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,16 @@ def _as_int(value: Optional[str]) -> Optional[int]:

# default cache
default_home = os.path.join(os.path.expanduser("~"), ".cache")
hf_cache_home = os.path.expanduser(
HF_HOME = os.path.expanduser(
os.getenv(
"HF_HOME",
os.path.join(os.getenv("XDG_CACHE_HOME", default_home), "huggingface"),
)
)
hf_cache_home = HF_HOME # for backward compatibility. TODO: remove this in 1.0.0

default_cache_path = os.path.join(hf_cache_home, "hub")
default_assets_cache_path = os.path.join(hf_cache_home, "assets")
default_cache_path = os.path.join(HF_HOME, "hub")
default_assets_cache_path = os.path.join(HF_HOME, "assets")

# Legacy env variables
HUGGINGFACE_HUB_CACHE = os.getenv("HUGGINGFACE_HUB_CACHE", default_cache_path)
Expand All @@ -109,7 +110,7 @@ def _as_int(value: Optional[str]) -> Optional[int]:
# `_OLD_HF_TOKEN_PATH` is deprecated and will be removed "at some point".
# See https://github.com/huggingface/huggingface_hub/issues/1232
_OLD_HF_TOKEN_PATH = os.path.expanduser("~/.huggingface/token")
HF_TOKEN_PATH = os.path.join(hf_cache_home, "token")
HF_TOKEN_PATH = os.path.join(HF_HOME, "token")


if _staging_mode:
Expand Down

0 comments on commit a1b90fa

Please sign in to comment.