@@ -126,8 +126,7 @@ For these reasons, to achieve broad portability, Python wheels
126
126
127
127
To be eligible for the ``manylinux1 `` platform tag, a Python wheel must
128
128
therefore both (a) contain binary executables and compiled code that links
129
- *only * to libraries (other than the appropriate ``libpython `` library, which is
130
- always a permitted dependency consistent with the PEP 425 ABI tag) with SONAMEs
129
+ *only * to libraries with SONAMEs
131
130
included in the following list: ::
132
131
133
132
libpanelw.so.5
@@ -153,11 +152,7 @@ included in the following list: ::
153
152
libglib-2.0.so.0
154
153
155
154
and, (b) work on a stock CentOS 5.11 [6 ]_ system that contains the system
156
- package manager's provided versions of these libraries. In addition,
157
- for wheels targeting CPython 3.2 and earlier (including all 2.x
158
- versions), there is an extra requirement that (c) the wheel be
159
- built against a version of CPython compiled with 4-byte unicode
160
- support (i.e. one where ``sys.maxunicode > 0xFFFF ``).
155
+ package manager's provided versions of these libraries.
161
156
162
157
Because CentOS 5 is only available for x86_64 and i686 architectures,
163
158
these are the only architectures currently supported by the ``manylinux1 ``
@@ -216,6 +211,81 @@ the list above to remove libraries that have turned out to be
216
211
problematic or add libraries that have turned out to be safe.
217
212
218
213
214
+ libpythonX.Y.so.1
215
+ -----------------
216
+
217
+ Note that ``libpythonX.Y.so.1 `` is *not * on the list of libraries that
218
+ a ``manylinux1 `` extension is allowed to link to. Explicitly linking
219
+ to ``libpythonX.Y.so.1 `` is unnecessary in almost all cases: the way
220
+ ELF linking works, extension modules that are loaded into the
221
+ interpreter automatically get access to all of the interpreter's
222
+ symbols, regardless of whether or not the extension itself is
223
+ explicitly linked against libpython. Furthermore, explicit linking to
224
+ libpython creates problems in the common configuration where Python is
225
+ not built with ``--enable-shared ``. In particular, on Debian and
226
+ Ubuntu systems, ``apt install pythonX.Y `` does not even install
227
+ ``libpythonX.Y.so.1 ``, meaning that any wheel that *did * depend on
228
+ ``libpythonX.Y.so.1 `` could fail to import.
229
+
230
+ There is one situation where extensions that are linked in this way
231
+ can fail to work: if a host program (e.g., ``apache2 ``) uses
232
+ ``dlopen() `` to load a module (e.g., ``mod_wsgi ``) that embeds the
233
+ CPython interpreter, and the host program does *not * pass the
234
+ ``RTLD_GLOBAL `` flag to ``dlopen() ``, then the embedded CPython will
235
+ be unable to load any extension modules that do not themselves link
236
+ explicitly to ``libpythonX.Y.so.1 ``. Fortunately, ``apache2 `` *does *
237
+ set the ``RTLD_GLOBAL `` flag, as do all the other programs that
238
+ embed-CPython-via-a-dlopened-plugin that we could locate, so this does
239
+ not seem to be a serious problem in practice. The incompatibility with
240
+ Debian/Ubuntu is more of an issue than the theoretical incompatibility
241
+ with a rather obscure corner case.
242
+
243
+ This is a rather complex and subtle issue that extends beyond
244
+ the scope of ``manylinux1 ``; for more discussion see: [9 ]_, [10 ]_,
245
+ [11 ]_.
246
+
247
+ UCS-2 vs UCS-4 builds
248
+ ---------------------
249
+
250
+ All versions of CPython 2.x, plus CPython 3.0-3.2 inclusive, can be
251
+ built in two ABI-incompatible modes: builds using the
252
+ ``--enable-unicode=ucs2 `` configure flag store Unicode data in UCS-2
253
+ (or really UTF-16) format, while builds using the
254
+ ``--enable-unicode=ucs4 `` configure flag store Unicode data in
255
+ UCS-4. (CPython 3.3 and greater use a different storage method that
256
+ always supports UCS-4.) If we want to make sure ``ucs2 `` wheels don't
257
+ get installed into ``ucs4 `` CPythons and vice-versa, then something
258
+ must be done.
259
+
260
+ An earlier version of this PEP included a requirement that
261
+ ``manylinux1 `` wheels targeting these older CPython versions should
262
+ always use the ``ucs4 `` ABI. But then, in between the PEP's initial
263
+ acceptance and its implementation, ``pip `` and ``wheel `` gained
264
+ first-class support for tracking and checking this aspect of ABI
265
+ compatibility for the relevant CPython versions, which is a better
266
+ solution. So we now allow the ``manylinux1 `` platform tags to be used
267
+ in combination with any ABI tag. However, to maintain compatibility it
268
+ is crucial to ensure that all ``manylinux1 `` wheels include a
269
+ non-trivial abi tag. For example, a wheel built against a ``ucs4 ``
270
+ CPython might have a name like::
271
+
272
+ PKG-VERSION-cp27-cp27mu-manylinux1_x86_64.whl
273
+ ^^^^^^ Good!
274
+
275
+ While a wheel built against the ``ucs2 `` ABI might have a name like::
276
+
277
+ PKG-VERSION-cp27-cp27m-manylinux1_x86_64.whl
278
+ ^^^^^ Okay!
279
+
280
+ But you should never have a wheel with a name like::
281
+
282
+ PKG-VERSION-cp27-none-manylinux1_x86_64.whl
283
+ ^^^^ BAD! Don't do this!
284
+
285
+ We note for information that the ``ucs4 `` ABI appears to be much more
286
+ widespread among Linux CPython distributors.
287
+
288
+
219
289
Compilation of Compliant Wheels
220
290
===============================
221
291
@@ -237,15 +307,15 @@ Docker Image
237
307
238
308
The first tool is a Docker image based on CentOS 5.11, which is recommended as
239
309
an easy to use self-contained build box for compiling ``manylinux1 `` wheels
240
- [9 ]_. Compiling on a more recently-released linux distribution will generally
310
+ [12 ]_. Compiling on a more recently-released linux distribution will generally
241
311
introduce dependencies on too-new versioned symbols. The image comes with a
242
312
full compiler suite installed (``gcc ``, ``g++ ``, and ``gfortran `` 4.8.2) as
243
313
well as the latest releases of Python and ``pip ``.
244
314
245
315
Auditwheel
246
316
----------
247
317
248
- The second tool is a command line executable called ``auditwheel `` [10 ]_ that
318
+ The second tool is a command line executable called ``auditwheel `` [13 ]_ that
249
319
may aid in package maintainers in dealing with third-party external
250
320
dependencies.
251
321
@@ -285,7 +355,7 @@ While we acknowledge many approaches for dealing with third-party library
285
355
dependencies within ``manylinux1 `` wheels, we recognize that the ``manylinux1 ``
286
356
policy encourages bundling external dependencies, a practice
287
357
which runs counter to the package management policies of many linux
288
- distributions' system package managers [11 ]_, [12 ]_. The primary purpose of
358
+ distributions' system package managers [14 ]_, [15 ]_. The primary purpose of
289
359
this is cross-distro compatibility. Furthermore, ``manylinux1 `` wheels on PyPI
290
360
occupy a different niche than the Python packages available through the
291
361
system package manager.
@@ -352,17 +422,14 @@ think otherwise.
352
422
We know of four main sources of potential incompatibility that are
353
423
likely to arise in practice:
354
424
355
- * "Narrow" unicode builds of Python 3.2 and earlier (including all
356
- versions of Python 2)
357
425
* Eventually, in the future, there may exist distributions that break
358
426
compatibility with this profile (e.g., if one of the libraries in
359
427
the profile changes its ABI in a backwards-incompatible way)
360
428
* A linux distribution that is too old (e.g. RHEL 4)
361
429
* A linux distribution that does not use ``glibc `` (e.g. Alpine Linux, which is
362
430
based on musl ``libc ``, or Android)
363
431
364
- Checking for unicode configuration compatibility is straightforward,
365
- but the other cases are more subtle. We propose a two-pronged
432
+ To address these we propose a two-pronged
366
433
approach. To handle potential future incompatibilities, we standardize
367
434
a mechanism for a Python distributor to signal that a particular
368
435
Python install definitely is or is not compatible with ``manylinux1 ``:
@@ -389,11 +456,6 @@ Specifically, the algorithm we propose is::
389
456
if get_platform() not in ["linux-x86_64", "linux-i686"]:
390
457
return False
391
458
392
- # "wide" Unicode mode is mandatory (always true on CPython 3.3+)
393
- import sys
394
- if sys.maxunicode <= 0xFFFF:
395
- return False
396
-
397
459
# Check for presence of _manylinux module
398
460
try:
399
461
import _manylinux
@@ -522,13 +584,21 @@ References
522
584
(https://groups.google.com/forum/#!topic/manylinux-discuss/-4l3rrjfr9U)
523
585
.. [8 ] distutils-sig discussion
524
586
(https://mail.python.org/pipermail/distutils-sig/2016-January/027997.html)
525
- .. [9 ] manylinux1 docker image
526
- (https://quay.io/repository/manylinux/manylinux)
527
- .. [10 ] auditwheel tool
587
+ .. [9 ] distutils-sig discussion
588
+ (https://mail.python.org/pipermail/distutils-sig/2016-February/028275.html)
589
+ .. [10 ] github issue discussion
590
+ (https://github.com/pypa/manylinux/issues/30)
591
+ .. [11 ] python bug tracker discussion
592
+ (https://bugs.python.org/issue21536)
593
+ .. [12 ] manylinux1 docker images
594
+ (Source: https://github.com/pypa/manylinux;
595
+ x86-64: https://quay.io/repository/pypa/manylinux1_x86_64;
596
+ x86-32: https://quay.io/repository/pypa/manylinux1_i686)
597
+ .. [13 ] auditwheel tool
528
598
(https://pypi.python.org/pypi/auditwheel)
529
- .. [11 ] Fedora Bundled Software Policy
599
+ .. [14 ] Fedora Bundled Software Policy
530
600
(https://fedoraproject.org/wiki/Bundled_Software_policy)
531
- .. [12 ] Debian Policy Manual -- 4.13: Convenience copies of code
601
+ .. [15 ] Debian Policy Manual -- 4.13: Convenience copies of code
532
602
(https://www.debian.org/doc/debian-policy/ch-source.html#s-embeddedfiles)
533
603
534
604
0 commit comments