summaryrefslogtreecommitdiff
blob: 34b740149af8cdf07ad328e702f9087e16431295 (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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>Integration with build systems written in Python &#8212; Gentoo Python Guide  documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=b3523f8e" />
    <link rel="stylesheet" type="text/css" href="_static/alabaster.css?v=039e1c02" />
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js?v=b3ba4146"></script>
    <script src="_static/doctools.js?v=888ff710"></script>
    <script src="_static/sphinx_highlight.js?v=4825356b"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Porting tips" href="porting.html" />
    <link rel="prev" title="Expert python-r1 usage" href="expert-multi.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="integration-with-build-systems-written-in-python">
<h1>Integration with build systems written in Python<a class="headerlink" href="#integration-with-build-systems-written-in-python" title="Permalink to this heading"></a></h1>
<p>Besides the build systems commonly used by Python packages there are
a few build systems written in Python and requiring the packages
to script them in Python.  This makes it necessary to use a proper
Python eclass in order to declare their compatibility with Python
versions.</p>
<section id="meson">
<h2>Meson<a class="headerlink" href="#meson" title="Permalink to this heading"></a></h2>
<p><a class="reference external" href="https://mesonbuild.com/">Meson</a> build system is a fairly recent addition.  While it is written
in Python, its scripts use a custom Python-agnostic script language.
Hence, it can be treated as an arbitrary external tool and does not need
any Python eclass.</p>
</section>
<section id="scons">
<h2>SCons<a class="headerlink" href="#scons" title="Permalink to this heading"></a></h2>
<p><a class="reference external" href="https://scons.org/">SCons</a> has gained Python 3 support quite recently.  At the same time,
many old script files were written for Python 2 and fail when run
via Python 3 SCons.  For this reason, it is necessary to use Python
eclass when using SCons.</p>
<p>In the simplest case when the package has no other use for Python,
it is sufficient to declare <code class="docutils literal notranslate"><span class="pre">PYTHON_COMPAT</span></code> for the SCons scripts
in the package, and inherit <code class="docutils literal notranslate"><span class="pre">python-any-r1</span></code> prior to <code class="docutils literal notranslate"><span class="pre">scons-utils</span></code>
(this happens naturally when you sort includes by eclass name).
The latter eclass takes care of setting as much as possible.</p>
<p>If the package has other Python components, it is necessary to account
for them and use an appropriate eclass as detailed in the eclass choice
chapter.</p>
<section id="build-time-use-with-no-extra-dependencies">
<h3>Build-time use with no extra dependencies<a class="headerlink" href="#build-time-use-with-no-extra-dependencies" title="Permalink to this heading"></a></h3>
<p>If the package either has no other Python components than SCons, or all
of them are purely build-time and have no dependencies, it is sufficient
to inherit <code class="docutils literal notranslate"><span class="pre">python-any-r1</span></code>.  The eclass takes care of setting
<code class="docutils literal notranslate"><span class="pre">BDEPEND</span></code> along with matching <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="w"> </span><span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
<span class="w"> </span><span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

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

<span class="hll"><span class="w"> </span><span class="nv">PYTHON_COMPAT</span><span class="o">=(</span><span class="w"> </span>python3_<span class="o">{</span><span class="m">6</span>,7<span class="o">}</span><span class="w"> </span><span class="o">)</span>
</span><span class="hll"><span class="w"> </span>inherit<span class="w"> </span>python-any-r1<span class="w"> </span>scons-utils<span class="w"> </span>toolchain-funcs
</span>
<span class="w"> </span><span class="nv">COMMIT</span><span class="o">=</span><span class="s2">&quot;6e5e8a57628095d8d0c8bbb38187afb0f3a42112&quot;</span>
<span class="w"> </span><span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;Userspace Xbox 360 Controller driver&quot;</span>
<span class="w"> </span><span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://xboxdrv.gitlab.io&quot;</span>
<span class="w"> </span><span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://github.com/chewi/xboxdrv/archive/</span><span class="si">${</span><span class="nv">COMMIT</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="w"> </span><span class="nv">S</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">WORKDIR</span><span class="si">}</span><span class="s2">/</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">COMMIT</span><span class="si">}</span><span class="s2">&quot;</span>

<span class="w"> </span><span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;GPL-3&quot;</span>
<span class="w"> </span><span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
<span class="w"> </span><span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;~amd64 ~x86&quot;</span>

<span class="w"> </span><span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="s2">     dev-libs/boost:=</span>
<span class="s2">     dev-libs/dbus-glib</span>
<span class="s2">     dev-libs/glib:2</span>
<span class="s2">     sys-apps/dbus</span>
<span class="s2">     virtual/libudev:=</span>
<span class="s2">     virtual/libusb:1</span>
<span class="s2">     x11-libs/libX11</span>
<span class="s2"> &quot;</span>

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

<span class="w"> </span><span class="nv">BDEPEND</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="s2">     dev-util/glib-utils</span>
<span class="s2">     virtual/pkgconfig</span>
<span class="s2"> &quot;</span>

<span class="w"> </span>src_compile<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>escons<span class="w"> </span><span class="se">\</span>
<span class="w">         </span><span class="nv">BUILD</span><span class="o">=</span>custom<span class="w"> </span><span class="se">\</span>
<span class="w">         </span><span class="nv">CXX</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>tc-getCXX<span class="k">)</span><span class="s2">&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">         </span><span class="nv">AR</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>tc-getAR<span class="k">)</span><span class="s2">&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">         </span><span class="nv">RANLIB</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>tc-getRANLIB<span class="k">)</span><span class="s2">&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">         </span><span class="nv">CXXFLAGS</span><span class="o">=</span><span class="s2">&quot;-Wall </span><span class="si">${</span><span class="nv">CXXFLAGS</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span><span class="se">\</span>
<span class="w">         </span><span class="nv">LINKFLAGS</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">LDFLAGS</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_install<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>dobin<span class="w"> </span>xboxdrv
<span class="w">     </span>doman<span class="w"> </span>doc/xboxdrv.1
<span class="w">     </span>dodoc<span class="w"> </span>AUTHORS<span class="w"> </span>NEWS<span class="w"> </span>PROTOCOL<span class="w"> </span>README.md<span class="w"> </span>TODO
<span class="w"> </span><span class="o">}</span>
</pre></div>
</div>
</section>
<section id="build-time-use-with-extra-dependencies">
<h3>Build-time use with extra dependencies<a class="headerlink" href="#build-time-use-with-extra-dependencies" title="Permalink to this heading"></a></h3>
<p>If the package has extra dependencies, you need to take care of <em>all</em>
dependencies yourself.  This is because <code class="docutils literal notranslate"><span class="pre">python_gen_any_dep</span></code> cannot
be combined.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="w"> </span><span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
<span class="w"> </span><span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

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

