Shirosawa commited on
Commit
1954c40
·
verified ·
1 Parent(s): 52490c2

Create sitecustomize.py

Browse files
Files changed (1) hide show
  1. sitecustomize.py +17 -0
sitecustomize.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # sitecustomize.py — shim for old libs importing huggingface_hub.HfFolder
2
+ import os, types
3
+ import huggingface_hub as _hh
4
+
5
+ if not hasattr(_hh, "HfFolder"):
6
+ class _ShimHfFolder:
7
+ @staticmethod
8
+ def get_token():
9
+ # Spaces 内用 Secrets: HF_TOKEN
10
+ return os.getenv("HF_TOKEN", "")
11
+
12
+ @staticmethod
13
+ def save_token(token: str):
14
+ # 在 Spaces 环境不落盘,直接忽略
15
+ return None
16
+
17
+ _hh.HfFolder = _ShimHfFolder # 提供缺失符号