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,13 +65,9 @@ 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
76
- sudo apt-get install --no-install-recommends --no-install-suggests -y apt-utils curl git cmake build-essential python3-dev python3-venv
69
+ sudo apt-get update
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
}
79
73
@@ -86,10 +80,10 @@ 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 () {
@@ -102,30 +96,34 @@ linux_update_pip() {
102
96
linux_install_bittensor () {
103
97
ohai " Cloning bittensor@master into ~/.bittensor/bittensor"
104
98
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)
99
+ git clone https://github.com/opentensor/bittensor.git ~ /.bittensor/bittensor/ 2> /dev/null || \
100
+ (cd ~ /.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard ; git clean -xdf)
106
101
107
102
ohai " Creating Python virtual environment"
108
103
python3 -m venv ~ /.bittensor/venv
104
+ $HOME /.bittensor/venv/bin/python -m ensurepip --upgrade
109
105
source ~ /.bittensor/venv/bin/activate
106
+ python=" $HOME /.bittensor/venv/bin/python"
110
107
111
108
ohai " Installing bittensor"
109
+ $python -m pip install --upgrade pip
112
110
$python -m pip install -e ~ /.bittensor/bittensor/
113
111
$python -m pip install -U bittensor-cli
114
- exit_on_error $?
112
+ exit_on_error $?
113
+ deactivate
115
114
}
116
115
117
116
linux_increase_ulimit (){
118
117
ohai " Increasing ulimit to 1,000,000"
119
118
prlimit --pid=$PPID --nofile=1000000
120
119
}
121
120
122
-
123
121
mac_install_xcode () {
124
122
which -s xcode-select
125
123
if [[ $? != 0 ]] ; then
126
124
ohai " Installing xcode:"
127
125
xcode-select --install
128
- exit_on_error $?
126
+ exit_on_error $?
129
127
fi
130
128
}
131
129
@@ -138,7 +136,7 @@ mac_install_brew() {
138
136
ohai " Updating brew:"
139
137
brew update --verbose
140
138
fi
141
- exit_on_error $?
139
+ exit_on_error $?
142
140
}
143
141
144
142
mac_install_cmake () {
@@ -158,7 +156,7 @@ mac_install_python() {
158
156
brew list python@3 & > /dev/null || brew install python@3;
159
157
ohai " Updating python3"
160
158
brew upgrade python@3
161
- exit_on_error $?
159
+ exit_on_error $?
162
160
}
163
161
164
162
mac_update_pip () {
@@ -170,16 +168,20 @@ mac_update_pip() {
170
168
171
169
mac_install_bittensor () {
172
170
ohai " Cloning bittensor into ~/.bittensor/bittensor"
173
- 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)
171
+ git clone https://github.com/opentensor/bittensor.git ~ /.bittensor/bittensor/ 2> /dev/null || \
172
+ (cd ~ /.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard; git clean -xdf)
174
173
175
174
ohai " Creating Python virtual environment"
176
175
python3 -m venv ~ /.bittensor/venv
176
+ $HOME /.bittensor/venv/bin/python -m ensurepip --upgrade
177
177
source ~ /.bittensor/venv/bin/activate
178
+ python=" $HOME /.bittensor/venv/bin/python"
178
179
179
180
ohai " Installing bittensor"
181
+ $python -m pip install --upgrade pip
180
182
$python -m pip install -e ~ /.bittensor/bittensor/
181
183
$python -m pip install -U bittensor-cli
182
- exit_on_error $?
184
+ exit_on_error $?
183
185
deactivate
184
186
}
185
187
@@ -191,8 +193,9 @@ if [[ "$OS" == "Linux" ]]; then
191
193
if [[ $? != 0 ]] ; then
192
194
abort " This linux based install requires apt-get. To run with other distros (centos, arch, etc), you will need to manually install the requirements"
193
195
fi
196
+
194
197
echo " " "
195
-
198
+
196
199
██████╗░██╗████████╗████████╗███████╗███╗░░██╗░██████╗░█████╗░██████╗░
197
200
██╔══██╗██║╚══██╔══╝╚══██╔══╝██╔════╝████╗░██║██╔════╝██╔══██╗██╔══██╗
198
201
██████╦╝██║░░░██║░░░░░░██║░░░█████╗░░██╔██╗██║╚█████╗░██║░░██║██████╔╝
270
273
271
274
# Use the shell's audible bell.
272
275
if [[ -t 1 ]]; then
273
- printf " \a"
276
+ printf " \a"
274
277
fi
275
278
276
279
echo " "
@@ -299,12 +302,12 @@ echo " $ btcli w new_hotkey"
299
302
echo " $ btcli w list"
300
303
echo " $ btcli s register"
301
304
echo " "
305
+ echo " - Check Bittensor SDK version"
306
+ echo " $ python -m bittensor"
307
+ echo " "
302
308
echo " - Use the Python API"
303
309
echo " $ python3" echo " >> import bittensor"
304
310
echo " "
305
- echo " - Join the discussion: "
311
+ echo " - Join the discussion:"
306
312
echo " ${tty_underline} https://discord.gg/3rUr6EcvbB${tty_reset} "
307
313
echo " "
308
-
309
-
310
-
0 commit comments