<span class="hll"><span class="w"> </span><span class="nv">PYTHON_COMPAT</span><span class="o">=(</span><span class="w"> </span>python3_<span class="o">{</span><span class="m">6</span>,7<span class="o">}</span><span class="w"> </span><span class="o">)</span>
</span><span class="hll"><span class="w"> </span>inherit<span class="w"> </span>python-any-r1<span class="w"> </span>scons-utils<span class="w"> </span>toolchain-funcs
</span>
<span class="w"> </span><span class="nv">MY_P</span><span class="o">=</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span>-src-r<span class="si">${</span><span class="nv">PV</span><span class="p">/_rc/-rc</span><span class="si">}</span>
<span class="w"> </span><span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;A high-performance, open source, schema-free document-oriented database&quot;</span>
<span class="w"> </span><span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://www.mongodb.com&quot;</span>
<span class="w"> </span><span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://fastdl.mongodb.org/src/</span><span class="si">${</span><span class="nv">MY_P</span><span class="si">}</span><span class="s2">.tar.gz&quot;</span>
<span class="w"> </span><span class="nv">S</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">WORKDIR</span><span class="si">}</span><span class="s2">/</span><span class="si">${</span><span class="nv">MY_P</span><span class="si">}</span><span class="s2">&quot;</span>

<span class="w"> </span><span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;Apache-2.0 SSPL-1&quot;</span>
<span class="w"> </span><span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
<span class="w"> </span><span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;~amd64&quot;</span>
<span class="w"> </span><span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;test +tools&quot;</span>
<span class="w"> </span><span class="nv">RESTRICT</span><span class="o">=</span><span class="s2">&quot;!test? ( test )&quot;</span>

