summaryrefslogtreecommitdiff
blob: 04779f4e607fec0a3378d9b36bbcc6e971dc6e08 (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
<!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-any-r1 — build-time dependency &#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="python-single-r1 — single-impl packages" href="single.html" />
    <link rel="prev" title="Common basics" href="basic.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-any-r1-build-time-dependency">
<h1>python-any-r1 — build-time dependency<a class="headerlink" href="#python-any-r1-build-time-dependency" title="Permalink to this heading"></a></h1>
<p>The <code class="docutils literal notranslate"><span class="pre">python-any-r1</span></code> eclass is used to enable Python support
in packages needing it purely at build time.</p>
<p>Eclass reference: <a class="reference external" href="https://devmanual.gentoo.org/eclass-reference/python-any-r1.eclass/index.html">python-any-r1.eclass(5)</a></p>
<section id="basic-use-for-unconditional-python">
<h2>Basic use for unconditional Python<a class="headerlink" href="#basic-use-for-unconditional-python" title="Permalink to this heading"></a></h2>
<p>The defining feature of this eclass is that it defines a <code class="docutils literal notranslate"><span class="pre">pkg_setup</span></code>
phase.  It normally calls <code class="docutils literal notranslate"><span class="pre">python_setup</span></code> function in order to find
a suitable Python interpreter, and set the global environment
appropriately.</p>
<p>This means that a most trivial package using an autotools-compatible
build system that needs Python at build time could look like
the following:</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="hll"> <span class="nv">PYTHON_COMPAT</span><span class="o">=(</span> python3_<span class="o">{</span><span class="m">6</span>..8<span class="o">}</span> <span class="o">)</span>
</span><span class="hll"> inherit python-any-r1
</span>
 <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;A repository of data files describing media player capabilities&quot;</span>
 <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://cgit.freedesktop.org/media-player-info/&quot;</span>
 <span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://www.freedesktop.org/software/</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">.tar.gz&quot;</span>

 <span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;BSD&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 ~arm ~arm64 ~hppa ~ia64 ~mips ppc ppc64 ~sh ~sparc x86&quot;</span>
 <span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;&quot;</span>

 <span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;&gt;=virtual/udev-208&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="nv">BDEPEND</span><span class="o">=</span><span class="s2">&quot;</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="s2">     virtual/pkgconfig</span>
<span class="s2"> &quot;</span>
</pre></div>
</div>
<p>This ebuild demonstrates the absolute minimum working code.  Only
the three highlighted lines are specific to Python eclasses, plus
the implicitly exported <code class="docutils literal notranslate"><span class="pre">pkg_setup</span></code> phase.</p>
<span class="target" id="index-0"></span><span class="target" id="index-1"></span><span class="target" id="index-2"></span></section>
<section id="dependencies">
<span id="index-3"></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
the Python implementation used for the package.  When Python
dependencies need to be specified, <code class="docutils literal notranslate"><span class="pre">${PYTHON_DEPS}</span></code> gets replaced
by a call to <code class="docutils literal notranslate"><span class="pre">python_gen_any_dep</span></code> generator and a matching
<code class="docutils literal notranslate"><span class="pre">python_check_deps()</span></code> function.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">python_gen_any_dep</span></code> function accepts a template where literal
<code class="docutils literal notranslate"><span class="pre">${PYTHON_USEDEP}</span></code> is substituted with appropriate USE dependency.
It generates an any-of (<code class="docutils literal notranslate"><span class="pre">||</span></code>) dependency that requires all
the packages to use the same Python interpreter, for at least one
of the supported implementations.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">python_check_deps()</span></code> function needs to be declared by ebuild
in order to test whether the implementation in question is suitable
for building the package.  In particular, it needs to verify whether
the particular branch of the any-of was satisfied, or whether all
dependencies were installed for the current interpreter.  For that
purpose, the function is called with <code class="docutils literal notranslate"><span class="pre">PYTHON_USEDEP</span></code> variable declared
to the USE dependency string for the currently tested implementation.</p>
<p>This is best explained using an example:</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> python3_<span class="o">{</span><span class="m">6</span>,7,8<span class="o">}</span> <span class="o">)</span>

 inherit meson python-any-r1

 <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;A file manager for Cinnamon, forked from Nautilus&quot;</span>
 <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;http://developer.linuxmint.com/projects/cinnamon-projects.html&quot;</span>
 <span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://github.com/linuxmint/nemo/archive/</span><span class="si">${</span><span class="nv">PV</span><span class="si">}</span><span class="s2">.tar.gz -&gt; </span><span class="si">${</span><span class="nv">P</span><span class="si">}</span><span class="s2">.tar.gz&quot;</span>

 <span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;GPL-2+ LGPL-2+ FDL-1.1&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">DEPEND</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="hll"><span class="s2">     </span><span class="k">$(</span>python_gen_any_dep <span class="s1">&#39;</span>
