1-
21#! /bin/bash
32set -u
43
5- # enable command completion
4+ # enable command completion
65set -o history -o histexpand
76
87python=" python3"
@@ -34,7 +33,6 @@ wait_for_user() {
3433 echo
3534 echo " Press RETURN to continue or any other key to abort"
3635 getc c
37- # we test for \r and \n because some stuff does \r instead
3836 if ! [[ " $c " == $' \r ' || " $c " == $' \n ' ]]; then
3937 exit 1
4038 fi
@@ -67,13 +65,9 @@ ohai() {
6765 printf " ${tty_blue} ==>${tty_bold} %s${tty_reset} \n" " $( shell_join " $@ " ) "
6866}
6967
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-
7468linux_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
7771 exit_on_error $?
7872}
7973
@@ -86,10 +80,10 @@ linux_install_python() {
8680 ohai " Updating python"
8781 sudo apt-get install --only-upgrade $python
8882 fi
89- exit_on_error $?
83+ exit_on_error $?
9084 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 $?
9387}
9488
9589linux_update_pip () {
@@ -102,30 +96,34 @@ linux_update_pip() {
10296linux_install_bittensor () {
10397 ohai " Cloning bittensor@master into ~/.bittensor/bittensor"
10498 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)
106101
107102 ohai " Creating Python virtual environment"
108103 python3 -m venv ~ /.bittensor/venv
104+ $HOME /.bittensor/venv/bin/python -m ensurepip --upgrade
109105 source ~ /.bittensor/venv/bin/activate
106+ python=" $HOME /.bittensor/venv/bin/python"
110107
111108 ohai " Installing bittensor"
109+ $python -m pip install --upgrade pip
112110 $python -m pip install -e ~ /.bittensor/bittensor/
113111 $python -m pip install -U bittensor-cli
114- exit_on_error $?
112+ exit_on_error $?
113+ deactivate
115114}
116115
117116linux_increase_ulimit (){
118117 ohai " Increasing ulimit to 1,000,000"
119118 prlimit --pid=$PPID --nofile=1000000
120119}
121120
122-
123121mac_install_xcode () {
124122 which -s xcode-select
125123 if [[ $? != 0 ]] ; then
126124 ohai " Installing xcode:"
127125 xcode-select --install
128- exit_on_error $?
126+ exit_on_error $?
129127 fi
130128}
131129
@@ -138,7 +136,7 @@ mac_install_brew() {
138136 ohai " Updating brew:"
139137 brew update --verbose
140138 fi
141- exit_on_error $?
139+ exit_on_error $?
142140}
143141
144142mac_install_cmake () {
@@ -158,7 +156,7 @@ mac_install_python() {
158156 brew list python@3 & > /dev/null || brew install python@3;
159157 ohai " Updating python3"
160158 brew upgrade python@3
161- exit_on_error $?
159+ exit_on_error $?
162160}
163161
164162mac_update_pip () {
@@ -170,16 +168,20 @@ mac_update_pip() {
170168
171169mac_install_bittensor () {
172170 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)
174173
175174 ohai " Creating Python virtual environment"
176175 python3 -m venv ~ /.bittensor/venv
176+ $HOME /.bittensor/venv/bin/python -m ensurepip --upgrade
177177 source ~ /.bittensor/venv/bin/activate
178+ python=" $HOME /.bittensor/venv/bin/python"
178179
179180 ohai " Installing bittensor"
181+ $python -m pip install --upgrade pip
180182 $python -m pip install -e ~ /.bittensor/bittensor/
181183 $python -m pip install -U bittensor-cli
182- exit_on_error $?
184+ exit_on_error $?
183185 deactivate
184186}
185187
@@ -191,8 +193,9 @@ if [[ "$OS" == "Linux" ]]; then
191193 if [[ $? != 0 ]] ; then
192194 abort " This linux based install requires apt-get. To run with other distros (centos, arch, etc), you will need to manually install the requirements"
193195 fi
196+
194197 echo " " "
195-
198+
196199██████╗░██╗████████╗████████╗███████╗███╗░░██╗░██████╗░█████╗░██████╗░
197200██╔══██╗██║╚══██╔══╝╚══██╔══╝██╔════╝████╗░██║██╔════╝██╔══██╗██╔══██╗
198201██████╦╝██║░░░██║░░░░░░██║░░░█████╗░░██╔██╗██║╚█████╗░██║░░██║██████╔╝
270273
271274# Use the shell's audible bell.
272275if [[ -t 1 ]]; then
273- printf " \a"
276+ printf " \a"
274277fi
275278
276279echo " "
@@ -299,12 +302,12 @@ echo " $ btcli w new_hotkey"
299302echo " $ btcli w list"
300303echo " $ btcli s register"
301304echo " "
305+ echo " - Check Bittensor SDK version"
306+ echo " $ python -m bittensor"
307+ echo " "
302308echo " - Use the Python API"
303309echo " $ python3" echo " >> import bittensor"
304310echo " "
305- echo " - Join the discussion: "
311+ echo " - Join the discussion:"
306312echo " ${tty_underline} https://discord.gg/3rUr6EcvbB${tty_reset} "
307313echo " "
308-
309-
310-
0 commit comments