GRDN.AI.3 / install_sitecustomize.py
danidanidani's picture
Fix requirements.txt and use simpler sitecustomize installer
b7e0ec8
#!/usr/bin/env python3
"""Install sitecustomize.py to fix OMP_NUM_THREADS"""
import os
import shutil
import site
sitecustomize_content = """
import os
if 'OMP_NUM_THREADS' in os.environ:
value = str(os.environ['OMP_NUM_THREADS'])
if not value.isdigit():
os.environ['OMP_NUM_THREADS'] = '4'
"""
try:
for site_dir in site.getsitepackages():
if os.access(site_dir, os.W_OK):
dest = os.path.join(site_dir, 'sitecustomize.py')
with open(dest, 'w') as f:
f.write(sitecustomize_content)
print(f"✅ Installed sitecustomize.py to {dest}")
break
except Exception as e:
print(f"Could not install sitecustomize.py: {e}")