<span class="w"> </span><span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;acct-group/mongodb</span>
<span class="s2">     acct-user/mongodb</span>
<span class="s2">     &gt;=app-arch/snappy-1.1.3</span>
<span class="s2">     &gt;=dev-cpp/yaml-cpp-0.6.2:=</span>
<span class="s2">     &gt;=dev-libs/boost-1.70:=[threads(+)]</span>
<span class="s2">     &gt;=dev-libs/libpcre-8.42[cxx]</span>
<span class="s2">     app-arch/zstd</span>
<span class="s2">     dev-libs/snowball-stemmer</span>
<span class="s2">     net-libs/libpcap</span>
<span class="s2">     &gt;=sys-libs/zlib-1.2.11:=&quot;</span>
<span class="w"> </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="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span>
<span class="s2">     </span><span class="k">$(</span>python_gen_any_dep<span class="w"> </span><span class="s1">&#39;</span>
<span class="s1">         test? ( dev-python/pymongo[${PYTHON_USEDEP}] )</span>
<span class="hll"><span class="s1">         &gt;=dev-util/scons-2.5.0[${PYTHON_USEDEP}]</span>
</span><span class="s1">         dev-python/cheetah3[${PYTHON_USEDEP}]</span>
<span class="s1">         dev-python/psutil[${PYTHON_USEDEP}]</span>
<span class="s1">         dev-python/pyyaml[${PYTHON_USEDEP}]</span>
<span class="s1">         virtual/python-typing[${PYTHON_USEDEP}]</span>
<span class="s1">     &#39;</span><span class="k">)</span>
<span class="s2">     sys-libs/ncurses:0=</span>
<span class="s2">     sys-libs/readline:0=&quot;</span>
<span class="w"> </span><span class="nv">PDEPEND</span><span class="o">=</span><span class="s2">&quot;tools? ( &gt;=app-admin/mongo-tools-</span><span class="si">${</span><span class="nv">PV</span><span class="si">}</span><span class="s2"> )&quot;</span>

<span class="w"> </span>python_check_deps<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span><span class="k">if</span><span class="w"> </span>use<span class="w"> </span>test<span class="p">;</span><span class="w"> </span><span class="k">then</span>
<span class="w">         </span>python_has_version<span class="w"> </span><span class="s2">&quot;dev-python/pymongo[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span><span class="w"> </span><span class="o">||</span>
<span class="w">             </span><span class="k">return</span><span class="w"> </span><span class="m">1</span>
<span class="w">     </span><span class="k">fi</span>

<span class="hll"><span class="w">     </span>python_has_version<span class="w"> </span><span class="s2">&quot;&gt;=dev-util/scons-2.5.0[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span><span class="w"> </span><span class="o">&amp;&amp;</span>
</span><span class="w">     </span>python_has_version<span class="w"> </span><span class="s2">&quot;dev-python/cheetah3[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span><span class="w"> </span><span class="o">&amp;&amp;</span>
<span class="w">     </span>python_has_version<span class="w"> </span><span class="s2">&quot;dev-python/psutil[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span><span class="w"> </span><span class="o">&amp;&amp;</span>
<span class="w">     </span>python_has_version<span class="w"> </span><span class="s2">&quot;dev-python/pyyaml[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span><span class="w"> </span><span class="o">&amp;&amp;</span>
<span class="w">     </span>python_has_version<span class="w"> </span><span class="s2">&quot;virtual/python-typing[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span>
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_configure<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span><span class="nv">scons_opts</span><span class="o">=(</span>
<span class="w">         </span><span class="nv">CC</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>tc-getCC<span class="k">)</span><span class="s2">&quot;</span>
<span class="w">         </span><span class="nv">CXX</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>tc-getCXX<span class="k">)</span><span class="s2">&quot;</span>

<span class="w">         </span>--disable-warnings-as-errors
<span class="w">         </span>--use-system-boost
<span class="w">         </span>--use-system-pcre
<span class="w">         </span>--use-system-snappy
<span class="w">         </span>--use-system-stemmer
<span class="w">         </span>--use-system-yaml
<span class="w">         </span>--use-system-zlib
<span class="w">         </span>--use-system-zstd
<span class="w">     </span><span class="o">)</span>

<span class="w">     </span>default
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_compile<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>escons<span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">scons_opts</span><span class="p">[@]</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span>core<span class="w"> </span>tools
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_test<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">EPYTHON</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span>./buildscripts/resmoke.py<span class="w"> </span>--dbpathPrefix<span class="o">=</span><span class="nb">test</span><span class="w"> </span><span class="se">\</span>
<span class="w">         </span>--suites<span class="w"> </span>core<span class="w"> </span>--jobs<span class="o">=</span><span class="k">$(</span>makeopts_jobs<span class="k">)</span><span class="w"> </span><span class="o">||</span><span class="w"> </span>die<span class="w"> </span><span class="s2">&quot;Tests failed&quot;</span>
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_install<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>escons<span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">scons_opts</span><span class="p">[@]</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span>--nostrip<span class="w"> </span>install<span class="w"> </span>--prefix<span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">ED</span><span class="si">}</span><span class="s2">&quot;</span>/usr
<span class="w"> </span><span class="o">}</span>
</pre></div>
</div>
</section>
<section id="single-impl-package">
<h3>Single-impl package<a class="headerlink" href="#single-impl-package" title="Permalink to this heading"></a></h3>
<p>If the package needs to install some Python components, and single-impl
install is appropriate, you need to combine <code class="docutils literal notranslate"><span class="pre">python-single-r1</span></code>
with <code class="docutils literal notranslate"><span class="pre">scons-utils</span></code>.  In this case, the eclass takes care of everything
needed for SCons, and you take care of everything needed for your
package.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="w"> </span><span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
<span class="w"> </span><span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

<span class="w"> </span><span class="nv">EAPI</span><span class="o">=</span><span class="m">5</span>

<span class="hll"><span class="w"> </span><span class="nv">PYTHON_COMPAT</span><span class="o">=(</span><span class="w"> </span>python2_7<span class="w"> </span><span class="o">)</span>
</span><span class="hll"><span class="w"> </span>inherit<span class="w"> </span>eutils<span class="w"> </span>python-single-r1<span class="w"> </span>scons-utils<span class="w"> </span>toolchain-funcs
</span>
<span class="w"> </span><span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;Molecular dynamics by NMR data analysis&quot;</span>
<span class="w"> </span><span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://www.nmr-relax.com/&quot;</span>
<span class="w"> </span><span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;http://download.gna.org/relax/</span><span class="si">${</span><span class="nv">P</span><span class="si">}</span><span class="s2">.src.tar.bz2&quot;</span>

<span class="w"> </span><span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
<span class="w"> </span><span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;GPL-2&quot;</span>
<span class="w"> </span><span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;~amd64 ~x86 ~amd64-linux ~x86-linux&quot;</span>
<span class="w"> </span><span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;test&quot;</span>
<span class="w"> </span><span class="nv">RESTRICT</span><span class="o">=</span><span class="s2">&quot;!test? ( test )&quot;</span>
<span class="hll"><span class="w"> </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="w"> </span><span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="s2">     </span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span>
<span class="s2">     </span><span class="k">$(</span>python_gen_cond_dep<span class="w"> </span><span class="s2">&quot;</span>
<span class="s2">         dev-python/Numdifftools[\${PYTHON_USEDEP}]</span>
<span class="s2">         || (</span>
<span class="s2">             dev-python/matplotlib-python2[\${PYTHON_USEDEP}]</span>
<span class="s2">             dev-python/matplotlib[\${PYTHON_USEDEP}]</span>
<span class="s2">         )</span>
<span class="s2">         || (</span>
<span class="s2">             dev-python/numpy-python2[\${PYTHON_USEDEP}]</span>
<span class="s2">             dev-python/numpy[\${PYTHON_USEDEP}]</span>
<span class="s2">         )</span>
<span class="s2">         dev-python/wxpython:</span><span class="si">${</span><span class="nv">WX_GTK_VER</span><span class="si">}</span><span class="s2">[\${PYTHON_USEDEP}]</span>
<span class="s2">         sci-chemistry/pymol[\${PYTHON_USEDEP}]</span>
<span class="s2">         &gt;=sci-libs/bmrblib-1.0.3[\${PYTHON_USEDEP}]</span>
<span class="s2">         &gt;=sci-libs/minfx-1.0.11[\${PYTHON_USEDEP}]</span>
<span class="s2">         || (</span>
<span class="s2">             sci-libs/scipy-python2[\${PYTHON_USEDEP}]</span>
<span class="s2">             sci-libs/scipy[\${PYTHON_USEDEP}]</span>
<span class="s2">         )</span>
<span class="s2">     &quot;</span><span class="k">)</span>
<span class="s2">     sci-chemistry/molmol</span>
<span class="s2">     sci-chemistry/vmd</span>
<span class="s2">     sci-visualization/grace</span>
<span class="s2">     sci-visualization/opendx&quot;</span>
<span class="w"> </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">     media-gfx/pngcrush</span>
<span class="s2">     test? ( </span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span><span class="s2"> )</span>
<span class="s2">     &quot;</span>

<span class="w"> </span>src_compile<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>tc-export<span class="w"> </span>CC
<span class="w">     </span>escons
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_install<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>python_moduleinto<span class="w"> </span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span>
<span class="w">     </span>python_domodule<span class="w"> </span>*

<span class="w">     </span>make_wrapper<span class="w"> </span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span>-nmr<span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">EPYTHON</span><span class="si">}</span><span class="s2"> </span><span class="k">$(</span>python_get_sitedir<span class="k">)</span><span class="s2">/</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">PN</span><span class="si">}</span><span class="s2">.py </span><span class="nv">$@</span><span class="s2">&quot;</span>
<span class="w"> </span><span class="o">}</span>
</pre></div>
</div>
</section>
<section id="single-impl-package-with-conditional-python-install">
<h3>Single-impl package with conditional Python install<a class="headerlink" href="#single-impl-package-with-conditional-python-install" title="Permalink to this heading"></a></h3>
<p>If the runtime part of the package uses Python only conditionally,
the use is similar to a package with unconditional build-time
and conditional runtime dependency on Python.  That is, build-time
dependencies, <code class="docutils literal notranslate"><span class="pre">REQUIRED_USE</span></code> and <code class="docutils literal notranslate"><span class="pre">pkg_setup</span></code> must be called
unconditionally.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="w"> </span><span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
<span class="w"> </span><span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

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

<span class="hll"><span class="w"> </span><span class="nv">PYTHON_COMPAT</span><span class="o">=(</span><span class="w"> </span>python3_<span class="o">{</span><span class="m">6</span>,7,8<span class="o">}</span><span class="w"> </span><span class="o">)</span>
</span>
<span class="w"> </span><span class="nv">FORTRAN_NEEDED</span><span class="o">=</span>fortran
<span class="w"> </span><span class="nv">FORTRAN_STANDARD</span><span class="o">=</span><span class="m">90</span>

<span class="hll"><span class="w"> </span>inherit<span class="w"> </span>python-single-r1<span class="w"> </span>scons-utils<span class="w"> </span>toolchain-funcs
</span>
<span class="w"> </span><span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;Object-oriented tool suite for chemical kinetics, thermodynamics, and transport&quot;</span>
<span class="w"> </span><span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://www.cantera.org&quot;</span>
<span class="w"> </span><span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://github.com/Cantera/</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">/archive/v</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="w"> </span><span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;BSD&quot;</span>
<span class="w"> </span><span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
<span class="w"> </span><span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;amd64 ~x86&quot;</span>
<span class="w"> </span><span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;fortran pch +python&quot;</span>

<span class="w"> </span><span class="nv">REQUIRED_USE</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_REQUIRED_USE</span><span class="si">}</span>
</span><span class="s2">     &quot;</span>