</span><span class="hll"><span class="s1">         dev-python/polib[${PYTHON_USEDEP}]</span>
</span><span class="hll"><span class="s1">         dev-python/pygobject:3[${PYTHON_USEDEP}]</span>
</span><span class="hll"><span class="s1">     &#39;</span><span class="k">)</span><span class="s2"></span>
</span><span class="s2"> &quot;</span>

<span class="hll"> python_check_deps<span class="o">()</span> <span class="o">{</span>
</span><span class="hll">     python_has_version <span class="s2">&quot;dev-python/polib[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span> <span class="o">&amp;&amp;</span>
</span><span class="hll">     python_has_version <span class="s2">&quot;dev-python/pygobject:3[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span>
</span><span class="hll"> <span class="o">}</span>
</span></pre></div>
</div>
<p>This means that the package will work with Python 3.6, 3.7 or 3.8,
provided that its both dependencies have the same implementation
enabled.  The generated <code class="docutils literal notranslate"><span class="pre">||</span></code> dep ensures that this is true for
at least one of them, while <code class="docutils literal notranslate"><span class="pre">python_check_deps()</span></code> verifies which
branch was satisfied.</p>
<p>The eclass provides a <code class="docutils literal notranslate"><span class="pre">python_has_version</span></code> wrapper that helps
verifying whether the dependencies are installed.  The wrapper takes
a single optional dependency class flag, followed by one or more package
dependencies.  Similarly to EAPI 7+ <code class="docutils literal notranslate"><span class="pre">has_version</span></code>, the root flag
can be <code class="docutils literal notranslate"><span class="pre">-b</span></code> (for packages from <code class="docutils literal notranslate"><span class="pre">BDEPEND</span></code>), <code class="docutils literal notranslate"><span class="pre">-d</span></code> (for <code class="docutils literal notranslate"><span class="pre">DEPEND</span></code>)
or <code class="docutils literal notranslate"><span class="pre">-r</span></code> (for <code class="docutils literal notranslate"><span class="pre">RDEPEND</span></code>, <code class="docutils literal notranslate"><span class="pre">IDEPEND</span></code> and <code class="docutils literal notranslate"><span class="pre">PDEPEND</span></code>).  When no flag
is passed, <code class="docutils literal notranslate"><span class="pre">-b</span></code> is assumed.  The wrapper verifies whether
the specified packages are installed, verbosely printing the checks
performed and their results.  It returns success if all packages were
found, false otherwise.</p>
<p>Note that when multiple invocations are used, <code class="docutils literal notranslate"><span class="pre">&amp;&amp;</span></code> needs to be used
to chain the results.  The example above can be also written as:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>python_check_deps<span class="o">()</span> <span class="o">{</span>
    python_has_version <span class="se">\</span>
        <span class="s2">&quot;dev-python/polib[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span> <span class="se">\</span>
        <span class="s2">&quot;dev-python/pygobject:3[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>It is important to understand that this works correctly only if
<code class="docutils literal notranslate"><span class="pre">python_gen_any_dep</span></code> and <code class="docutils literal notranslate"><span class="pre">python_check_deps()</span></code> match exactly.
Furthermore, for any USE flag combination <code class="docutils literal notranslate"><span class="pre">python_gen_any_dep</span></code> must be
called at most once.  In particular, it is invalid to split the above
example into multiple <code class="docutils literal notranslate"><span class="pre">python_gen_any_dep</span></code> calls.</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>In some packages, Python is only necessary with specific USE flag
combinations.  This is particularly common when Python is used for
the test suite.  In that case, the dependencies and <code class="docutils literal notranslate"><span class="pre">pkg_setup</span></code> call
need to be wrapped in appropriate USE conditions:</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> python3_<span class="o">{</span><span class="m">6</span>,7<span class="o">}</span> <span class="o">)</span>
 inherit python-any-r1

 <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;Programmable Completion for bash&quot;</span>
 <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://github.com/scop/bash-completion&quot;</span>
 <span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://github.com/scop/bash-completion/releases/download/</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="si">}</span><span class="s2">.tar.xz&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 arm ~arm64 ~hppa ia64 ~mips ppc ~ppc64 ~s390 ~sh sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris&quot;</span>
<span class="hll"> <span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;test&quot;</span>
</span><span class="hll"> <span class="nv">RESTRICT</span><span class="o">=</span><span class="s2">&quot;!test? ( test )&quot;</span>
</span>
 <span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;&gt;=app-shells/bash-4.3_p30-r1:0&quot;</span>
 <span class="nv">DEPEND</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="hll"><span class="s2">     test? (</span>
</span><span class="hll"><span class="s2">         </span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span><span class="s2"></span>
</span><span class="hll"><span class="s2">         </span><span class="k">$(</span>python_gen_any_dep <span class="s1">&#39;</span>
</span><span class="hll"><span class="s1">             dev-python/pexpect[${PYTHON_USEDEP}]</span>
</span><span class="hll"><span class="s1">             dev-python/pytest[${PYTHON_USEDEP}]</span>
</span><span class="hll"><span class="s1">         &#39;</span><span class="k">)</span><span class="s2"></span>
</span><span class="hll"><span class="s2">     )&quot;</span>
</span>
 python_check_deps<span class="o">()</span> <span class="o">{</span>
     python_has_version -d <span class="s2">&quot;dev-python/pexpect[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span> <span class="o">&amp;&amp;</span>
     python_has_version -d <span class="s2">&quot;dev-python/pytest[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span>
 <span class="o">}</span>

 pkg_setup<span class="o">()</span> <span class="o">{</span>
<span class="hll">     use <span class="nb">test</span> <span class="o">&amp;&amp;</span> python-any-r1_pkg_setup
</span> <span class="o">}</span>
</pre></div>
</div>
</section>
<section id="additional-conditional-dependencies">
<h2>Additional conditional dependencies<a class="headerlink" href="#additional-conditional-dependencies" title="Permalink to this heading"></a></h2>
<p>Another possible case is that Python is required unconditionally
but some dependencies are required only conditionally to USE flags.
The simplest way to achieve that is to use <code class="docutils literal notranslate"><span class="pre">${PYTHON_DEPS}</span></code> globally
and <code class="docutils literal notranslate"><span class="pre">python_gen_any_dep</span></code> in USE-conditional block, then express
a similar condition in <code class="docutils literal notranslate"><span class="pre">python_check_deps()</span></code>:</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> python3_<span class="o">{</span><span class="m">6</span>,7<span class="o">}</span> <span class="o">)</span>
 inherit python-any-r1 cmake

 <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;Qt bindings for the Telepathy D-Bus protocol&quot;</span>
 <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://telepathy.freedesktop.org/&quot;</span>
 <span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://telepathy.freedesktop.org/releases/</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">.tar.gz&quot;</span>

 <span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;LGPL-2.1&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 ~arm arm64 x86&quot;</span>
<span class="hll"> <span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;test&quot;</span>
</span> <span class="nv">RESTRICT</span><span class="o">=</span><span class="s2">&quot;!test? ( test )&quot;</span>

<span class="hll"> <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"></span>
</span><span class="hll"><span class="s2">     test? (</span>
</span><span class="hll"><span class="s2">         </span><span class="k">$(</span>python_gen_any_dep <span class="s1">&#39;</span>
</span><span class="hll"><span class="s1">             dev-python/dbus-python[${PYTHON_USEDEP}]</span>
</span><span class="hll"><span class="s1">         &#39;</span><span class="k">)</span><span class="s2"></span>
</span><span class="hll"><span class="s2">     )</span>
</span><span class="s2"> &quot;</span>

<span class="hll"> python_check_deps<span class="o">()</span> <span class="o">{</span>
</span><span class="hll">     use <span class="nb">test</span> <span class="o">||</span> <span class="k">return</span> <span class="m">0</span>
</span><span class="hll">     python_has_version -b <span class="s2">&quot;dev-python/dbus-python[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span>
</span><span class="hll"> <span class="o">}</span>
</span></pre></div>
</div>
</section>
<section id="multiple-sets-of-conditional-dependencies">
<h2>Multiple sets of conditional dependencies<a class="headerlink" href="#multiple-sets-of-conditional-dependencies" title="Permalink to this heading"></a></h2>
<p>The hardest case for this eclass is to declare multiple Python
dependencies conditional to different USE flags.  While there are
multiple possible ways of doing that, the least error-prone is to move
USE conditional blocks inside <code class="docutils literal notranslate"><span class="pre">python_gen_any_dep</span></code>:</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> python3_6 <span class="o">)</span>

 inherit gnome2 python-any-r1

 <span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;GObject library for accessing the freedesktop.org Secret Service API&quot;</span>
 <span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://wiki.gnome.org/Projects/Libsecret&quot;</span>

 <span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;LGPL-2.1+ Apache-2.0&quot;</span> <span class="c1"># Apache-2.0 license is used for tests only</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 arm arm64 ia64 ~mips ppc ppc64 sparc x86&quot;</span>
<span class="hll"> <span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;+introspection test&quot;</span>
</span> <span class="nv">RESTRICT</span><span class="o">=</span><span class="s2">&quot;!test? ( test )&quot;</span>
 <span class="c1"># Tests fail with USE=-introspection, https://bugs.gentoo.org/655482</span>
 <span class="nv">REQUIRED_USE</span><span class="o">=</span><span class="s2">&quot;test? ( introspection )&quot;</span>

 <span class="nv">DEPEND</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="hll"><span class="s2">     test? (</span>
</span><span class="hll"><span class="s2">         </span><span class="k">$(</span>python_gen_any_dep <span class="s1">&#39;</span>
</span><span class="hll"><span class="s1">             dev-python/mock[${PYTHON_USEDEP}]</span>
</span><span class="hll"><span class="s1">             dev-python/dbus-python[${PYTHON_USEDEP}]</span>
</span><span class="hll"><span class="s1">             introspection? ( dev-python/pygobject:3[${PYTHON_USEDEP}] )</span>
</span><span class="hll"><span class="s1">         &#39;</span><span class="k">)</span><span class="s2"></span>
</span><span class="hll"><span class="s2">     )</span>
</span><span class="s2"> &quot;</span>

<span class="hll"> python_check_deps<span class="o">()</span> <span class="o">{</span>
</span><span class="hll">     <span class="k">if</span> use introspection<span class="p">;</span> <span class="k">then</span>
</span><span class="hll">         python_has_version <span class="s2">&quot;dev-python/pygobject:3[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span> <span class="o">||</span> <span class="k">return</span> <span class="m">1</span>
</span><span class="hll">     <span class="k">fi</span>
</span><span class="hll">     python_has_version <span class="s2">&quot;dev-python/mock[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span> <span class="o">&amp;&amp;</span>
</span><span class="hll">     python_has_version --host-root <span class="s2">&quot;dev-python/dbus-python[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span>
</span><span class="hll"> <span class="o">}</span>
</span>
 pkg_setup<span class="o">()</span> <span class="o">{</span>
<span class="hll">     use <span class="nb">test</span> <span class="o">&amp;&amp;</span> python-any-r1_pkg_setup
</span> <span class="o">}</span>
</pre></div>
</div>
</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 current"><a class="current reference internal" href="#">python-any-r1 — build-time dependency</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#basic-use-for-unconditional-python">Basic use for unconditional Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="#dependencies">Dependencies</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-conditional-dependencies">Additional conditional dependencies</a></li>
<li class="toctree-l2"><a class="reference internal" href="#multiple-sets-of-conditional-dependencies">Multiple sets of conditional dependencies</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="single.html">python-single-r1 — single-impl packages</a></li>
<li class="toctree-l1"><a class="reference internal" href="multi.html">python-r1 — multi-impl packages</a></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="basic.html" title="previous chapter">Common basics</a></li>
      <li>Next: <a href="single.html" title="next chapter">python-single-r1 — single-impl packages</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/any.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>