1
0
Fork
You've already forked python3
0
forked from ansible/python3
Ansible role that installs Python 3, pip3 and associated tools
  • Diff 100%
2021年07月12日 01:55:40 +02:00
defaults Added support for deadsnakes PPA. Improved handling of vars. 2021年07月03日 02:56:54 +02:00
files Install python3, pip3, mpv and mps-youtube (with patch) 2021年03月14日 13:22:12 +01:00
tasks Role now works for Ubuntu focal, and only installs PPA on <=18 2021年07月12日 01:55:40 +02:00
vars Role now works for Ubuntu focal, and only installs PPA on <=18 2021年07月12日 01:55:40 +02:00
.gitignore Added support for deadsnakes PPA. Improved handling of vars. 2021年07月03日 02:56:54 +02:00
README.md Added support for deadsnakes PPA. Improved handling of vars. 2021年07月03日 02:56:54 +02:00

Python3

Upgrading beyond 3.6.9 on Ubuntu bionic

The most straight-forward way is to use the deadsnakes PPA.

Other ansible roles for Python:

Testing the python installed from deadsnakes PPA on rosetta

Before any changes:

taha@rosetta:~
$ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root 9 Apr 16 2018 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root 9 Apr 16 2018 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3633000 Feb 27 16:10 /usr/bin/python2.7
lrwxrwxrwx 1 root root 33 Feb 27 16:10 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 16 Apr 16 2018 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 Mar 9 16:10 /usr/bin/python3 -> python3.6
-rwxr-xr-x 2 root root 4526456 Jan 26 16:33 /usr/bin/python3.6
lrwxrwxrwx 1 root root 33 Jan 26 16:33 /usr/bin/python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x 2 root root 4526456 Jan 26 16:33 /usr/bin/python3.6m
lrwxrwxrwx 1 root root 34 Jan 26 16:33 /usr/bin/python3.6m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx 1 root root 16 Oct 25 2018 /usr/bin/python3-config -> python3.6-config
-rwxr-xr-x 1 root root 384 Apr 11 2018 /usr/bin/python3-futurize
lrwxrwxrwx 1 root root 10 Mar 9 16:10 /usr/bin/python3m -> python3.6m
lrwxrwxrwx 1 root root 17 Oct 25 2018 /usr/bin/python3m-config -> python3.6m-config
-rwxr-xr-x 1 root root 388 Apr 11 2018 /usr/bin/python3-pasteurize
lrwxrwxrwx 1 root root 16 Apr 16 2018 /usr/bin/python-config -> python2.7-config

Now ran this role with ppa_deadsnakes.enabled and version 3.8.

taha@rosetta:~
$ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root 9 Apr 16 2018 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root 9 Apr 16 2018 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3633000 Feb 27 16:10 /usr/bin/python2.7
lrwxrwxrwx 1 root root 33 Feb 27 16:10 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 16 Apr 16 2018 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 Mar 9 16:10 /usr/bin/python3 -> python3.6
-rwxr-xr-x 2 root root 4526456 Jan 26 16:33 /usr/bin/python3.6
lrwxrwxrwx 1 root root 33 Jan 26 16:33 /usr/bin/python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x 2 root root 4526456 Jan 26 16:33 /usr/bin/python3.6m
lrwxrwxrwx 1 root root 34 Jan 26 16:33 /usr/bin/python3.6m-config -> x86_64-linux-gnu-python3.6m-config
-rwxr-xr-x 1 root root 5134032 May 5 05:01 /usr/bin/python3.8
lrwxrwxrwx 1 root root 33 May 5 05:01 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config
lrwxrwxrwx 1 root root 16 Oct 25 2018 /usr/bin/python3-config -> python3.6-config
-rwxr-xr-x 1 root root 384 Apr 11 2018 /usr/bin/python3-futurize
lrwxrwxrwx 1 root root 10 Mar 9 16:10 /usr/bin/python3m -> python3.6m
lrwxrwxrwx 1 root root 17 Oct 25 2018 /usr/bin/python3m-config -> python3.6m-config
-rwxr-xr-x 1 root root 388 Apr 11 2018 /usr/bin/python3-pasteurize
lrwxrwxrwx 1 root root 16 Apr 16 2018 /usr/bin/python-config -> python2.7-config

At this point:

taha@rosetta:~
$ python3.8 --version
Python 3.8.10
$ python3 --version
Python 3.6.9
$ python --version
Python 2.7.17

Question is, then, should I symlink python3 to 3.8? Or would that break things? For now, let's not.

mps-youtube

I have removed the patch from asks2, but mpsyt still crashes immediately after finishing playing a video. This appears to be a different issue than the one the patch was intended to fix.

Why we install pip packages as user, not root

I have moved away from installing pip as the system user (root) because that lead to really hard-to-overcome clashes between pip packages and apt packages, such as pycairo.

Attempting uninstall: pycairo
Found existing installation: pycairo 1.16.2
stderr: ERROR: Cannot uninstall 'pycairo'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall

What if we uninstall python3-cairo? This was explicitly requested by the screenkey play, but is a dependency of multiple other projects:

(master) $ sudo apt remove python3-cairo 
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following packages were automatically installed and are no longer required:
 fortune-mod fortunes-min gedit-common gir1.2-ayatanaappindicator3-0.1 gir1.2-gexiv2-0.10
 gir1.2-gtksource-3.0 libayatana-appindicator3-1 libayatana-indicator3-7 libgexiv2-2 libgspell-1-1
 libgspell-1-common libgtksourceview-3.0-1 libgtksourceview-3.0-common librecode0 python3-bs4
 python3-html5lib python3-lxml python3-olefile python3-pil python3-webencodings
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED
 gedit meld python3-cairo python3-cairo-dev python3-gi-cairo variety
0 to upgrade, 0 to newly install, 6 to remove and 21 not to upgrade.
After this operation, 7,605 kB disk space will be freed.
Do you want to continue? [Y/n] 

No, that would break too many other packages.

Options?

  • simply power on by adding --ignore-installed to pip extra args, but that risks putting the entire system in an unmaintainable state
  • would it help if we changed pip_user from root to {{ ansible_env.USER }}? (don't really need it to be root...)
  • if that does not help, then what?
  • install more pip packages in their own virtualenvs, instead of like now?
  • install python from source (a so-called private python installation), would that help?

Good commentary on this subject:

While working on this issue, I deleted /usr/lib/python3 which broke the entire system. Had to reinstall the OS from scratch...

Places where Python places its packages

And ditto for Python 2:

/usr/lib/python3/
/usr/lib/python3.6/
/usr/local/lib/python3.6/dist-packages/
~/.local/lib/python3.6/site-packages/