<span class="w"> </span><span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="s2">     python? (</span>
<span class="s2">         </span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span>
<span class="s2">         </span><span class="k">$(</span>python_gen_cond_dep<span class="w"> </span><span class="s1">&#39;</span>
<span class="s1">             dev-python/numpy[${PYTHON_USEDEP}]</span>
<span class="s1">         &#39;</span><span class="k">)</span>
<span class="s2">     )</span>
<span class="s2">     &lt;sci-libs/sundials-5.1.0:0=</span>
<span class="s2"> &quot;</span>

<span class="w"> </span><span class="nv">DEPEND</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="s2">     </span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span>
<span class="s2">     dev-cpp/eigen:3</span>
<span class="s2">     dev-libs/boost</span>
<span class="s2">     dev-libs/libfmt</span>
<span class="s2">     python? (</span>
<span class="s2">         </span><span class="k">$(</span>python_gen_cond_dep<span class="w"> </span><span class="s1">&#39;</span>
<span class="s1">             dev-python/cython[${PYTHON_USEDEP}]</span>
<span class="s1">         &#39;</span><span class="k">)</span>
<span class="s2">     )</span>
<span class="s2"> &quot;</span>

<span class="w"> </span>pkg_setup<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>fortran-2_pkg_setup
<span class="hll"><span class="w">     </span>python-single-r1_pkg_setup
</span><span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_configure<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span><span class="nv">scons_vars</span><span class="o">=(</span>
<span class="w">         </span><span class="nv">CC</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>tc-getCC<span class="k">)</span><span class="s2">&quot;</span>
<span class="w">         </span><span class="nv">CXX</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>tc-getCXX<span class="k">)</span><span class="s2">&quot;</span>
<span class="w">         </span><span class="nv">cc_flags</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">CXXFLAGS</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="w">         </span><span class="nv">cxx_flags</span><span class="o">=</span><span class="s2">&quot;-std=c++11&quot;</span>
<span class="w">         </span><span class="nv">debug</span><span class="o">=</span><span class="s2">&quot;no&quot;</span>
<span class="w">         </span><span class="nv">FORTRAN</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>tc-getFC<span class="k">)</span><span class="s2">&quot;</span>
<span class="w">         </span><span class="nv">FORTRANFLAGS</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">CXXFLAGS</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="w">         </span><span class="nv">optimize_flags</span><span class="o">=</span><span class="s2">&quot;-Wno-inline&quot;</span>
<span class="w">         </span><span class="nv">renamed_shared_libraries</span><span class="o">=</span><span class="s2">&quot;no&quot;</span>
<span class="w">         </span><span class="nv">use_pch</span><span class="o">=</span><span class="k">$(</span>usex<span class="w"> </span>pch<span class="k">)</span>
<span class="w">         </span><span class="nv">system_fmt</span><span class="o">=</span><span class="s2">&quot;y&quot;</span>
<span class="w">         </span><span class="nv">system_sundials</span><span class="o">=</span><span class="s2">&quot;y&quot;</span>
<span class="w">         </span><span class="nv">system_eigen</span><span class="o">=</span><span class="s2">&quot;y&quot;</span>
<span class="w">         </span><span class="nv">env_vars</span><span class="o">=</span><span class="s2">&quot;all&quot;</span>
<span class="w">         </span><span class="nv">extra_inc_dirs</span><span class="o">=</span><span class="s2">&quot;/usr/include/eigen3&quot;</span>
<span class="w">     </span><span class="o">)</span>

