summaryrefslogtreecommitdiff
blob: 51cb5160182347b972a502911209827ac184db20 (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
<!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>pypi — helper eclass for PyPI archives &#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/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="Common helper functions" href="helper.html" />
    <link rel="prev" title="distutils-r1 legacy concepts" href="distutils-legacy.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="pypi-helper-eclass-for-pypi-archives">
<h1>pypi — helper eclass for PyPI archives<a class="headerlink" href="#pypi-helper-eclass-for-pypi-archives" title="Permalink to this heading"></a></h1>
<p>The <code class="docutils literal notranslate"><span class="pre">pypi</span></code> eclass is a small eclass to facilitate fetching sources
from PyPI.  It abstracts away the complexity of PyPI URLs, and makes it
easier to adapt <code class="docutils literal notranslate"><span class="pre">SRC_URI</span></code> to their future changes.</p>
<p>Please note that PyPI archives are not always the best choice
for distfiles.  In particular, they frequently are missing tests
and other files important to Gentoo packaging.  Should that be the case,
other archives should be used.  Read the <a class="reference internal" href="distutils.html#source-archives"><span class="std std-ref">Source archives</span></a> section
for more information.</p>
<p>Eclass reference: <a class="reference external" href="https://devmanual.gentoo.org/eclass-reference/pypi.eclass/index.html">pypi.eclass(5)</a></p>
<section id="packages-with-matching-name-and-version">
<h2>Packages with matching name and version<a class="headerlink" href="#packages-with-matching-name-and-version" title="Permalink to this heading"></a></h2>
<p>In the most common case, the upstream package will have exactly the same
name as the Gentoo package, and the version numbers will be entirely
compatible.  In this case, it is sufficient to inherit the eclass,
and it will automatically set a suitable default <code class="docutils literal notranslate"><span class="pre">SRC_URI</span></code>.  The URI
will be equivalent to:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;</span>
<span class="s2">    https://files.pythonhosted.org/packages/source/</span><span class="si">${</span><span class="nv">PN</span><span class="p">::</span><span class="nv">1</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">P</span><span class="si">}</span><span class="s2">.tar.gz</span>
<span class="s2">&quot;</span>
</pre></div>
</div>
<p>Note that <code class="docutils literal notranslate"><span class="pre">SRC_URI</span></code> is not combined between eclasses and ebuilds.
Should you need to fetch additional files, you need to explicitly append
to the variable or the default will be overwritten, e.g.:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>inherit<span class="w"> </span>distutils-r1<span class="w"> </span>pypi

<span class="nv">SRC_URI</span><span class="o">+=</span><span class="s2">&quot;</span>
<span class="s2">    https://github.com/pytest-dev/execnet/commit/c0459b92bc4a42b08281e69b8802d24c5d3415d4.patch</span>
<span class="s2">        -&gt; </span><span class="si">${</span><span class="nv">P</span><span class="si">}</span><span class="s2">-pytest-7.2.patch</span>
<span class="s2">&quot;</span>
</pre></div>
</div>
</section>
<section id="customizing-the-generated-url">
<h2>Customizing the generated URL<a class="headerlink" href="#customizing-the-generated-url" title="Permalink to this heading"></a></h2>
<p>The default value may not be suitable for your package if it uses
a different project name, version numbers that are incompatible with
Gentoo or the legacy <code class="docutils literal notranslate"><span class="pre">.zip</span></code> sdist format.  The <code class="docutils literal notranslate"><span class="pre">pypi_sdist_url</span></code>
function can be used to generate URLs in that case.  Its usage is:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pypi_sdist_url<span class="w"> </span><span class="o">[</span>&lt;project&gt;<span class="w"> </span><span class="o">[</span>&lt;version&gt;<span class="w"> </span><span class="o">[</span>&lt;suffix&gt;<span class="o">]]]</span>
</pre></div>
</div>
<p>with package defaulting to <code class="docutils literal notranslate"><span class="pre">${PN}</span></code>, version to <code class="docutils literal notranslate"><span class="pre">${PV}</span></code> and suffix
to <code class="docutils literal notranslate"><span class="pre">.tar.gz</span></code>.  For example, the Gentoo <code class="docutils literal notranslate"><span class="pre">dev-python/markups</span></code> package
uses title-case <code class="docutils literal notranslate"><span class="pre">Markups</span></code> project name, and so the ebuild uses:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>inherit<span class="w"> </span>distutils-r1<span class="w"> </span>pypi

<span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>pypi_sdist_url<span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PN</span><span class="p">^</span><span class="si">}</span><span class="s2">&quot;</span><span class="k">)</span><span class="s2">&quot;</span>
</pre></div>
</div>
</section>
<section id="fetching-wheels">
<h2>Fetching wheels<a class="headerlink" href="#fetching-wheels" title="Permalink to this heading"></a></h2>
<p>In very specific cases, it may be necessary to fetch wheels
(i.e. prebuilt Python packages) instead.  The <code class="docutils literal notranslate"><span class="pre">pypi_wheel_url</span></code>
function is provided to aid this purpose.  Its usage is:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pypi_wheel_url<span class="w"> </span><span class="o">[</span>&lt;project&gt;<span class="w"> </span><span class="o">[</span>&lt;version&gt;<span class="w"> </span><span class="o">[</span>&lt;python-tag&gt;<span class="w"> </span><span class="o">[</span>&lt;abi-platform-tag&gt;<span class="o">]]]]</span>
</pre></div>
</div>
<p>with package defaulting to <code class="docutils literal notranslate"><span class="pre">${PN}</span></code>, version to <code class="docutils literal notranslate"><span class="pre">${PV}</span></code>, python-tag
to <code class="docutils literal notranslate"><span class="pre">py3</span></code> and abi-platform-tag to <code class="docutils literal notranslate"><span class="pre">none-any</span></code> (i.e. indicating a pure
Python package).  For example, <code class="docutils literal notranslate"><span class="pre">dev-python/ensurepip-setuptools</span></code>
does:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>inherit<span class="w"> </span>pypi
<span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>pypi_wheel_url<span class="w"> </span><span class="s2">&quot;</span><span class="si">${</span><span class="nv">PN</span><span class="p">#ensurepip-</span><span class="si">}</span><span class="s2">&quot;</span><span class="k">)</span><span class="s2">&quot;</span>
</pre></div>
</div>
<p>Note that wheels are ZIP archives suffixed <code class="docutils literal notranslate"><span class="pre">.whl</span></code>, and they are not
unpacked by the package manager automatically.  You either need to
unzip it explicitly or use <code class="docutils literal notranslate"><span class="pre">-&gt;</span></code> to rename it, e.g. by appending
<code class="docutils literal notranslate"><span class="pre">.zip</span></code> suffix.  Remember to add an explicit dependency
on <code class="docutils literal notranslate"><span class="pre">app-arch/unzip</span></code> as well.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">pypi_wheel_filename</span></code> function is provided to aid getting
the wheel filename.  It has a matching synopsis:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>pypi_wheel_filename<span class="w"> </span><span class="o">[</span>&lt;project&gt;<span class="w"> </span><span class="o">[</span>&lt;version&gt;<span class="w"> </span><span class="o">[</span>&lt;python-tag&gt;<span class="w"> </span><span class="o">[</span>&lt;abi-platform-tag&gt;<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"><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 current"><a class="current reference internal" href="#">pypi — helper eclass for PyPI archives</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#packages-with-matching-name-and-version">Packages with matching name and version</a></li>
<li class="toctree-l2"><a class="reference internal" href="#customizing-the-generated-url">Customizing the generated URL</a></li>
<li class="toctree-l2"><a class="reference internal" href="#fetching-wheels">Fetching wheels</a></li>
</ul>
</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"><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="distutils-legacy.html" title="previous chapter">distutils-r1 legacy concepts</a></li>
      <li>Next: <a href="helper.html" title="next chapter">Common helper functions</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 6.1.3</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a>
      
      |
      <a href="_sources/pypi.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>