@@ -87,6 +87,7 @@ The first is the specification of ``Py_LIMITED_API`` in ``extra_compile_args`` t
87
87
minimum CPython version you would like to support:
88
88
89
89
.. code-block :: python
90
+
90
91
extra_compile_args= {" cxx" : [" -DPy_LIMITED_API=0x03090000" ]},
91
92
92
93
Defining the ``Py_LIMITED_API `` flag helps guarantee that the extension is in fact
@@ -99,13 +100,11 @@ pytorch/python bindings,) and to only use APIs from libtorch (ATen objects, oper
99
100
and the dispatcher). We strongly recommend defining the ``Py_LIMITED_API `` flag to
100
101
ensure the extension is compliant and safe as a CPython agnostic wheel.
101
102
102
- The second and third lines inform setuptools that you intend to build a CPython agnostic
103
- wheel and will influence the naming of the wheel accordingly. It is necessary to specify
104
- ``py_limited_api=True `` as an argument to CppExtension/CUDAExtension and also as an option
105
- to the ``"bdist_wheel" `` command with the minimal supported CPython version (in this case,
106
- 3.9):
103
+ The second and third lines specifying ``py_limited_api `` inform setuptools that you intend
104
+ to build a CPython agnostic wheel and will influence the naming of the wheel accordingly:
107
105
108
106
.. code-block :: python
107
+
109
108
setup(name = " extension_cpp" ,
110
109
ext_modules = [
111
110
cpp_extension.CppExtension(
@@ -115,11 +114,15 @@ to the ``"bdist_wheel"`` command with the minimal supported CPython version (in
115
114
options = {" bdist_wheel" : {" py_limited_api" : " cp39" }} # 3.9 is minimum supported Python version
116
115
)
117
116
118
- This ``setup `` would build one wheel that could be installed across multiple CPython
119
- versions ``>=3.9 ``.
117
+ It is necessary to specify ``py_limited_api=True `` as an argument to CppExtension/
118
+ CUDAExtension and also as an option to the ``"bdist_wheel" `` command with the minimal
119
+ supported CPython version (in this case, 3.9, as it is the oldest supported version
120
+ currently). Consequently, the ``setup `` in our tutorial would build one wheel that could
121
+ be installed across multiple CPython versions ``>=3.9 ``.
120
122
121
- If your extension uses CPython APIs outside the stable limited set, then you should build
122
- a wheel per CPython version instead, like so:
123
+ If your extension uses CPython APIs outside the stable limited set, then you cannot
124
+ build a CPython agnostic wheel! You should build one wheel per CPython version instead,
125
+ like so:
123
126
124
127
.. code-block :: python
125
128
0 commit comments