<span class="w">     </span><span class="nv">scons_targets</span><span class="o">=(</span>
<span class="w">         </span><span class="nv">f90_interface</span><span class="o">=</span><span class="k">$(</span>usex<span class="w"> </span>fortran<span class="w"> </span>y<span class="w"> </span>n<span class="k">)</span>
<span class="w">         </span><span class="nv">python2_package</span><span class="o">=</span><span class="s2">&quot;none&quot;</span>
<span class="w">     </span><span class="o">)</span>

<span class="w">     </span><span class="k">if</span><span class="w"> </span>use<span class="w"> </span>python<span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="k">then</span>
<span class="w">         </span><span class="nv">scons_targets</span><span class="o">+=(</span><span class="w"> </span><span class="nv">python3_package</span><span class="o">=</span><span class="s2">&quot;full&quot;</span><span class="w"> </span><span class="nv">python3_cmd</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">EPYTHON</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span><span class="o">)</span>
<span class="w">     </span><span class="k">else</span>
<span class="w">         </span><span class="nv">scons_targets</span><span class="o">+=(</span><span class="w"> </span><span class="nv">python3_package</span><span class="o">=</span><span class="s2">&quot;none&quot;</span><span class="w"> </span><span class="o">)</span>
<span class="w">     </span><span class="k">fi</span>
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_compile<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>escons<span class="w"> </span>build<span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">scons_vars</span><span class="p">[@]</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">scons_targets</span><span class="p">[@]</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span><span class="nv">prefix</span><span class="o">=</span><span class="s2">&quot;/usr&quot;</span>
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_test<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>escons<span class="w"> </span><span class="nb">test</span>
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_install<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>escons<span class="w"> </span>install<span class="w"> </span><span class="nv">stage_dir</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">D</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span><span class="nv">libdirname</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>get_libdir<span class="k">)</span><span class="s2">&quot;</span>
<span class="w">     </span>python_optimize
<span class="w"> </span><span class="o">}</span>
</pre></div>
</div>
</section>
<section id="pure-python-multi-impl-package">
<h3>Pure Python multi-impl package<a class="headerlink" href="#pure-python-multi-impl-package" title="Permalink to this heading"></a></h3>
<p>When you are dealing with a pure Python package using SCons, it makes
sense to use plain <code class="docutils literal notranslate"><span class="pre">python-r1</span></code> API.  This means that SCons is going
to be called from a <code class="docutils literal notranslate"><span class="pre">python_foreach_impl</span></code> loop only.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="w"> </span><span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
<span class="w"> </span><span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

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

<span class="hll"><span class="w"> </span><span class="nv">PYTHON_COMPAT</span><span class="o">=(</span><span class="w"> </span>python2_7<span class="w"> </span><span class="o">)</span>
</span><span class="hll"><span class="w"> </span>inherit<span class="w"> </span>fortran-2<span class="w"> </span>python-r1<span class="w"> </span>scons-utils<span class="w"> </span>toolchain-funcs
</span>
<span class="w"> </span><span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;Automated pipeline for performing Poisson-Boltzmann electrostatics calculations&quot;</span>
<span class="w"> </span><span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://www.poissonboltzmann.org/&quot;</span>
<span class="w"> </span><span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://github.com/Electrostatics/apbs-</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">/releases/download/</span><span class="si">${</span><span class="nv">P</span><span class="si">}</span><span class="s2">/</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">-src-</span><span class="si">${</span><span class="nv">PV</span><span class="si">}</span><span class="s2">.tar.gz&quot;</span>

