Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

New upgrade script for Python. #131

Merged
merged 13 commits into from
Mar 8, 2018
Merged

New upgrade script for Python. #131

merged 13 commits into from
Mar 8, 2018

Conversation

ludeeus
Copy link
Member

@ludeeus ludeeus commented Mar 4, 2018

Description:

This script will upgrade Python to the latest stable version.
It will also create a new virtual environment to be used for Home Assistant.
If it fails, it will revert back to the original virtual environment.

Checklist:

  • The code change is tested and works locally.
    • Hassbian 1.4.0 "Stretch" (From Python 3.5.3)
    • Hassbian 1.23 "Jessie" (From Python 3.4.2)

Both tested with current dev branch of hassbian-scripts

  • Script has validation check of the job.

If pertinent:

  • Created/Updated documentation at /docs

apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
apt-get install libtcmalloc-minimal4
export LD_PRELOAD="/usr/lib/libtcmalloc_minimal.so.4"
cd /tmp

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

cd /tmp
wget https://www.python.org/ftp/python/"$PYTHONVERSION"/Python-"$PYTHONVERSION".tar.xz
tar xf Python-"$PYTHONVERSION".tar.xz
cd Python-"$PYTHONVERSION"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

EOF

echo "Creating new virutal environment using Python $PYTHONVERSION"
python${PYTHONVERSION:: -2} -m venv /srv/homeassistant

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double quote to prevent globbing and word splitting.

@ludeeus ludeeus changed the title WIP: New upgrade for python WIP: New upgrade script for python. Mar 4, 2018
@ludeeus ludeeus changed the title WIP: New upgrade script for python. WIP: New upgrade script for Python. Mar 4, 2018
@ludeeus ludeeus changed the title WIP: New upgrade script for Python. New upgrade script for Python. Mar 4, 2018
@ludeeus
Copy link
Member Author

ludeeus commented Mar 6, 2018

I'm unsure about this, it can help many users with the upgrade, but it's also a big change.
Maybe add this to the script?
Requiring users to take another step.

if [ "$FORCE" == "" ]; then
    echo "This script will change a lot on your pi."
    echo "DO NOT run this if you absolutely have to."
    echo "You can force run the upgrade script like this:"
    echo "sudo hassbian-config upgrade python --force"
   return 0
  fi

@Landrash
Copy link
Collaborator

Landrash commented Mar 7, 2018

I'm unsure about this script. What's your reason for wanting it in?

Copy link
Collaborator

@Landrash Landrash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor cosmetic tweaks and discussion about why this should be added should probably be had.

docs/python.md Outdated
## Description
This script will upgrade Python to the latest stable version.
It will also create a new virtual environment to be used for Home Assistant.
_This upgrade takes loong time to finish._
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling of long.

docs/python.md Outdated
This script will upgrade Python to the latest stable version.
It will also create a new virtual environment to be used for Home Assistant.
_This upgrade takes loong time to finish._
_This prosess takes about a hour on an RPi 3_
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change RPI 3 to Rapsberry Pi 3.

@@ -0,0 +1,17 @@
## Description
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add information that this is not recommended.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better now? :)

@ludeeus
Copy link
Member Author

ludeeus commented Mar 7, 2018

The main reason is to supply an easy way of upgrading the venv that Home Assistant runs in to a least be supported on jessie (older Hassbian devices), but this will install the latest stable version of Python to comply with future compability issues, and give the benefits that Python 3.6.x have over 3.5.x.

@Landrash Since both you and I is unsure about including this, I suggest we closed it for now and revisit it later if we want :)

@Landrash
Copy link
Collaborator

Landrash commented Mar 7, 2018

I'm actually for this but it would be nice if you make this not run without the --force command and make it print out a warning if you try to install it anyway.

@Landrash Landrash merged commit 3b3c945 into home-assistant:dev Mar 8, 2018
@ludeeus ludeeus deleted the upgrade-python branch March 8, 2018 07:11
@ludeeus ludeeus added this to the v0.8.0 milestone Mar 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants