https://github.com/python/pythoncapi-compat
The pythoncapi-compat project can be used to write a C extension supporting a wide range of Python versions with a single code base.
https://github.com/python/pythoncapi-compat
Last synced: 2 months ago
JSON representation
The pythoncapi-compat project can be used to write a C extension supporting a wide range of Python versions with a single code base.
- Host: GitHub
- URL: https://github.com/python/pythoncapi-compat
- Owner: python
- License: 0bsd
- Created: 2020-06-04T17:09:06.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-17T09:50:17.000Z (8 months ago)
- Last Synced: 2024-10-29T16:05:38.887Z (7 months ago)
- Language: Python
- Homepage: https://pythoncapi-compat.readthedocs.io/
- Size: 223 KB
- Stars: 80
- Watchers: 12
- Forks: 23
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: COPYING
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
++++++++++++++++++++++++++
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/actionsThe ``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
`_
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
`_ and is covered by the `PSF Code of
Conduct `_.