<span class="w"> </span><span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
<span class="w"> </span><span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;BSD&quot;</span>
<span class="w"> </span><span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;amd64 x86 ~amd64-linux ~x86-linux&quot;</span>
<span class="w"> </span><span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;opal&quot;</span>
<span class="hll"><span class="w"> </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="w"> </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">         dev-python/numpy-python2[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]</span>
<span class="s2">         dev-python/numpy[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]</span>
<span class="s2">     )</span>
<span class="s2">     sci-chemistry/openbabel-python[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]</span>
<span class="s2">     opal? ( dev-python/zsi[</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="w"> </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">     dev-lang/swig:0</span>
<span class="hll"><span class="s2">     dev-util/scons[</span><span class="si">${</span><span class="nv">PYTHON_USEDEP</span><span class="si">}</span><span class="s2">]&quot;</span>
</span>
<span class="w"> </span>src_prepare<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>find<span class="w"> </span>-type<span class="w"> </span>f<span class="w"> </span><span class="se">\(</span><span class="w"> </span>-name<span class="w"> </span><span class="s2">&quot;*.pyc&quot;</span><span class="w"> </span>-o<span class="w"> </span>-name<span class="w"> </span><span class="s2">&quot;*.pyo&quot;</span><span class="w"> </span><span class="se">\)</span><span class="w"> </span>-delete<span class="w"> </span><span class="o">||</span><span class="w"> </span>die

<span class="w">     </span>eapply<span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PATCHES</span><span class="p">[@]</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="w">     </span>eapply_user
<span class="w">     </span>rm<span class="w"> </span>-rf<span class="w"> </span>scons<span class="w"> </span><span class="o">||</span><span class="w"> </span>die

<span class="w">     </span>python_copy_sources
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>python_configure<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>tc-export<span class="w"> </span>CXX
<span class="w">     </span>cat<span class="w"> </span>&gt;<span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">BUILD_DIR</span><span class="si">}</span><span class="s2">&quot;</span>/build_config.py<span class="w"> </span><span class="s">&lt;&lt;-EOF || die</span>
<span class="s">         PREFIX=&quot;${D}/$(python_get_sitedir)/${PN}&quot;</span>
<span class="s">         APBS=&quot;${EPREFIX}/usr/bin/apbs&quot;</span>
<span class="s">         MAX_ATOMS=10000</span>
<span class="s">         BUILD_PDB2PKA=False</span>
<span class="s">         REBUILD_SWIG=True</span>
<span class="s">     EOF</span>
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_configure<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>python_foreach_impl<span class="w"> </span>python_configure
<span class="w"> </span><span class="o">}</span>

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

<span class="w"> </span>python_install<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span><span class="nb">cd</span><span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">BUILD_DIR</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span><span class="o">||</span><span class="w"> </span>die
<span class="hll"><span class="w">     </span>escons<span class="w"> </span>install
</span><span class="w">     </span>python_optimize
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_install<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span>python_foreach_impl<span class="w"> </span>python_install
<span class="w"> </span><span class="o">}</span>
</pre></div>
</div>
</section>
<section id="hybrid-python-r1-scons-package">
<h3>Hybrid python-r1 + SCons package<a class="headerlink" href="#hybrid-python-r1-scons-package" title="Permalink to this heading"></a></h3>
<p>Finally, let’s consider a package that uses SCons as a build system
and installs Python components independently of it.  This could be
e.g. a C/C++ program with separate Python bindings.</p>
<p>Let’s presume that the Python bindings need to be installed manually,
and they support a wider target range than the build system.  In this
case, the any-r1 API is recommended.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="w"> </span><span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
<span class="w"> </span><span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

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

<span class="w"> </span><span class="nv">PYTHON_COMPAT</span><span class="o">=(</span><span class="w"> </span>python2_7<span class="w"> </span>python3_6<span class="w"> </span><span class="o">)</span>
<span class="w"> </span>inherit<span class="w"> </span>python-r1<span class="w"> </span>scons-utils<span class="w"> </span>toolchain-funcs

<span class="w"> </span><span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;GPS daemon and library for USB/serial GPS devices and GPS/mapping clients&quot;</span>
<span class="w"> </span><span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://gpsd.gitlab.io/gpsd/&quot;</span>
<span class="w"> </span><span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;mirror://nongnu/</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="w"> </span><span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;BSD&quot;</span>
<span class="w"> </span><span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0/24&quot;</span>
<span class="w"> </span><span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;~amd64 ~arm ~ppc ~ppc64 ~sparc ~x86&quot;</span>

<span class="w"> </span><span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;python&quot;</span>
<span class="w"> </span><span class="nv">REQUIRED_USE</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="s2">     python? ( </span><span class="si">${</span><span class="nv">PYTHON_REQUIRED_USE</span><span class="si">}</span><span class="s2"> )&quot;</span>

