summaryrefslogtreecommitdiff
blob: b026186f8304f19b03a997934ad4cefa76fb94ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

    <title>python-r1 — multi-impl packages &#8212; Gentoo Python Guide  documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/sphinx_highlight.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="distutils-r1 — standard Python build systems" href="distutils.html" />
    <link rel="prev" title="python-single-r1 — single-impl packages" href="single.html" />
   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <section id="python-r1-multi-impl-packages">
<h1>python-r1 — multi-impl packages<a class="headerlink" href="#python-r1-multi-impl-packages" title="Permalink to this heading"></a></h1>
<p>The <code class="docutils literal notranslate"><span class="pre">python-r1</span></code> eclass is used to install multi-impl packages.
It is considered an expert eclass — when possible, you should prefer
using <code class="docutils literal notranslate"><span class="pre">python-single-r1</span></code> instead.  For packages using distutils
or a similar Python build system, <code class="docutils literal notranslate"><span class="pre">distutils-r1</span></code> eclass should be used
instead.</p>
<p>Eclass reference: <a class="reference external" href="https://devmanual.gentoo.org/eclass-reference/python-r1.eclass/index.html">python-r1.eclass(5)</a></p>
<section id="manual-install">
<span id="index-0"></span><h2>Manual install<a class="headerlink" href="#manual-install" title="Permalink to this heading"></a></h2>
<p>The simplest case of multi-impl package is a package without a specific
build system.  The modules need to be installed manually here,
and <code class="docutils literal notranslate"><span class="pre">python_foreach_impl</span></code> function is used to repeat the install step
for all enabled implementations.</p>
<p>For simple use cases, the install command can be inlined:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span> <span class="c1"># Copyright 1999-2020 Gentoo Foundation</span>
 <span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

 <span class="nv">EAPI</span><span class="o">=</span><span class="m">7</span>

<span class="hll"> <span class="nv">PYTHON_COMPAT</span><span class="o">=(</span> python2_7 <span class="o">)</span>
</span><span class="hll"> inherit python-r1
</span>
 <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;MySQL abstraction layer for python&quot;</span>
 <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;http://software.fionet.com/pSQL/&quot;</span>
 <span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;http://software.fionet.com/pSQL/release/</span><span class="si">${</span><span class="nv">P</span><span class="si">}</span><span class="s2">.tar.gz&quot;</span>

 <span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
 <span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;GPL-2&quot;</span>
 <span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;~amd64 ~x86&quot;</span>
 <span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;&quot;</span>
<span class="hll"> <span class="nv">REQUIRED_USE</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_REQUIRED_USE</span><span class="si">}</span><span class="s2">&quot;</span>
</span>
<span class="hll"> <span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span><span class="s2">&quot;</span>
</span> <span class="nv">DEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span><span class="s2">&quot;</span>

 src_install<span class="o">()</span> <span class="o">{</span>
<span class="hll">     python_foreach_impl python_domodule pSQL.py
</span> <span class="o">}</span>
</pre></div>
</div>
<p>While <code class="docutils literal notranslate"><span class="pre">python_foreach_impl</span></code> can be repeated multiple times, it is
generally better to declare a function when multiple install commands
need to be executed:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span> <span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
 <span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

 <span class="nv">EAPI</span><span class="o">=</span><span class="m">7</span>

 <span class="nv">PYTHON_COMPAT</span><span class="o">=(</span> python2_7 <span class="o">)</span>
 inherit python-r1

 <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;Proxy cache for Gentoo packages&quot;</span>
 <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://sourceforge.net/projects/http-replicator&quot;</span>
 <span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;mirror://sourceforge/</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">/</span><span class="si">${</span><span class="nv">P</span><span class="si">}</span><span class="s2">.tgz&quot;</span>

 <span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;GPL-2&quot;</span>
 <span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
 <span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;~alpha amd64 hppa ppc ~sparc x86&quot;</span>
 <span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;&quot;</span>
 <span class="nv">REQUIRED_USE</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_REQUIRED_USE</span><span class="si">}</span><span class="s2">&quot;</span>

 <span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span><span class="s2">&quot;</span>
 <span class="nv">DEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span><span class="s2">&quot;</span>

