Difference between revisions of "Python"
AstroFloyd (talk | contribs) m (→Version upgrade: Add depclean command to unmerge old Python version) |
(Add information about packages not liking PYTHON_SINGLE_TARGET="python3_*") |
||
| Line 60: | Line 60: | ||
{{Emerge|--update --newuse --deep @world}} | {{Emerge|--update --newuse --deep @world}} | ||
again. You may be asked to update any remaining <code>python_targets_python3_4</code> USE flags as well. | again. You may be asked to update any remaining <code>python_targets_python3_4</code> USE flags as well. | ||
| + | |||
| + | Note that many popular packages such as Docker still require <code>PYTHON_SINGLE_TARGET</code> to be set to <code>python2_7</code> due to various dependencies such as ''app-text/asciidoc'' which do not yet support Python 3. | ||
Once your upgrade has completed, you should be able to remove the old Python version using | Once your upgrade has completed, you should be able to remove the old Python version using | ||
Revision as of 17:13, 1 December 2017
Python is the language that powers Portage, eselect, equery, and other tools in Gentoo.
Installation
Since Python is so integral to Gentoo there is little chance it is not installed. Doing so would be like removing the heart from Gentoo. There is occasion where Python must be recompiled in order to add new features or to upgrade.
USE flags
USE flags for dev-lang/python An interpreted, interactive, object-oriented programming language
+ensurepip
|
Install the ensurepip module that uses bundled wheels to bootstrap pip and setuptools (if disabled, it will be only possible to use venv `--without-pip`) |
+ncurses
|
Add ncurses support (console display library) |
+readline
|
Enable support for libreadline, a GNU line-editing library that almost everyone wants |
+sqlite
|
Add support for sqlite - embedded sql database |
+ssl
|
Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security) |
+xml
|
Add support for XML files |
berkdb
|
Add support for sys-libs/db (Berkeley DB) |
bluetooth
|
Build Bluetooth protocol support in socket module |
build
|
!!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used for creating build images and the first half of bootstrapping [make stage1] |
debug
|
Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces |
examples
|
Install examples, usually source code |
gdbm
|
Add support for sys-libs/gdbm (GNU database libraries) |
jit
|
Enable experimental Just-In-Time compilation support. |
libedit
|
Use the libedit library (replacement for readline) |
pgo
|
Optimize the build using Profile Guided Optimization (PGO) by running Python's test suite and collecting statistics based on its performance. This will take longer to build. |
tail-call-interp
|
Enable the tail call interpreter. May lead to better performance but is still new and dependent on latest toolchain versions (Clang 19, GCC 15). |
test
|
Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently) |
tk
|
Add support for Tk GUI toolkit |
valgrind
|
Disable pymalloc when running under dev-debug/valgrind is detected (may incur minor performance penalty even when valgrind is not used) |
verify-sig
|
Verify upstream signatures on distfiles |
wininst
|
Install Windows executables required to create an executable installer for MS Windows |
Emerge
Python is slotted, which means there is more than one version Python that can be installed on a Gentoo system at the same time. Select the version to install by using an : (colon) and the package atom followed by one of the slot numbers:
For example, to install Python 3.4:
root #emerge --ask dev-lang/python:3.4Configuration
Setting the active interpreter
The active Python interpreter can be set using the eselect python command. First list the available interpreters using list:
root #eselect python listSelect the desired interpreter using set. In this example the second option was chosen:
root #eselect python set 2
Version upgrade
The old python-updater is no longer used.
Before you start, ensure that your system is uptodate:
root #emerge --ask --update --newuse --deep @worldThen, update Python if you hadn't done so already:
root #emerge --ask --update dev-lang/pythonIn order to tell your system to use the new Python version, update the variables PYTHON_TARGETS and PYTHON_SINGLE_TARGET, for instance in your make.conf (when updating from 3.4 to 3.5):
- PYTHON_TARGETS="python2_7 python3_5"
- PYTHON_SINGLE_TARGET="python3_5"
and run
root #emerge --ask --update --newuse --deep @worldagain. You may be asked to update any remaining python_targets_python3_4 USE flags as well.
Note that many popular packages such as Docker still require PYTHON_SINGLE_TARGET to be set to python2_7 due to various dependencies such as app-text/asciidoc which do not yet support Python 3.
Once your upgrade has completed, you should be able to remove the old Python version using
root #emerge --ask --depclean dev-lang/pythonUsage
Invocation
A specific version of the Python interpreter can be invoked from the command-line directly by running:
user $python2.7Or
user $python3.4To execute a script with Python 2.x use the following header:
/usr/local/bin/repo#!/usr/bin/env python2
...