1
-
2
1
#! /bin/bash
3
2
set -u
4
3
5
- # enable command completion
4
+ # enable command completion
6
5
set -o history -o histexpand
7
6
8
7
python=" python3"
@@ -34,7 +33,6 @@ wait_for_user() {
34
33
echo
35
34
echo " Press RETURN to continue or any other key to abort"
36
35
getc c
37
- # we test for \r and \n because some stuff does \r instead
38
36
if ! [[ " $c " == $' \r ' || " $c " == $' \n ' ]]; then
39
37
exit 1
40
38
fi
@@ -67,12 +65,8 @@ ohai() {
67
65
printf " ${tty_blue} ==>${tty_bold} %s${tty_reset} \n" " $( shell_join " $@ " ) "
68
66
}
69
67
70
- # Things can fail later if `pwd` doesn't exist.
71
- # Also sudo prints a warning message for no good reason
72
- cd " /usr" || exit 1
73
-
74
68
linux_install_pre () {
75
- sudo apt-get update
69
+ sudo apt-get update
76
70
sudo apt-get install --no-install-recommends --no-install-suggests -y apt-utils curl git cmake build-essential
77
71
exit_on_error $?
78
72
}
@@ -86,41 +80,48 @@ linux_install_python() {
86
80
ohai " Updating python"
87
81
sudo apt-get install --only-upgrade $python
88
82
fi
89
- exit_on_error $?
83
+ exit_on_error $?
90
84
ohai " Installing python tools"
91
- sudo apt-get install --no-install-recommends --no-install-suggests -y $python -pip $python -dev
92
- exit_on_error $?
85
+ sudo apt-get install --no-install-recommends --no-install-suggests -y python3 -pip python3 -dev python3-venv
86
+ exit_on_error $?
93
87
}
94
88
95
89
linux_update_pip () {
96
- PYTHONPATH=$( which $python )
97
- ohai " You are using python@ $PYTHONPATH $"
98
- ohai " Installing python tools"
99
- $python -m pip install --upgrade pip
90
+ ohai " Skipping pip upgrade in system Python (PEP 668). Will upgrade inside virtual environment."
100
91
}
101
92
93
+
102
94
linux_install_bittensor () {
103
95
ohai " Cloning bittensor@master into ~/.bittensor/bittensor"
104
96
mkdir -p ~ /.bittensor/bittensor
105
- git clone https://github.com/opentensor/bittensor.git ~ /.bittensor/bittensor/ 2> /dev/null || (cd ~ /.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard ; git clean -xdf)
97
+ git clone https://github.com/opentensor/bittensor.git ~ /.bittensor/bittensor/ 2> /dev/null || \
98
+ (cd ~ /.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard ; git clean -xdf)
99
+
100
+ ohai " Creating Python virtual environment"
101
+ python3 -m venv ~ /.bittensor/venv
102
+ $HOME /.bittensor/venv/bin/python -m ensurepip --upgrade
103
+ source ~ /.bittensor/venv/bin/activate
104
+ python=" $HOME /.bittensor/venv/bin/python"
105
+
106
106
ohai " Installing bittensor"
107
+ $python -m pip install --upgrade pip
107
108
$python -m pip install -e ~ /.bittensor/bittensor/
108
109
$python -m pip install -U bittensor-cli
109
- exit_on_error $?
110
+ exit_on_error $?
111
+ deactivate
110
112
}
111
113
112
114
linux_increase_ulimit (){
113
115
ohai " Increasing ulimit to 1,000,000"
114
116
prlimit --pid=$PPID --nofile=1000000
115
117
}
116
118
117
-
118
119
mac_install_xcode () {
119
120
which -s xcode-select
120
121
if [[ $? != 0 ]] ; then
121
122
ohai " Installing xcode:"
122
123
xcode-select --install
123
- exit_on_error $?
124
+ exit_on_error $?
124
125
fi
125
126
}
126
127
@@ -133,7 +134,7 @@ mac_install_brew() {
133
134
ohai " Updating brew:"
134
135
brew update --verbose
135
136
fi
136
- exit_on_error $?
137
+ exit_on_error $?
137
138
}
138
139
139
140
mac_install_cmake () {
@@ -153,7 +154,7 @@ mac_install_python() {
153
154
brew list python@3 & > /dev/null || brew install python@3;
154
155
ohai " Updating python3"
155
156
brew upgrade python@3
156
- exit_on_error $?
157
+ exit_on_error $?
157
158
}
158
159
159
160
mac_update_pip () {
@@ -165,11 +166,20 @@ mac_update_pip() {
165
166
166
167
mac_install_bittensor () {
167
168
ohai " Cloning bittensor into ~/.bittensor/bittensor"
168
- git clone https://github.com/opentensor/bittensor.git ~ /.bittensor/bittensor/ 2> /dev/null || (cd ~ /.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard; git clean -xdf)
169
+ git clone https://github.com/opentensor/bittensor.git ~ /.bittensor/bittensor/ 2> /dev/null || \
170
+ (cd ~ /.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard; git clean -xdf)
171
+
172
+ ohai " Creating Python virtual environment"
173
+ python3 -m venv ~ /.bittensor/venv
174
+ $HOME /.bittensor/venv/bin/python -m ensurepip --upgrade
175
+ source ~ /.bittensor/venv/bin/activate
176
+ python=" $HOME /.bittensor/venv/bin/python"
177
+
169
178
ohai " Installing bittensor"
179
+ $python -m pip install --upgrade pip
170
180
$python -m pip install -e ~ /.bittensor/bittensor/
171
181
$python -m pip install -U bittensor-cli
172
- exit_on_error $?
182
+ exit_on_error $?
173
183
deactivate
174
184
}
175
185
@@ -178,11 +188,12 @@ OS="$(uname)"
178
188
if [[ " $OS " == " Linux" ]]; then
179
189
180
190
which -s apt-get
181
- if [[ $? = = 0 ]] ; then
191
+ if [[ $? ! = 0 ]] ; then
182
192
abort " This linux based install requires apt-get. To run with other distros (centos, arch, etc), you will need to manually install the requirements"
183
193
fi
194
+
184
195
echo " " "
185
-
196
+
186
197
██████╗░██╗████████╗████████╗███████╗███╗░░██╗░██████╗░█████╗░██████╗░
187
198
██╔══██╗██║╚══██╔══╝╚══██╔══╝██╔════╝████╗░██║██╔════╝██╔══██╗██╔══██╗
188
199
██████╦╝██║░░░██║░░░░░░██║░░░█████╗░░██╔██╗██║╚█████╗░██║░░██║██████╔╝
260
271
261
272
# Use the shell's audible bell.
262
273
if [[ -t 1 ]]; then
263
- printf " \a"
274
+ printf " \a"
264
275
fi
265
276
266
277
echo " "
@@ -289,12 +300,12 @@ echo " $ btcli w new_hotkey"
289
300
echo " $ btcli w list"
290
301
echo " $ btcli s register"
291
302
echo " "
303
+ echo " - Check Bittensor SDK version"
304
+ echo " $ python -m bittensor"
305
+ echo " "
292
306
echo " - Use the Python API"
293
307
echo " $ python3" echo " >> import bittensor"
294
308
echo " "
295
- echo " - Join the discussion: "
309
+ echo " - Join the discussion:"
296
310
echo " ${tty_underline} https://discord.gg/3rUr6EcvbB${tty_reset} "
297
311
echo " "
298
-
299
-
300
-
0 commit comments