<span class="hll"> python_install<span class="o">()</span> <span class="o">{</span>
</span><span class="hll">     python_doscript http-replicator
</span><span class="hll">     python_domodule *.py
</span><span class="hll"> <span class="o">}</span>
</span>
 src_install<span class="o">()</span> <span class="o">{</span>
<span class="hll">     python_foreach_impl python_install
</span> <span class="o">}</span>
</pre></div>
</div>
</section>
<section id="dependencies">
<span id="index-1"></span><h2>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this heading"></a></h2>
<p>When depending on other Python packages, USE dependencies need to be
declared in order to ensure that the dependencies would be built against
all the Python implementations enabled for the package.  This is easily
done via appending the USE dependency string from <code class="docutils literal notranslate"><span class="pre">${PYTHON_USEDEP}</span></code>
to the dependencies:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span><span class="s2"></span>
<span class="s2">    sys-apps/portage[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]</span>
<span class="s2">&quot;</span>
<span class="nv">DEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span><span class="s2">&quot;</span>
</pre></div>
</div>
</section>
<section id="pure-python-autotools-package">
<span id="index-2"></span><h2>Pure Python autotools package<a class="headerlink" href="#pure-python-autotools-package" title="Permalink to this heading"></a></h2>
<p>Another typical case for this eclass is to handle a pure Python package
with a non-standard build system.  In this case, it is generally
necessary to call phase functions via <code class="docutils literal notranslate"><span class="pre">python_foreach_impl</span></code>.  Whenever
possible, out-of-source builds are recommended (i.e. installing to
separate directories from a single source directory).</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span> <span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
 <span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

 <span class="nv">EAPI</span><span class="o">=</span><span class="s2">&quot;6&quot;</span>
 <span class="nv">PYTHON_COMPAT</span><span class="o">=(</span> python3_6 <span class="o">)</span>

 inherit autotools python-r1

 <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;Python wrapper for libcangjie&quot;</span>
 <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;http://cangjians.github.io/&quot;</span>
 <span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://github.com/Cangjians/py</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">/releases/download/v</span><span class="si">${</span><span class="nv">PV</span><span class="si">}</span><span class="s2">/</span><span class="si">${</span><span class="nv">P</span><span class="p">#py</span><span class="si">}</span><span class="s2">.tar.xz&quot;</span>

 <span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;LGPL-3+&quot;</span>
 <span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
 <span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;~amd64 ~x86&quot;</span>
 <span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;&quot;</span>
 <span class="nv">REQUIRED_USE</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_REQUIRED_USE</span><span class="si">}</span><span class="s2">&quot;</span>

 <span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span><span class="s2"></span>
<span class="s2">     app-i18n/libcangjie&quot;</span>
 <span class="nv">DEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span><span class="s2"></span>
<span class="s2">     dev-python/cython[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]</span>
<span class="s2">     virtual/pkgconfig&quot;</span>

 src_prepare<span class="o">()</span> <span class="o">{</span>
     default
     eautoreconf
 <span class="o">}</span>

 src_configure<span class="o">()</span> <span class="o">{</span>
     <span class="nb">local</span> <span class="nv">ECONF_SOURCE</span><span class="o">=</span><span class="si">${</span><span class="nv">S</span><span class="si">}</span>
<span class="hll">     python_foreach_impl run_in_build_dir default
</span> <span class="o">}</span>

 src_compile<span class="o">()</span> <span class="o">{</span>
<span class="hll">     python_foreach_impl run_in_build_dir default
</span> <span class="o">}</span>

 src_test<span class="o">()</span> <span class="o">{</span>
<span class="hll">     python_foreach_impl run_in_build_dir default
</span> <span class="o">}</span>

 src_install<span class="o">()</span> <span class="o">{</span>
<span class="hll">     python_foreach_impl run_in_build_dir default
</span>     einstalldocs
     find <span class="s2">&quot;</span><span class="si">${</span><span class="nv">D</span><span class="si">}</span><span class="s2">&quot;</span> -name <span class="s1">&#39;*.la&#39;</span> -delete <span class="o">||</span> die
 <span class="o">}</span>
