- Document HF_HOME environment variable for writable cache - Add systemd service permission guidance for /tmp paths - Troubleshooting steps for read-only file system errors
20 lines
683 B
Python
Executable File
20 lines
683 B
Python
Executable File
import os
|
|
import sys
|
|
|
|
# Set a writable cache directory for Numba
|
|
# This is crucial when running as a systemd service with restricted home directory access.
|
|
# The cache will be created in the bot's root directory.
|
|
CACHE_DIR = os.path.join(os.path.dirname(__file__), '.numba_cache')
|
|
|
|
if not os.path.exists(CACHE_DIR):
|
|
try:
|
|
os.makedirs(CACHE_DIR)
|
|
print(f"Numba cache directory created at: {CACHE_DIR}")
|
|
except OSError as e:
|
|
print(f"Error creating Numba cache directory: {e}", file=sys.stderr)
|
|
|
|
# Set the environment variable for Numba
|
|
os.environ['NUMBA_CACHE_DIR'] = CACHE_DIR
|
|
|
|
print(f"Numba cache directory set to: {os.environ.get('NUMBA_CACHE_DIR')}")
|