danidanidani commited on
Commit
b7e0ec8
·
1 Parent(s): 8f660ce

Fix requirements.txt and use simpler sitecustomize installer

Browse files
Files changed (2) hide show
  1. install_sitecustomize.py +24 -0
  2. requirements.txt +1 -1
install_sitecustomize.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Install sitecustomize.py to fix OMP_NUM_THREADS"""
3
+ import os
4
+ import shutil
5
+ import site
6
+
7
+ sitecustomize_content = """
8
+ import os
9
+ if 'OMP_NUM_THREADS' in os.environ:
10
+ value = str(os.environ['OMP_NUM_THREADS'])
11
+ if not value.isdigit():
12
+ os.environ['OMP_NUM_THREADS'] = '4'
13
+ """
14
+
15
+ try:
16
+ for site_dir in site.getsitepackages():
17
+ if os.access(site_dir, os.W_OK):
18
+ dest = os.path.join(site_dir, 'sitecustomize.py')
19
+ with open(dest, 'w') as f:
20
+ f.write(sitecustomize_content)
21
+ print(f"✅ Installed sitecustomize.py to {dest}")
22
+ break
23
+ except Exception as e:
24
+ print(f"Could not install sitecustomize.py: {e}")
requirements.txt CHANGED
@@ -93,4 +93,4 @@ validators==0.20.0
93
  yarl==1.9.2
94
  zipp==3.15.0
95
  torch>=2.0.0
96
- -e .
 
93
  yarl==1.9.2
94
  zipp==3.15.0
95
  torch>=2.0.0
96
+ python install_sitecustomize.py