<span class="w"> </span><span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="s2">     &gt;=net-misc/pps-tools-0.0.20120407</span>
<span class="s2">     python? ( </span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span><span class="s2"> )&quot;</span>
<span class="w"> </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="hll"><span class="s2">     </span><span class="k">$(</span>python_gen_any_dep<span class="w"> </span><span class="s1">&#39;&gt;=dev-util/scons-2.3.0[${PYTHON_USEDEP}]&#39;</span><span class="w"> </span>-2<span class="k">)</span>
</span><span class="s2">     virtual/pkgconfig&quot;</span>

<span class="hll"><span class="w"> </span>python_check_deps<span class="o">()</span><span class="w"> </span><span class="o">{</span>
</span><span class="hll"><span class="w">     </span>python_has_version<span class="w"> </span><span class="s2">&quot;&gt;=dev-util/scons-2.3.0[</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="w"> </span><span class="o">}</span>
</span>
<span class="w"> </span>src_configure<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span><span class="nv">myesconsargs</span><span class="o">=(</span>
<span class="w">         </span><span class="nv">prefix</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">EPREFIX</span><span class="si">}</span><span class="s2">/usr&quot;</span>
<span class="w">         </span><span class="nv">libdir</span><span class="o">=</span><span class="s2">&quot;\$prefix/</span><span class="k">$(</span>get_libdir<span class="k">)</span><span class="s2">&quot;</span>
<span class="w">         </span><span class="nv">udevdir</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>get_udevdir<span class="k">)</span><span class="s2">&quot;</span>
<span class="w">         </span><span class="nv">chrpath</span><span class="o">=</span>False
<span class="w">         </span><span class="nv">gpsd_user</span><span class="o">=</span>gpsd
<span class="w">         </span><span class="nv">gpsd_group</span><span class="o">=</span>uucp
<span class="w">         </span><span class="nv">nostrip</span><span class="o">=</span>True
<span class="w">         </span><span class="nv">manbuild</span><span class="o">=</span>False
<span class="w">         </span><span class="k">$(</span>use_scons<span class="w"> </span>python<span class="k">)</span>
<span class="w">     </span><span class="o">)</span>

<span class="w">     </span><span class="c1"># SConstruct uses py2 constructs</span>
<span class="hll"><span class="w">     </span>python_setup<span class="w"> </span>-2
</span><span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_compile<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span><span class="nb">export</span><span class="w"> </span><span class="nv">CHRPATH</span><span class="o">=</span>
<span class="w">     </span>tc-export<span class="w"> </span>CC<span class="w"> </span>CXX<span class="w"> </span>PKG_CONFIG
<span class="w">     </span><span class="nb">export</span><span class="w"> </span><span class="nv">SHLINKFLAGS</span><span class="o">=</span><span class="si">${</span><span class="nv">LDFLAGS</span><span class="si">}</span><span class="w"> </span><span class="nv">LINKFLAGS</span><span class="o">=</span><span class="si">${</span><span class="nv">LDFLAGS</span><span class="si">}</span>
<span class="w">     </span>escons
<span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_install<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span><span class="nv">DESTDIR</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">D</span><span class="si">}</span><span class="s2">&quot;</span><span class="w"> </span>escons<span class="w"> </span>install
<span class="w">     </span>use<span class="w"> </span>python<span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span>python_foreach_impl<span class="w"> </span>python_domodule<span class="w"> </span>gps
<span class="w"> </span><span class="o">}</span>
</pre></div>
</div>
</section>
</section>
<section id="waf">
<h2>waf<a class="headerlink" href="#waf" title="Permalink to this heading"></a></h2>
<p>The <a class="reference external" href="https://waf.io/">waf</a> build system is written in Python and bundled with the packages
using it.  Therefore, it is necessary to combine <code class="docutils literal notranslate"><span class="pre">waf-utils</span></code> eclass
with one of the Python eclasses.</p>
<p>Since SCons does not have any dependencies beside the Python
interpreter, the integration is generally simple.  You consider waf
like any other build-time script, and use the eclass implied by other
Python components in package.</p>
<p>Furthermore, since waf requires threading support in the Python
interpreter, it is necessary to add <code class="docutils literal notranslate"><span class="pre">PYTHON_REQ_USE='threads(+)'</span></code> in
all waf packages (combined with individual package requirements if
applicable).</p>
<section id="build-time-use">
<h3>Build-time use<a class="headerlink" href="#build-time-use" title="Permalink to this heading"></a></h3>
<p>If waf is the only build-time Python script in the package, it is only
necessary to add <code class="docutils literal notranslate"><span class="pre">PYTHON_REQ_USE</span></code> and <code class="docutils literal notranslate"><span class="pre">${PYTHON_DEPS}</span></code> to build-time
dependencies.  If the package had other Python dependencies, you would
specify them instead.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="w"> </span><span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
<span class="w"> </span><span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

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

<span class="hll"><span class="w"> </span><span class="nv">PYTHON_COMPAT</span><span class="o">=(</span><span class="w"> </span>python2_7<span class="w"> </span><span class="o">)</span>
</span><span class="hll"><span class="w"> </span><span class="nv">PYTHON_REQ_USE</span><span class="o">=</span><span class="s1">&#39;threads(+)&#39;</span>
</span><span class="w"> </span><span class="nv">NO_WAF_LIBDIR</span><span class="o">=</span>yes

<span class="hll"><span class="w"> </span>inherit<span class="w"> </span>python-any-r1<span class="w"> </span>waf-utils
</span>
<span class="w"> </span><span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;C++ Template Unit Test Framework&quot;</span>
<span class="w"> </span><span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;http://mrzechonek.github.io/tut-framework/&quot;</span>
<span class="w"> </span><span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://github.com/mrzechonek/tut-framework/archive/</span><span class="si">${</span><span class="nv">PV</span><span class="p">//./-</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="w"> </span><span class="nv">S</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">WORKDIR</span><span class="si">}</span><span class="s2">/tut-framework-</span><span class="si">${</span><span class="nv">PV</span><span class="p">//./-</span><span class="si">}</span><span class="s2">&quot;</span>

<span class="w"> </span><span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;BSD-2&quot;</span>
<span class="w"> </span><span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0&quot;</span>
<span class="w"> </span><span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">&quot;~amd64 ~x86&quot;</span>
<span class="w"> </span><span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;&quot;</span>

<span class="hll"><span class="w"> </span><span class="nv">BDEPEND</span><span class="o">=</span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span>
</span></pre></div>
</div>
</section>
<section id="id1">
<h3>Single-impl package<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h3>
<p>The rules for integrating simple-impl package are roughly the same
as for pure <code class="docutils literal notranslate"><span class="pre">python-single-r1</span></code> use.  Again, waf requires only plain
build-time <code class="docutils literal notranslate"><span class="pre">${PYTHON_DEPS}</span></code> and <code class="docutils literal notranslate"><span class="pre">PYTHON_REQ_USE</span></code>.</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="w"> </span><span class="c1"># Copyright 1999-2020 Gentoo Authors</span>
<span class="w"> </span><span class="c1"># Distributed under the terms of the GNU General Public License v2</span>

