Spaces:
Sleeping
Sleeping
Update ash_animator/__init__.py
Browse files- ash_animator/__init__.py +37 -0
ash_animator/__init__.py
CHANGED
|
@@ -1,4 +1,41 @@
|
|
| 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
# Auto-generated __init__.py to import all modules
|
| 3 |
from .basemaps import *
|
| 4 |
from .converter import *
|
|
|
|
| 1 |
|
| 2 |
+
# cache_setup.py
|
| 3 |
+
|
| 4 |
+
import os
|
| 5 |
+
import tempfile
|
| 6 |
+
|
| 7 |
+
def setup_safe_cache(app_name="my_app"):
|
| 8 |
+
"""
|
| 9 |
+
Redirects all common cache/config directories to a writable location
|
| 10 |
+
to avoid permission issues (e.g., in Docker, servers, CI).
|
| 11 |
+
|
| 12 |
+
Must be called before importing:
|
| 13 |
+
- matplotlib
|
| 14 |
+
- cartopy
|
| 15 |
+
- contextily
|
| 16 |
+
- any internal modules using those libraries
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
# Define root cache location
|
| 20 |
+
cache_root = os.path.join(tempfile.gettempdir(), f"{app_name}_cache")
|
| 21 |
+
|
| 22 |
+
# Map of environment variables to subdirectories
|
| 23 |
+
cache_paths = {
|
| 24 |
+
"XDG_CACHE_HOME": os.path.join(cache_root, "xdg_cache"),
|
| 25 |
+
"XDG_CONFIG_HOME": os.path.join(cache_root, "xdg_config"),
|
| 26 |
+
"MPLCONFIGDIR": os.path.join(cache_root, "matplotlib"),
|
| 27 |
+
"CARTOPY_USER_BACKGROUNDS": os.path.join(cache_root, "cartopy"),
|
| 28 |
+
"CARTOPY_CACHE_DIR": os.path.join(cache_root, "cartopy"),
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
# Apply environment variable overrides and ensure directories exist
|
| 32 |
+
for var, path in cache_paths.items():
|
| 33 |
+
os.environ[var] = path
|
| 34 |
+
os.makedirs(path, exist_ok=True)
|
| 35 |
+
|
| 36 |
+
print(f"✅ Cache directories set under: {cache_root}")
|
| 37 |
+
|
| 38 |
+
setup_safe_cache("ash_animator") # You can pass your app name
|
| 39 |
# Auto-generated __init__.py to import all modules
|
| 40 |
from .basemaps import *
|
| 41 |
from .converter import *
|