File: README.rst

package info (click to toggle)
pygobject 3.54.5-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,864 kB
  • sloc: ansic: 40,281; python: 26,363; sh: 477; makefile: 81; xml: 35; cpp: 1
file content (55 lines) | stat: -rw-r--r-- 1,697 bytes parent folder | download | duplicates (4)
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
++++++++++++++++++++++++++
Python C API compatibility
++++++++++++++++++++++++++

.. image:: https://github.com/python/pythoncapi-compat/actions/workflows/build.yml/badge.svg
   :alt: Build status of pythoncapi-compat on GitHub Actions
   :target: https://github.com/python/pythoncapi-compat/actions

The ``pythoncapi-compat`` project can be used to write a C or C++ extension
supporting a wide range of Python versions with a single code base.  It is made
of the ``pythoncapi_compat.h`` header file and the ``upgrade_pythoncapi.py``
script.

``upgrade_pythoncapi.py`` requires Python 3.6 or newer.

See the `documentation at ReadTheDocs
<https://pythoncapi-compat.readthedocs.io/en/latest/>`_
for more details.

Getting started
===============

To upgrade a specific file::

    python3 upgrade_pythoncapi.py module.c

To upgrade all C/C++ files in a directory::

    python3 upgrade_pythoncapi.py src/

Select operations
-----------------

To only replace ``op->ob_type`` with ``Py_TYPE(op)``, select the ``Py_TYPE``
operation with::

    python3 upgrade_pythoncapi.py -o Py_TYPE module.c

Or the opposite, to apply all operations but leave ``op->ob_type`` unchanged,
deselect the ``Py_TYPE`` operation with::

    python3 upgrade_pythoncapi.py -o all,-Py_TYPE module.c

Download pythoncapi_compat.h
----------------------------

If you want to ``pythoncapi_compat.h`` to your code base, use the
``upgrade_pythoncapi.py`` tool to fetch it::

    python3 upgrade_pythoncapi.py --download PATH


This project is distributed under the `Zero Clause BSD (0BSD) license
<https://opensource.org/licenses/0BSD>`_ and is covered by the `PSF Code of
Conduct <https://www.python.org/psf/codeofconduct/>`_.