</pre></div>
</div>
<p>Note the use of <code class="docutils literal notranslate"><span class="pre">run_in_build_dir</span></code> helper from <code class="docutils literal notranslate"><span class="pre">multibuild</span></code> eclass
(direct inherit is unnecessary here, as it is considered implicit part
of <code class="docutils literal notranslate"><span class="pre">python-r1</span></code> API).  It changes the directory to <code class="docutils literal notranslate"><span class="pre">BUILD_DIR</span></code> (which
is set by <code class="docutils literal notranslate"><span class="pre">python_foreach_impl</span></code> to a unique directory for each
implementation) and runs the specified command there.  In this case,
the ebuild performs autotools out-of-source build in a dedicated
directory for every interpreter enabled.</p>
<p>Also note that the in-build-dir call to <code class="docutils literal notranslate"><span class="pre">default</span></code> does not install
documentation from source directory, hence the additional
<code class="docutils literal notranslate"><span class="pre">einstalldocs</span></code> call.  Libtool-based packages install <code class="docutils literal notranslate"><span class="pre">.la</span></code> files
that are unnecessary for Python extensions, hence they are removed
afterwards.</p>
<p>If the package in question does not support out-of-source builds
(e.g. due to a buggy build system), <code class="docutils literal notranslate"><span class="pre">python_copy_sources</span></code> function
can be used to duplicate the package’s sources in build directories
for each implementation.  The same ebuild easily can be changed
to do that:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span> <span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
 <span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

 <span class="nv">EAPI</span><span class="o">=</span><span class="s2">&quot;6&quot;</span>
 <span class="nv">PYTHON_COMPAT</span><span class="o">=(</span> python3_6 <span class="o">)</span>

 inherit autotools python-r1

 <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;Python wrapper for libcangjie&quot;</span>
 <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;http://cangjians.github.io/&quot;</span>
 <span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://github.com/Cangjians/py</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">/releases/download/v</span><span class="si">${</span><span class="nv">PV</span><span class="si">}</span><span class="s2">/</span><span class="si">${</span><span class="nv">P</span><span class="p">#py</span><span class="si">}</span><span class="s2">.tar.xz&quot;</span>

 <span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;LGPL-3+&quot;</span>
 <span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
 <span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;~amd64 ~x86&quot;</span>
 <span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;&quot;</span>
 <span class="nv">REQUIRED_USE</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_REQUIRED_USE</span><span class="si">}</span><span class="s2">&quot;</span>

 <span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span><span class="s2"></span>
<span class="s2">     app-i18n/libcangjie&quot;</span>
 <span class="nv">DEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span><span class="s2"></span>
<span class="s2">     dev-python/cython[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]</span>
<span class="s2">     virtual/pkgconfig&quot;</span>

 src_prepare<span class="o">()</span> <span class="o">{</span>
     default
     eautoreconf
<span class="hll">     python_copy_sources
</span> <span class="o">}</span>

 src_configure<span class="o">()</span> <span class="o">{</span>
<span class="hll">     python_foreach_impl run_in_build_dir default
</span> <span class="o">}</span>

 src_compile<span class="o">()</span> <span class="o">{</span>
<span class="hll">     python_foreach_impl run_in_build_dir default
</span> <span class="o">}</span>

 src_test<span class="o">()</span> <span class="o">{</span>
<span class="hll">     python_foreach_impl run_in_build_dir default
</span> <span class="o">}</span>

 src_install<span class="o">()</span> <span class="o">{</span>
<span class="hll">     python_foreach_impl run_in_build_dir default
</span>     einstalldocs
     find <span class="s2">&quot;</span><span class="si">${</span><span class="nv">D</span><span class="si">}</span><span class="s2">&quot;</span> -name <span class="s1">&#39;*.la&#39;</span> -delete <span class="o">||</span> die
 <span class="o">}</span>
