1 |
mgorny 12/11/04 14:05:12 |
2 |
|
3 |
Added: user-guide.xml |
4 |
Log: |
5 |
Initial version of python-r1 user guide. |
6 |
|
7 |
Revision Changes Path |
8 |
1.1 xml/htdocs/proj/en/Python/python-r1/user-guide.xml |
9 |
|
10 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/proj/en/Python/python-r1/user-guide.xml?rev=1.1&view=markup |
11 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/proj/en/Python/python-r1/user-guide.xml?rev=1.1&content-type=text/plain |
12 |
|
13 |
Index: user-guide.xml |
14 |
=================================================================== |
15 |
<?xml version="1.0" encoding="UTF-8"?> |
16 |
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
17 |
|
18 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/Python/python-r1/user-guide.xml,v 1.1 2012/11/04 14:05:12 mgorny Exp $ --> |
19 |
|
20 |
<guide lang="en"> |
21 |
<title>python-r1 User's Guide</title> |
22 |
|
23 |
<author title="Author"> |
24 |
<mail link="mgorny@g.o">Michał Górny</mail> |
25 |
</author> |
26 |
|
27 |
<author title="Editor"> |
28 |
<mail link="idella4@g.o">Ian Delaney</mail> |
29 |
</author> |
30 |
|
31 |
<abstract> |
32 |
This guide provides a basic insight to how Python packages |
33 |
are deployed using the python-r1 eclasses. It describes |
34 |
the multi-implementation concept and offers a guide to selecting |
35 |
preferred implementations. |
36 |
</abstract> |
37 |
|
38 |
<!-- The content of this document is licensed under the CC-BY-SA license --> |
39 |
<!-- See http://creativecommons.org/licenses/by-sa/3.0/ --> |
40 |
<license version="3.0"/> |
41 |
|
42 |
<version>1</version> |
43 |
<date>2012-11-04</date> |
44 |
|
45 |
<chapter id="Multi_implementation_support"> |
46 |
<title>Multi-implementation support</title> |
47 |
|
48 |
<section id="mis_Short_introduction"> |
49 |
<title>Short introduction</title> |
50 |
|
51 |
<body> |
52 |
<p> |
53 |
Currently Gentoo supports three different Python interpreters |
54 |
— CPython, PyPy and Jython. CPython has two major but distinct |
55 |
branches — called simply Python 2 & Python 3. This makes |
56 |
four <e>interpreter groups</e>. |
57 |
</p> |
58 |
|
59 |
<p> |
60 |
Each group is further sub-divided into branches, which |
61 |
are identified by minor version numbers: Python 2.7, 2.6, 2.5, |
62 |
3.3, 3.2, 3.1; PyPy 1.9 and 1.8; and lastly, Jython 2.5. All |
63 |
these versions can be installed in Gentoo side-by-side, and are |
64 |
collectively referred to as <e>Python implementations</e>. |
65 |
</p> |
66 |
|
67 |
<p> |
68 |
There may be various reasons to install multiple Python |
69 |
implementations. The most important is incompatibilities |
70 |
that occur between each one's Python scripts. Many Python |
71 |
packages in Gentoo still don't support Python 3. There are also |
72 |
a few packages which support only Python 3. |
73 |
</p> |
74 |
|
75 |
<p> |
76 |
Having two or more implementations installed allows our users |
77 |
to run all kinds of scripts. Another common and significant |
78 |
advantage of having multiple Python versions installed |
79 |
is the ability to test a script against multiple interpreters. |
80 |
</p> |
81 |
</body> |
82 |
</section> |
83 |
|
84 |
<section id="mis_PYTHON_TARGETS_setting"> |
85 |
<title>PYTHON_TARGETS setting</title> |
86 |
|
87 |
<body> |
88 |
<p> |
89 |
Having a number of implementations to choose from, the modern |
90 |
Python packages provide users with an ability to explicitly |
91 |
select one or more Python implementations. This selection |
92 |
is performed through the use of <c>PYTHON_TARGETS</c> expanded |
93 |
USE flags. |
94 |
</p> |
95 |
|
96 |
<pre caption="Example output of emerge with PYTHON_TARGETS-aware |
97 |
package"> |
98 |
$ <i>emerge -pv app-portage/flaggie</i> |
99 |
|
100 |
These are the packages that would be merged, in order: |
101 |
|
102 |
Calculating dependencies... done! |
103 |
[<keyword>ebuild R *</keyword>] <ident>app-portage/flaggie-9999::mgorny</ident> <var>PYTHON_TARGETS</var>="<const>python2_6 python2_7 python3_2</const> <comment>-python3_1</comment>" 0 kB |
104 |
|
105 |
Total: 1 package (1 reinstall), Size of downloads: 0 kB |
106 |
</pre> |
107 |
|
108 |
<p> |
109 |
As you can see in the above sample, the package in question |
110 |
supports four Python implementations of which three are enabled. |
111 |
This means that all the Python modules and scripts will be |
112 |
installed for those three Python versions, and thus they will |
113 |
be available to the scripts run using those versions. |
114 |
</p> |
115 |
|
116 |
<p> |
117 |
CPython versions 2.7 and 3.2 are enabled by default. If you wish |
118 |
to use a different set of enabled implementations, you have |
119 |
to set the <c>PYTHON_TARGETS</c> variable |
120 |
in <path>make.conf</path>. Please note that it is |
121 |
not incremental — that is, you need to list all the enabled |
122 |
implementations. |
123 |
</p> |
124 |
|
125 |
<pre caption="Example make.conf enabling Python 2.6, 2.7 and 3.2"> |
126 |
<var>PYTHON_TARGETS</var>=<const>"python2_6 python2_7 python3_2"</const> |
127 |
</pre> |
128 |
</body> |
129 |
</section> |
130 |
|
131 |
<section id="mis_Python_script_renaming"> |
132 |
<title>Python script renaming</title> |
133 |
|
134 |
<body> |
135 |
<p> |
136 |
You may have noticed already that the default installation |
137 |
of Python scripts in Gentoo differs to that of other |
138 |
distributions (and Python packages themselves). This is done |
139 |
in order to completely support multiple Python implementations |
140 |
being used on the same system. |
141 |
</p> |
142 |
|
143 |
<pre caption="Example Python scripts installed by a package"> |
144 |
$ <i>ls -1 /usr/bin/flaggie*</i> |
145 |
<var>/usr/bin/flaggie</var> |
146 |
/usr/bin/flaggie-python2.6 |
147 |
/usr/bin/flaggie-python2.7 |
148 |
/usr/bin/flaggie-python3.2 |
149 |
</pre> |
150 |
|
151 |
<p> |
152 |
Firstly, all Python scripts installed by packages are installed |
153 |
in per-implementation variants. This ensures that any changes |
154 |
necessary for a given Python implementation are preserved |
155 |
in the scripts. It also makes it possible to easily run |
156 |
the script with the desired interpreter. |
157 |
</p> |
158 |
|
159 |
<p> |
160 |
Additionally, in place of the standard script, a wrapper |
161 |
is installed. The wrapper is a very simple tool which checks |
162 |
which of the Python implementations supported by the script |
163 |
would be the preferred one and runs the appropriate script |
164 |
variant. |
165 |
</p> |
166 |
</body> |
167 |
</section> |
168 |
</chapter> |
169 |
|
170 |
<!-- vim:se tw=72 ts=2 sts=2 sw=2 :--> |
171 |
</guide> |