Skip to content

Commit

Permalink
Update installer & CI badge
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Feb 15, 2022
1 parent f3f9bfd commit 709ef16
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 72 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pimoroni PA1010D GPS Breakout

[![Build Status](https://travis-ci.com/pimoroni/pa1010d-python.svg?branch=master)](https://travis-ci.com/pimoroni/pa1010d-python)
[![Build Status](https://shields.io/github/workflow/status/pimoroni/pa1010d-python/Python%20Tests.svg)](https://github.com/pimoroni/pa1010d-python/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/pimoroni/pa1010d-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/pa1010d-python?branch=master)
[![PyPi Package](https://img.shields.io/pypi/v/pa1010d.svg)](https://pypi.python.org/pypi/pa1010d)
[![Python Versions](https://img.shields.io/pypi/pyversions/pa1010d.svg)](https://pypi.python.org/pypi/pa1010d)
Expand Down Expand Up @@ -29,4 +29,4 @@ Latest/development library and dependencies from GitHub:

Stable (library only) from PyPi:

* Just run `sudo pip3 install pa1010d`
* Just run `python3 -m pip install pa1010d`
58 changes: 30 additions & 28 deletions install-bullseye.sh → install-legacy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

CONFIG=/boot/config.txt
DATESTAMP=`date "+%Y-%m-%d-%H-%M-%S"`
CONFIG_BACKUP=false
Expand All @@ -8,16 +9,14 @@ RESOURCES_TOP_DIR=$USER_HOME/Pimoroni
WD=`pwd`
USAGE="sudo ./install.sh (--unstable)"
POSITIONAL_ARGS=()
FORCE=false
UNSTABLE=false
PYTHON="/usr/bin/python3"
CODENAME=`lsb_release -sc`

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

user_check() {
if [ $(id -u) -ne 0 ]; then
Expand All @@ -27,7 +26,7 @@ user_check() {
}

confirm() {
if [ "$FORCE" == '-y' ]; then
if $FORCE; then
true
else
read -r -p "$1 [y/N] " response < /dev/tty
Expand Down Expand Up @@ -107,9 +106,8 @@ while [[ $# -gt 0 ]]; do
UNSTABLE=true
shift
;;
-p|--python)
PYTHON=$2
shift
-f|--force)
FORCE=true
shift
;;
*)
Expand All @@ -123,21 +121,11 @@ while [[ $# -gt 0 ]]; do
esac
done

distro_check
user_check

if [ ! -f "$PYTHON" ]; then
printf "Python path $PYTHON not found!\n"
exit 1
fi

PYTHON_VER=`$PYTHON --version`

inform "Installing. Please wait..."
apt_pkg_install python-configparser

$PYTHON -m pip install --upgrade configparser

CONFIG_VARS=`$PYTHON - <<EOF
CONFIG_VARS=`python - <<EOF
from configparser import ConfigParser
c = ConfigParser()
c.read('library/setup.cfg')
Expand Down Expand Up @@ -190,16 +178,30 @@ fi
cd library
printf "Installing for $PYTHON_VER...\n"
apt_pkg_install "${PY3_DEPS[@]}"
printf "Installing for Python 2..\n"
apt_pkg_install "${PY2_DEPS[@]}"
if $UNSTABLE; then
$PYTHON setup.py install > /dev/null
python setup.py install > /dev/null
else
$PYTHON -m pip install --upgrade $LIBRARY_NAME
pip install --upgrade $LIBRARY_NAME
fi
if [ $? -eq 0 ]; then
success "Done!\n"
echo "$PYTHON -m pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
echo "pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
fi
if [ -f "/usr/bin/python3" ]; then
printf "Installing for Python 3..\n"
apt_pkg_install "${PY3_DEPS[@]}"
if $UNSTABLE; then
python3 setup.py install > /dev/null
else
pip3 install --upgrade $LIBRARY_NAME
fi
if [ $? -eq 0 ]; then
success "Done!\n"
echo "pip3 uninstall $LIBRARY_NAME" >> $UNINSTALLER
fi
fi
cd $WD
Expand Down
72 changes: 32 additions & 40 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

CONFIG=/boot/config.txt
DATESTAMP=`date "+%Y-%m-%d-%H-%M-%S"`
CONFIG_BACKUP=false
Expand All @@ -9,13 +8,10 @@ RESOURCES_TOP_DIR=$USER_HOME/Pimoroni
WD=`pwd`
USAGE="sudo ./install.sh (--unstable)"
POSITIONAL_ARGS=()
FORCE=false
UNSTABLE=false
CODENAME=`lsb_release -sc`
PYTHON="/usr/bin/python3"

if [[ $CODENAME == "bullseye" ]]; then
bash ./install-bullseye.sh
exit $?
fi

user_check() {
if [ $(id -u) -ne 0 ]; then
Expand All @@ -25,7 +21,7 @@ user_check() {
}

confirm() {
if [ "$FORCE" == '-y' ]; then
if $FORCE; then
true
else
read -r -p "$1 [y/N] " response < /dev/tty
Expand Down Expand Up @@ -105,6 +101,15 @@ while [[ $# -gt 0 ]]; do
UNSTABLE=true
shift
;;
-f|--force)
FORCE=true
shift
;;
-p|--python)
PYTHON=$2
shift
shift
;;
*)
if [[ $1 == -* ]]; then
printf "Unrecognised option: $1\n";
Expand All @@ -118,9 +123,18 @@ done

user_check

apt_pkg_install python-configparser
if [ ! -f "$PYTHON" ]; then
printf "Python path $PYTHON not found!\n"
exit 1
fi

PYTHON_VER=`$PYTHON --version`

inform "Installing. Please wait..."

$PYTHON -m pip install --upgrade configparser

CONFIG_VARS=`python - <<EOF
CONFIG_VARS=`$PYTHON - <<EOF
from configparser import ConfigParser
c = ConfigParser()
c.read('library/setup.cfg')
Expand All @@ -141,7 +155,6 @@ PY3_DEPS={py3deps}
PY2_DEPS={py2deps}
SETUP_CMDS={commands}
CONFIG_TXT={configtxt}
PY3_ONLY={py3only}
""".format(**p))
EOF`
Expand Down Expand Up @@ -174,37 +187,16 @@ fi
cd library
if ! $PY3_ONLY; then
printf "Installing for Python 2..\n"
apt_pkg_install "${PY2_DEPS[@]}"
if $UNSTABLE; then
python setup.py install > /dev/null
else
pip install --upgrade $LIBRARY_NAME
fi
if [ $? -eq 0 ]; then
success "Done!\n"
echo "pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
fi
fi
if [ -f "/usr/bin/python3" ]; then
printf "Installing for Python 3..\n"
apt_pkg_install "${PY3_DEPS[@]}"
if $UNSTABLE; then
python3 setup.py install > /dev/null
else
pip3 install --upgrade $LIBRARY_NAME
fi
if [ $? -eq 0 ]; then
success "Done!\n"
echo "pip3 uninstall $LIBRARY_NAME" >> $UNINSTALLER
fi
printf "Installing for $PYTHON_VER...\n"
apt_pkg_install "${PY3_DEPS[@]}"
if $UNSTABLE; then
$PYTHON setup.py install > /dev/null
else
if $PY3_ONLY; then
warning "Python 3 is required to install this library...\n"
exit 1
fi
$PYTHON -m pip install --upgrade $LIBRARY_NAME
fi
if [ $? -eq 0 ]; then
success "Done!\n"
echo "$PYTHON -m pip uninstall $LIBRARY_NAME" >> $UNINSTALLER
fi
cd $WD
Expand Down
9 changes: 7 additions & 2 deletions library/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pimoroni PA1010D GPS Breakout

[![Build Status](https://travis-ci.com/pimoroni/pa1010d-python.svg?branch=master)](https://travis-ci.com/pimoroni/pa1010d-python)
[![Build Status](https://shields.io/github/workflow/status/pimoroni/pa1010d-python/Python%20Tests.svg)](https://github.com/pimoroni/pa1010d-python/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/pimoroni/pa1010d-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/pa1010d-python?branch=master)
[![PyPi Package](https://img.shields.io/pypi/v/pa1010d.svg)](https://pypi.python.org/pypi/pa1010d)
[![Python Versions](https://img.shields.io/pypi/pyversions/pa1010d.svg)](https://pypi.python.org/pypi/pa1010d)
Expand Down Expand Up @@ -29,9 +29,14 @@ Latest/development library and dependencies from GitHub:

Stable (library only) from PyPi:

* Just run `sudo pip3 install pa1010d`
* Just run `python3 -m pip install pa1010d`

# Changelog
0.0.4
-----

* Fix read/write for Python 3.9

0.0.3
-----

Expand Down

0 comments on commit 709ef16

Please sign in to comment.