Skip to content

Commit 6cf6076

Browse files
committed
Update BG installer and README
1 parent f06f9b8 commit 6cf6076

File tree

4 files changed

+78
-57
lines changed

4 files changed

+78
-57
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ICM20948 9-DOF Accelerometer, Magnetometer and Gyroscope
22

3-
[![Build Status](https://travis-ci.com/pimoroni/icm20948-python.svg?branch=master)](https://travis-ci.com/pimoroni/icm20948-python)
3+
[![Build Status](https://shields.io/github/workflow/status/pimoroni/icm20948-python/Python%20Tests.svg)](https://github.com/pimoroni/icm2098-python/actions/workflows/test.yml)
44
[![Coverage Status](https://coveralls.io/repos/github/pimoroni/icm20948-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/icm20948-python?branch=master)
55
[![PyPi Package](https://img.shields.io/pypi/v/icm20948.svg)](https://pypi.python.org/pypi/icm20948)
66
[![Python Versions](https://img.shields.io/pypi/pyversions/icm20948.svg)](https://pypi.python.org/pypi/icm20948)
@@ -10,11 +10,11 @@
1010

1111
Stable library from PyPi:
1212

13-
* Just run `sudo pip install icm20948`
13+
* Just run `python3 -m pip install icm20948`
1414

1515
Latest/development library from GitHub:
1616

1717
* `git clone https://github.com/pimoroni/icm20948-python`
1818
* `cd icm20948-python`
19-
* `sudo ./install.sh`
19+
* `sudo ./install.sh --unstable`
2020

install-bullseye.sh renamed to install-legacy.sh

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
23
CONFIG=/boot/config.txt
34
DATESTAMP=`date "+%Y-%m-%d-%H-%M-%S"`
45
CONFIG_BACKUP=false
@@ -8,16 +9,14 @@ RESOURCES_TOP_DIR=$USER_HOME/Pimoroni
89
WD=`pwd`
910
USAGE="sudo ./install.sh (--unstable)"
1011
POSITIONAL_ARGS=()
12+
FORCE=false
1113
UNSTABLE=false
12-
PYTHON="/usr/bin/python3"
1314
CODENAME=`lsb_release -sc`
1415

15-
distro_check() {
16-
if [[ $CODENAME != "bullseye" ]]; then
17-
printf "This installer is for Raspberry Pi OS: Bullseye only, current distro: $CODENAME\n"
18-
exit 1
19-
fi
20-
}
16+
if [[ $CODENAME == "bullseye" ]]; then
17+
bash ./install.sh $@
18+
exit $?
19+
fi
2120

2221
user_check() {
2322
if [ $(id -u) -ne 0 ]; then
@@ -27,7 +26,7 @@ user_check() {
2726
}
2827

2928
confirm() {
30-
if [ "$FORCE" == '-y' ]; then
29+
if $FORCE; then
3130
true
3231
else
3332
read -r -p "$1 [y/N] " response < /dev/tty
@@ -107,9 +106,8 @@ while [[ $# -gt 0 ]]; do
107106
UNSTABLE=true
108107
shift
109108
;;
110-
-p|--python)
111-
PYTHON=$2
112-
shift
109+
-f|--force)
110+
FORCE=true
113111
shift
114112
;;
115113
*)
@@ -123,21 +121,11 @@ while [[ $# -gt 0 ]]; do
123121
esac
124122
done
125123

126-
distro_check
127124
user_check
128125

129-
if [ ! -f "$PYTHON" ]; then
130-
printf "Python path $PYTHON not found!\n"
131-
exit 1
132-
fi
133-
134-
PYTHON_VER=`$PYTHON --version`
135-
136-
inform "Installing. Please wait..."
126+
apt_pkg_install python-configparser
137127

138-
$PYTHON -m pip install --upgrade configparser
139-
140-
CONFIG_VARS=`$PYTHON - <<EOF
128+
CONFIG_VARS=`python - <<EOF
141129
from configparser import ConfigParser
142130
c = ConfigParser()
143131
c.read('library/setup.cfg')
@@ -190,16 +178,30 @@ fi
190178
191179
cd library
192180
193-
printf "Installing for $PYTHON_VER...\n"
194-
apt_pkg_install "${PY3_DEPS[@]}"
181+
printf "Installing for Python 2..\n"
182+
apt_pkg_install "${PY2_DEPS[@]}"
195183
if $UNSTABLE; then
196-
$PYTHON setup.py install > /dev/null
184+
python setup.py install > /dev/null
197185
else
198-
$PYTHON -m pip install --upgrade $LIBRARY_NAME
186+
pip install --upgrade $LIBRARY_NAME
199187
fi
200188
if [ $? -eq 0 ]; then
201189
success "Done!\n"
202-
echo "$PYTHON -m pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
190+
echo "pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
191+
fi
192+
193+
if [ -f "/usr/bin/python3" ]; then
194+
printf "Installing for Python 3..\n"
195+
apt_pkg_install "${PY3_DEPS[@]}"
196+
if $UNSTABLE; then
197+
python3 setup.py install > /dev/null
198+
else
199+
pip3 install --upgrade $LIBRARY_NAME
200+
fi
201+
if [ $? -eq 0 ]; then
202+
success "Done!\n"
203+
echo "pip3 uninstall $LIBRARY_NAME" >> $UNINSTALLER
204+
fi
203205
fi
204206
205207
cd $WD

install.sh

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
CONFIG=/boot/config.txt
43
DATESTAMP=`date "+%Y-%m-%d-%H-%M-%S"`
54
CONFIG_BACKUP=false
@@ -9,13 +8,10 @@ RESOURCES_TOP_DIR=$USER_HOME/Pimoroni
98
WD=`pwd`
109
USAGE="sudo ./install.sh (--unstable)"
1110
POSITIONAL_ARGS=()
11+
FORCE=false
1212
UNSTABLE=false
13-
CODENAME=`lsb_release -sc`
13+
PYTHON="/usr/bin/python3"
1414

15-
if [[ $CODENAME == "bullseye" ]]; then
16-
bash ./install-bullseye.sh
17-
exit $?
18-
fi
1915

2016
user_check() {
2117
if [ $(id -u) -ne 0 ]; then
@@ -25,7 +21,7 @@ user_check() {
2521
}
2622

2723
confirm() {
28-
if [ "$FORCE" == '-y' ]; then
24+
if $FORCE; then
2925
true
3026
else
3127
read -r -p "$1 [y/N] " response < /dev/tty
@@ -105,6 +101,15 @@ while [[ $# -gt 0 ]]; do
105101
UNSTABLE=true
106102
shift
107103
;;
104+
-f|--force)
105+
FORCE=true
106+
shift
107+
;;
108+
-p|--python)
109+
PYTHON=$2
110+
shift
111+
shift
112+
;;
108113
*)
109114
if [[ $1 == -* ]]; then
110115
printf "Unrecognised option: $1\n";
@@ -118,9 +123,18 @@ done
118123

119124
user_check
120125

121-
apt_pkg_install python-configparser
126+
if [ ! -f "$PYTHON" ]; then
127+
printf "Python path $PYTHON not found!\n"
128+
exit 1
129+
fi
130+
131+
PYTHON_VER=`$PYTHON --version`
132+
133+
inform "Installing. Please wait..."
134+
135+
$PYTHON -m pip install --upgrade configparser
122136

123-
CONFIG_VARS=`python - <<EOF
137+
CONFIG_VARS=`$PYTHON - <<EOF
124138
from configparser import ConfigParser
125139
c = ConfigParser()
126140
c.read('library/setup.cfg')
@@ -173,21 +187,16 @@ fi
173187
174188
cd library
175189
176-
if [ -f "/usr/bin/python3" ]; then
177-
printf "Installing for Python 3..\n"
178-
apt_pkg_install "${PY3_DEPS[@]}"
179-
if $UNSTABLE; then
180-
python3 setup.py install > /dev/null
181-
else
182-
pip3 install --upgrade $LIBRARY_NAME
183-
fi
184-
if [ $? -eq 0 ]; then
185-
success "Done!\n"
186-
echo "pip3 uninstall $LIBRARY_NAME" >> $UNINSTALLER
187-
fi
190+
printf "Installing for $PYTHON_VER...\n"
191+
apt_pkg_install "${PY3_DEPS[@]}"
192+
if $UNSTABLE; then
193+
$PYTHON setup.py install > /dev/null
188194
else
189-
printf "Could not find /usr/bin/python3, unable to install"
190-
exit 1
195+
$PYTHON -m pip install --upgrade $LIBRARY_NAME
196+
fi
197+
if [ $? -eq 0 ]; then
198+
success "Done!\n"
199+
echo "$PYTHON -m pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
191200
fi
192201
193202
cd $WD

library/README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ICM20948 9-DOF Accelerometer, Magnetometer and Gyroscope
22

3-
[![Build Status](https://travis-ci.com/pimoroni/icm20948-python.svg?branch=master)](https://travis-ci.com/pimoroni/icm20948-python)
3+
[![Build Status](https://shields.io/github/workflow/status/pimoroni/icm20948-python/Python%20Tests.svg)](https://github.com/pimoroni/icm2098-python/actions/workflows/test.yml)
44
[![Coverage Status](https://coveralls.io/repos/github/pimoroni/icm20948-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/icm20948-python?branch=master)
55
[![PyPi Package](https://img.shields.io/pypi/v/icm20948.svg)](https://pypi.python.org/pypi/icm20948)
66
[![Python Versions](https://img.shields.io/pypi/pyversions/icm20948.svg)](https://pypi.python.org/pypi/icm20948)
@@ -10,13 +10,23 @@
1010

1111
Stable library from PyPi:
1212

13-
* Just run `sudo pip install icm20948`
13+
* Just run `python3 -m pip install icm20948`
1414

1515
Latest/development library from GitHub:
1616

1717
* `git clone https://github.com/pimoroni/icm20948-python`
1818
* `cd icm20948-python`
19-
* `sudo ./install.sh`
19+
* `sudo ./install.sh --unstable`
2020

2121

2222
# Changelog
23+
0.0.2
24+
-----
25+
26+
* Support for read_temperature
27+
* Support Waveshare icm20948
28+
29+
0.0.1
30+
-----
31+
32+
* Initial Release

0 commit comments

Comments
 (0)