openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Upgrade from Python 3.9.4 to Python 3.10.6

Open cclauss opened this issue 4 years ago • 8 comments

Closes #6309 which I got into a bad git state. :-( But then the Renovate tool auto-undid my butchery. :-) Closes #5727

My sense is that:

  • [x] .python-version can be removed as it was only used by pyenv
  • [x] .github/workflows/codegen_api_docs.yml needs to be updated
  • [x] .github/workflows/python_tests.yml needs to be updated
  • [x] .pre-commit-config.yaml needs to be updated
  • [x] python3.10 -m venv --upgrade .venv

Technical

Testing

Screenshot

Stakeholders

cclauss avatar Mar 29 '22 15:03 cclauss

For testing, please do:

  1. On ol-dev1 (in ol-cclauss), check out branch and build a new olbase image tagged -t openlibrary/olbase:py3.10
  2. Ask @cdrini to push this up to docker hub once it's done
  3. Pull it down locally and test the site with the OLIMAGE param
    • Also test solr-updater starts up ok ; it's using FnToCLI which has caused issues with types/python handling of types
  4. Restart testing.openlibrary.org with the OLIMAGE param ; confirm things work
  5. Merge!

(Also: OMG py3.10 has pattern matching!!!)

cdrini avatar Apr 01 '22 19:04 cdrini

Lots of neat goodies in here! https://docs.python.org/3/whatsnew/3.10.html But pattern matching definitely steals the show :) Nothing looks too breaking

cdrini avatar Apr 01 '22 19:04 cdrini

Now that Ubuntu 22.04 LTS (Jammy Jellyfish) is shipping with Python 3.10.4 as the default Python, there is another way to execute this PR -- Stay on Ubuntu but upgrade to the current LTS.

docker run --rm -it ubuntu:jammy bash
# And then inside that ubuntu:jammy container do...
apt-get -qq update && apt-get install -y python3 && python3 --version && exit

--> Python 3.10.4

The Pro is that we stay on Ubuntu LTS but the cons are that future Python upgrades remain complex and we loose the opportunity to slim down our image size.

My vote is that we continue with this PR which shifts us from Ubuntu to Debian-slim.

cclauss avatar Apr 22 '22 09:04 cclauss

I also vote for debian slim

jimman2003 avatar Apr 22 '22 11:04 jimman2003

Based on https://github.com/internetarchive/openlibrary/tree/master/docker#developing-the-dockerfile And https://github.com/internetarchive/openlibrary/pull/6340#issuecomment-1086270358 On ol-dev1 in /opt/ol-cclauss

  • [ ] docker build --no-cache -t openlibrary/olbase:py3.10 -f docker/Dockerfile.olbase .

Installing collected packages: pip WARNING: The scripts pip, pip3 and pip3.10 are installed in '/home/openlibrary/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Step 25/27 : RUN npm ci Fails on conflicts.

cclauss avatar Jun 29 '22 15:06 cclauss

@jimchamp and I went thru the process together today on Zoom and were unable to resolve the npi ci issues. We will probably need to Zoom with @cdrini to make progress on the build.

cclauss avatar Aug 04 '22 14:08 cclauss

@cdrini on Slack > Ahh, this thing. I thought we fixed this... let me take a look @cdrini on Slack > Ah we did fix it! Do a rebase against master and it should work :+1:

docker build --no-cache -t openlibrary/olbase:py3.10 -f docker/Dockerfile.olbase .

[ ... ]
Successfully built 9ca97e31171a
Successfully tagged openlibrary/olbase:py3.10

hostname ; pwd

ol-dev1.us.archive.org
/opt/ol-cclauss

Yeah! Progress. (Doah! I had rebased locally but not on ol-dev1. Arrggh)

cclauss avatar Aug 05 '22 08:08 cclauss

https://internetarchive.slack.com/archives/C06RPDLTG/p1659973072425089

Python 3.11 release candidate 1 has just shipped at https://www.python.org/download/pre-releases

We run infogami and openlibrary tests on Python 3.11 pre-release at: https://github.com/internetarchive/infogami/blob/master/.github/workflows/python_tests.yml and https://github.com/internetarchive/infogami/blob/master/.github/workflows/openlibrary_tests.yml

cclauss avatar Aug 08 '22 15:08 cclauss