@@ -230,34 +230,82 @@ The CPython :doc:`Extending and Embedding <python:extending/index>`
230
230
guide includes an introduction to writing a
231
231
:doc: `custom extension module in C <python:extending/extending >`.
232
232
233
- ..
233
+ FIXME: Elaborate that all this is one of the reasons why you probably
234
+ *don't * want to handcode your extension modules :)
234
235
235
- FIXME
236
236
237
- * mention the stable ABI (3.2+, link to the CPython C API docs)
238
- * mention the module lifecycle
239
- * mention the challenges of shared static state and subinterpreters
240
- * mention the implications of the GIL for extension modules
241
- * mention the memory allocation APIs in 3.4+
237
+ Extension module lifecycle
238
+ --------------------------
242
239
243
- * mention again that all this is one of the reasons why you probably *don't *
244
- want to handcode your extension modules :)
240
+ FIXME: This section needs to be fleshed out.
241
+
242
+
243
+ Implications of shared static state and subinterpreters
244
+ -------------------------------------------------------
245
+
246
+ FIXME: This section needs to be fleshed out.
247
+
248
+
249
+ Implications of the GIL
250
+ -----------------------
251
+
252
+ FIXME: This section needs to be fleshed out.
253
+
254
+
255
+ Memory allocation APIs
256
+ ----------------------
257
+
258
+ FIXME: This section needs to be fleshed out.
259
+
260
+
261
+ .. _cpython-stable-abi :
262
+
263
+ ABI Compatibility
264
+ -----------------
265
+
266
+ The CPython C API does not guarantee ABI stability between minor releases
267
+ (3.2, 3.3, 3.4, etc.). This means that, typically, if you build an
268
+ extension module against one version of Python, it is only guaranteed to
269
+ work with the same minor version of Python and not with any other minor
270
+ versions.
271
+
272
+ Python 3.2 introduced the Limited API, with is a well-defined subset of
273
+ Python's C API. The symbols needed for the Limited API form the
274
+ "Stable ABI" which is guaranteed to be compatible across all Python 3.x
275
+ versions. Wheels containing extensions built against the stable ABI use
276
+ the ``abi3 `` ABI tag, to reflect that they're compatible with all Python
277
+ 3.x versions.
278
+
279
+ CPython's :doc: `C API stability<python:c-api/stable> ` page provides
280
+ detailed information about the API / ABI stability guarantees, how to use
281
+ the Limited API and the exact contents of the "Limited API".
245
282
246
283
247
284
Building binary extensions
248
285
==========================
249
286
287
+ FIXME: Cover the build-backends available for building extensions.
288
+
250
289
Building extensions for multiple platforms
251
290
------------------------------------------
252
291
253
292
If you plan to distribute your extension, you should provide
254
- :term: `wheels <Wheel> ` for all the platforms you intend to support. For most
255
- extensions, this is at least one package per Python version times the number of
256
- OS and architectures you support. These are usually built on continuous
257
- integration (CI) systems. There are tools to help you build highly
258
- redistributable binaries from CI; these include :ref: `cibuildwheel ` and
259
- :ref: `multibuild `.
293
+ :term: `wheels <Wheel> ` for all the platforms you intend to support. These
294
+ are usually built on continuous integration (CI) systems. There are tools
295
+ to help you build highly redistributable binaries from CI; these include
296
+ :ref: `cibuildwheel ` and :ref: `multibuild `.
297
+
298
+ For most extensions, you will need to build wheels for all the platforms
299
+ you intend to support. This means that the number of wheels you need to
300
+ build is the product of::
301
+
302
+ count(Python minor versions) * count(OS) * count(architectures)
260
303
304
+ Using CPython's :ref: `Stable ABI <cpython-stable-abi >` can help significantly
305
+ reduce the number of wheels you need to provide, since a single wheel on a
306
+ platform can be used with all Python minor versions; eliminating one dimension
307
+ of the matrix. It also removes the need to generate new wheels for each new
308
+ minor version of Python.
261
309
262
310
Binary extensions for Windows
263
311
-----------------------------
@@ -310,20 +358,24 @@ Spinning Wheels wiki
310
358
Publishing binary extensions
311
359
============================
312
360
313
- For interim guidance on this topic, see the discussion in
314
- :issue: `this issue <284> `.
361
+ Publishing binary extensions through PyPI uses the same upload mechanisms as
362
+ publishing pure Python packages. You build a wheel file for your extension
363
+ using the build-backend and upload it to PyPI using
364
+ :doc: `twine <twine:index >`.
315
365
316
- ..
366
+ Avoid binary-only releases
367
+ --------------------------
317
368
318
- FIXME
369
+ It is strongly recommended that you publish your binary extensions as
370
+ well as the source code that was used to build them. This allows users to
371
+ build the extension from source if they need to. Notably, this is required
372
+ for certain Linux distributions that build from source within their
373
+ own build systems for the distro package repositories.
319
374
320
- * cover publishing as wheel files on PyPI or a custom index server
321
- * cover creation of Windows and macOS installers
322
- * cover weak linking
323
- * mention the fact that Linux distros have a requirement to build from
324
- source in their own build systems, so binary-only releases are strongly
325
- discouraged
375
+ Weak linking
376
+ ------------
326
377
378
+ FIXME: This section needs to be fleshed out.
327
379
328
380
Additional resources
329
381
====================
0 commit comments