forked from bit-current/DistributedTraining
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post_install.py
34 lines (26 loc) · 1.08 KB
/
post_install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import pkg_resources
def remove_nest_asyncio_import():
try:
# Locate the installation directory of bittensor
distribution = pkg_resources.get_distribution('bittensor')
bittensor_path = distribution.location
# Path to bittensor __init__.py
init_path = os.path.join(bittensor_path, 'bittensor', '__init__.py')
if not os.path.exists(init_path):
print("bittensor __init__.py not found. Ensure bittensor is correctly installed.")
return
# Read the file
with open(init_path, 'r') as file:
lines = file.readlines()
# Remove lines that import nest_asyncio
with open(init_path, 'w') as file:
for line in lines:
if 'nest_asyncio' not in line:
file.write(line)
# Uninstall nest_asyncio
os.system("pip uninstall -y nest_asyncio")
except pkg_resources.DistributionNotFound:
print("bittensor package is not installed. Please install it first.")
if __name__ == "__main__":
remove_nest_asyncio_import()