<span class="w"> </span><span class="nv">EAPI</span><span class="o">=</span><span class="m">6</span>
<span class="hll"><span class="w"> </span><span class="nv">PYTHON_COMPAT</span><span class="o">=(</span><span class="w"> </span>python2_7<span class="w"> </span><span class="o">)</span>
</span><span class="hll"><span class="w"> </span><span class="nv">PYTHON_REQ_USE</span><span class="o">=</span><span class="s2">&quot;threads&quot;</span>
</span>
<span class="hll"><span class="w"> </span>inherit<span class="w"> </span>python-single-r1<span class="w"> </span>waf-utils
</span>
<span class="w"> </span><span class="nv">DESCRIPTION</span><span class="o">=</span><span class="s2">&quot;An LDAP-like embedded database&quot;</span>
<span class="w"> </span><span class="nv">HOMEPAGE</span><span class="o">=</span><span class="s2">&quot;https://ldb.samba.org/&quot;</span>
<span class="w"> </span><span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;https://www.samba.org/ftp/pub/</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="w"> </span><span class="nv">LICENSE</span><span class="o">=</span><span class="s2">&quot;LGPL-3&quot;</span>
<span class="w"> </span><span class="nv">SLOT</span><span class="o">=</span><span class="s2">&quot;0/</span><span class="si">${</span><span class="nv">PV</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="w"> </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&quot;</span>
<span class="w"> </span><span class="nv">IUSE</span><span class="o">=</span><span class="s2">&quot;+ldap python&quot;</span>
<span class="w"> </span><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 class="w"> </span><span class="nv">RDEPEND</span><span class="o">=</span><span class="s2">&quot;!elibc_FreeBSD? ( dev-libs/libbsd )</span>
<span class="s2">     dev-libs/popt</span>
<span class="s2">     &gt;=sys-libs/talloc-2.1.8[python?]</span>
<span class="s2">     &gt;=sys-libs/tevent-0.9.31[python(+)?]</span>
<span class="s2">     &gt;=sys-libs/tdb-1.3.12[python?]</span>
<span class="s2">     python? ( </span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span><span class="s2"> )</span>
<span class="s2">     ldap? ( net-nds/openldap )</span>
<span class="s2">     &quot;</span>

<span class="w"> </span><span class="nv">DEPEND</span><span class="o">=</span><span class="s2">&quot;dev-libs/libxslt</span>
<span class="s2">     virtual/pkgconfig</span>
<span class="hll"><span class="s2">     </span><span class="si">${</span><span class="nv">PYTHON_DEPS</span><span class="si">}</span>
</span><span class="s2">     </span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span><span class="s2">&quot;</span>

<span class="w"> </span><span class="nv">WAF_BINARY</span><span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">S</span><span class="si">}</span><span class="s2">/buildtools/bin/waf&quot;</span>

<span class="w"> </span><span class="nv">PATCHES</span><span class="o">=(</span>
<span class="w">     </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">FILESDIR</span><span class="si">}</span><span class="s2">&quot;</span>/<span class="si">${</span><span class="nv">PN</span><span class="si">}</span>-1.1.27-optional_packages.patch
<span class="w">     </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">FILESDIR</span><span class="si">}</span><span class="s2">&quot;</span>/<span class="si">${</span><span class="nv">P</span><span class="si">}</span>-disable-python.patch
<span class="w"> </span><span class="o">)</span>

<span class="w"> </span>pkg_setup<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="hll"><span class="w">     </span>python-single-r1_pkg_setup
</span><span class="w"> </span><span class="o">}</span>

<span class="w"> </span>src_configure<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w">     </span><span class="nb">local</span><span class="w"> </span><span class="nv">myconf</span><span class="o">=(</span>
<span class="w">         </span><span class="k">$(</span>usex<span class="w"> </span>ldap<span class="w"> </span><span class="s1">&#39;&#39;</span><span class="w"> </span>--disable-ldap<span class="k">)</span>
<span class="w">         </span><span class="k">$(</span>usex<span class="w"> </span>python<span class="w"> </span><span class="s1">&#39;&#39;</span><span class="w"> </span><span class="s1">&#39;--disable-python&#39;</span><span class="k">)</span>
<span class="w">         </span>--disable-rpath
<span class="w">         </span>--disable-rpath-install<span class="w"> </span>--bundled-libraries<span class="o">=</span>NONE
<span class="w">         </span>--with-modulesdir<span class="o">=</span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">EPREFIX</span><span class="si">}</span><span class="s2">&quot;</span>/usr/<span class="k">$(</span>get_libdir<span class="k">)</span>/samba
<span class="w">         </span>--builtin-libraries<span class="o">=</span>NONE
<span class="w">     </span><span class="o">)</span>
<span class="w">     </span>waf-utils_src_configure<span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">myconf</span><span class="p">[@]</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="w"> </span><span class="o">}</span>
</pre></div>
</div>
</section>
</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"><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="test.html">Tests in Python packages</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="pypi.html">pypi — helper eclass for PyPI archives</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="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 current"><a class="current reference internal" href="#">Integration with build systems written in Python</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#meson">Meson</a></li>
<li class="toctree-l2"><a class="reference internal" href="#scons">SCons</a></li>
<li class="toctree-l2"><a class="reference internal" href="#waf">waf</a></li>
</ul>
</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="expert-multi.html" title="previous chapter">Expert python-r1 usage</a></li>
      <li>Next: <a href="porting.html" title="next chapter">Porting tips</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 7.1.1</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a>
      
      |
      <a href="_sources/buildsys.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>