</pre></div>
</div>
<p>Note that besides adding <code class="docutils literal notranslate"><span class="pre">python_copy_sources</span></code> call, <code class="docutils literal notranslate"><span class="pre">ECONF_SOURCE</span></code>
has been removed in order to disable out-of-source builds.</p>
</section>
<section id="conditional-python-use">
<h2>Conditional Python use<a class="headerlink" href="#conditional-python-use" title="Permalink to this heading"></a></h2>
<p>When the package installs Python components conditionally to a USE flag,
the respective USE conditional needs to be consistently used in metadata
variables and in <code class="docutils literal notranslate"><span class="pre">python_foreach_impl</span></code> calls.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span> <span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
 <span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

 <span class="nv">EAPI</span><span class="o">=</span><span class="m">6</span>
 <span class="nv">PYTHON_COMPAT</span><span class="o">=(</span> python2_7 <span class="o">)</span>

 inherit gnome2 python-r1

 <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;Canvas widget for GTK+ using the cairo 2D library for drawing&quot;</span>
 <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://wiki.gnome.org/GooCanvas&quot;</span>

 <span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;LGPL-2&quot;</span>
 <span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;2.0&quot;</span>
 <span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;~alpha amd64 ia64 ppc ppc64 sparc x86&quot;</span>
<span class="hll"> <span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;python&quot;</span>
</span><span class="hll"> <span class="nv">REQUIRED_USE</span><span class="o">=</span><span class="s2">&quot;python? ( </span><span class="si">${</span><span class="nv">PYTHON_REQUIRED_USE</span><span class="si">}</span><span class="s2"> )&quot;</span>
</span>
 <span class="c1"># python only enables python specific binding override</span>
 <span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="hll"><span class="s2">     python? (</span>
</span><span class="hll"><span class="s2">         </span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span><span class="s2"></span>
</span><span class="hll"><span class="s2">         &gt;=dev-python/pygobject-2.90.4:3[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">] )</span>
</span><span class="s2"> &quot;</span>
 <span class="nv">DEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span><span class="s2">&quot;</span>

 src_prepare<span class="o">()</span> <span class="o">{</span>
     <span class="c1"># Python bindings are built/installed manually.</span>
     sed -e <span class="s2">&quot;/SUBDIRS = python/d&quot;</span> -i bindings/Makefile.am <span class="se">\</span>
         bindings/Makefile.in <span class="o">||</span> die

     gnome2_src_prepare
 <span class="o">}</span>

 src_configure<span class="o">()</span> <span class="o">{</span>
     gnome2_src_configure <span class="se">\</span>
         --disable-python
 <span class="o">}</span>

 src_install<span class="o">()</span> <span class="o">{</span>
     gnome2_src_install

<span class="hll">     <span class="k">if</span> use python<span class="p">;</span> <span class="k">then</span>
</span><span class="hll">         sub_install<span class="o">()</span> <span class="o">{</span>
</span><span class="hll">             python_moduleinto <span class="k">$(</span>python -c <span class="s2">&quot;import gi;print gi._overridesdir&quot;</span><span class="k">)</span>
</span><span class="hll">             python_domodule bindings/python/GooCanvas.py
</span><span class="hll">         <span class="o">}</span>
</span><span class="hll">         python_foreach_impl sub_install
</span><span class="hll">     <span class="k">fi</span>
</span> <span class="o">}</span>
</pre></div>
</div>
<p>Note that in many cases, you will end up having to disable upstream
rules for installing Python files as they are suitable only for
single-impl installs.</p>
</section>
<section id="additional-build-time-python-use">
<span id="index-3"></span><h2>Additional build-time Python use<a class="headerlink" href="#additional-build-time-python-use" title="Permalink to this heading"></a></h2>
<p>Some packages additionally require Python at build time, independently
of Python components installed (i.e. outside <code class="docutils literal notranslate"><span class="pre">python_foreach_impl</span></code>).
The eclass provides extensive API for this purpose but for now we’ll
focus on the simplest case where the global code does not have any
dependencies or they are a subset of dependencies declared already.</p>
<p>In this case, it is sufficient to call <code class="docutils literal notranslate"><span class="pre">python_setup</span></code> before
the routine requiring Python.  It will choose the most preferred
of enabled implementations, and set the global environment for it.  Note
that it is entirely normal that the same environment will be set inside
<code class="docutils literal notranslate"><span class="pre">python_foreach_impl</span></code> afterwards.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="linenos"> 1</span> <span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
<span class="linenos"> 2</span> <span class="c1"># Distributed under the terms of the GNU General Public License v2</span>
<span class="linenos"> 3</span>
<span class="linenos"> 4</span> <span class="nv">EAPI</span><span class="o">=</span><span class="s2">&quot;7&quot;</span>
<span class="linenos"> 5</span>
<span class="linenos"> 6</span> <span class="nv">PYTHON_COMPAT</span><span class="o">=(</span> python<span class="o">{</span>3_6,3_7<span class="o">}</span> <span class="o">)</span>
<span class="linenos"> 7</span> <span class="nv">PYTHON_REQ_USE</span><span class="o">=</span><span class="s2">&quot;ncurses,readline&quot;</span>
<span class="linenos"> 8</span> inherit python-r1
<span class="linenos"> 9</span>
<span class="linenos">10</span> <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;QEMU + Kernel-based Virtual Machine userland tools&quot;</span>
<span class="linenos">11</span> <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;http://www.qemu.org http://www.linux-kvm.org&quot;</span>
<span class="linenos">12</span> <span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;http://wiki.qemu-project.org/download/</span><span class="si">${</span><span class="nv">P</span><span class="si">}</span><span class="s2">.tar.xz&quot;</span>
<span class="linenos">13</span>
<span class="linenos">14</span> <span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;GPL-2 LGPL-2 BSD-2&quot;</span>
<span class="linenos">15</span> <span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
<span class="linenos">16</span> <span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;amd64 ~arm64 ~ppc ~ppc64 x86&quot;</span>
<span class="hll"><span class="linenos">17</span> <span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;python&quot;</span>
</span><span class="hll"><span class="linenos">18</span> <span class="nv">REQUIRED_USE</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_REQUIRED_USE</span><span class="si">}</span><span class="s2">&quot;</span>
</span><span class="linenos">19</span>
<span class="hll"><span class="linenos">20</span> <span class="nv">BDEPEND</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span><span class="s2">&quot;</span>
</span><span class="hll"><span class="linenos">21</span> <span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;python? ( </span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span><span class="s2"> )&quot;</span>
</span><span class="linenos">22</span>
<span class="linenos">23</span> src_configure<span class="o">()</span> <span class="o">{</span>
<span class="hll"><span class="linenos">24</span>     python_setup
</span><span class="linenos">25</span>     ./configure <span class="o">||</span> die
<span class="linenos">26</span> <span class="o">}</span>
<span class="linenos">27</span>
<span class="hll"><span class="linenos">28</span> qemu_python_install<span class="o">()</span> <span class="o">{</span>
</span><span class="hll"><span class="linenos">29</span>     python_domodule <span class="s2">&quot;</span><span class="si">${</span><span class="nv">S</span><span class="si">}</span><span class="s2">/python/qemu&quot;</span>
</span><span class="hll"><span class="linenos">30</span>
</span><span class="hll"><span class="linenos">31</span>     python_doscript <span class="s2">&quot;</span><span class="si">${</span><span class="nv">S</span><span class="si">}</span><span class="s2">/scripts/kvm/vmxcap&quot;</span>
</span><span class="hll"><span class="linenos">32</span>     python_doscript <span class="s2">&quot;</span><span class="si">${</span><span class="nv">S</span><span class="si">}</span><span class="s2">/scripts/qmp/qmp-shell&quot;</span>
</span><span class="hll"><span class="linenos">33</span>     python_doscript <span class="s2">&quot;</span><span class="si">${</span><span class="nv">S</span><span class="si">}</span><span class="s2">/scripts/qmp/qemu-ga-client&quot;</span>
</span><span class="hll"><span class="linenos">34</span> <span class="o">}</span>
</span><span class="linenos">35</span>
<span class="linenos">36</span> src_install<span class="o">()</span> <span class="o">{</span>
<span class="linenos">37</span>     default
<span class="hll"><span class="linenos">38</span>     <span class="k">if</span> use python<span class="p">;</span> <span class="k">then</span>
</span><span class="hll"><span class="linenos">39</span>         python_foreach_impl qemu_python_install
</span><span class="hll"><span class="linenos">40</span>     <span class="k">fi</span>
</span><span class="linenos">41</span> <span class="o">}</span>
</pre></div>
</div>
<p>Note that the parts affecting installation of runtime components
(<code class="docutils literal notranslate"><span class="pre">RDEPEND</span></code>, <code class="docutils literal notranslate"><span class="pre">python_foreach_impl</span></code>) are made conditional to the USE
flag, while parts affecting build time (<code class="docutils literal notranslate"><span class="pre">REQUIRED_USE</span></code>, <code class="docutils literal notranslate"><span class="pre">BDEPEND</span></code>,
<code class="docutils literal notranslate"><span class="pre">python_setup</span></code>) are unconditional.</p>
</section>
</section>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">Gentoo Python Guide</a></h1>








<h3>Navigation</h3>
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="preface.html">Preface</a></li>
<li class="toctree-l1"><a class="reference internal" href="interpreter.html">Python interpreters</a></li>
<li class="toctree-l1"><a class="reference internal" href="eclass.html">Choosing between Python eclasses</a></li>
<li class="toctree-l1"><a class="reference internal" href="basic.html">Common basics</a></li>
<li class="toctree-l1"><a class="reference internal" href="any.html">python-any-r1 — build-time dependency</a></li>
<li class="toctree-l1"><a class="reference internal" href="single.html">python-single-r1 — single-impl packages</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">python-r1 — multi-impl packages</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#manual-install">Manual install</a></li>
<li class="toctree-l2"><a class="reference internal" href="#dependencies">Dependencies</a></li>
<li class="toctree-l2"><a class="reference internal" href="#pure-python-autotools-package">Pure Python autotools package</a></li>
<li class="toctree-l2"><a class="reference internal" href="#conditional-python-use">Conditional Python use</a></li>
<li class="toctree-l2"><a class="reference internal" href="#additional-build-time-python-use">Additional build-time Python use</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="distutils.html">distutils-r1 — standard Python build systems</a></li>
<li class="toctree-l1"><a class="reference internal" href="distutils-legacy.html">distutils-r1 legacy concepts</a></li>
<li class="toctree-l1"><a class="reference internal" href="helper.html">Common helper functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="depend.html">Advanced dependencies</a></li>
<li class="toctree-l1"><a class="reference internal" href="test.html">Resolving test suite problems</a></li>
<li class="toctree-l1"><a class="reference internal" href="pytest.html">pytest recipes</a></li>
<li class="toctree-l1"><a class="reference internal" href="concept.html">Advanced concepts</a></li>
<li class="toctree-l1"><a class="reference internal" href="expert-multi.html">Expert python-r1 usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="buildsys.html">Integration with build systems written in Python</a></li>
<li class="toctree-l1"><a class="reference internal" href="porting.html">Porting tips</a></li>
<li class="toctree-l1"><a class="reference internal" href="migration.html">Migration guides</a></li>
<li class="toctree-l1"><a class="reference internal" href="qawarn.html">QA checks and warnings</a></li>
<li class="toctree-l1"><a class="reference internal" href="package-maintenance.html">Python package maintenance</a></li>
<li class="toctree-l1"><a class="reference internal" href="interpreter-maintenance.html">Maintenance of Python implementations</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="single.html" title="previous chapter">python-single-r1 — single-impl packages</a></li>
      <li>Next: <a href="distutils.html" title="next chapter">distutils-r1 — standard Python build systems</a></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2020, Michał Górny, license: CC BY 4.0.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 5.2.3</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
      |
      <a href="_sources/multi.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>