@@ -87,6 +87,7 @@ The first is the specification of ``Py_LIMITED_API`` in ``extra_compile_args`` t
8787minimum CPython version you would like to support:
8888
8989.. code-block :: python
90+
9091 extra_compile_args= {" cxx" : [" -DPy_LIMITED_API=0x03090000" ]},
9192
9293 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
99100and the dispatcher). We strongly recommend defining the ``Py_LIMITED_API `` flag to
100101ensure the extension is compliant and safe as a CPython agnostic wheel.
101102
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:
107105
108106.. code-block :: python
107+
109108 setup(name = " extension_cpp" ,
110109 ext_modules = [
111110 cpp_extension.CppExtension(
@@ -115,11 +114,15 @@ to the ``"bdist_wheel"`` command with the minimal supported CPython version (in
115114 options = {" bdist_wheel" : {" py_limited_api" : " cp39" }} # 3.9 is minimum supported Python version
116115 )
117116
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 ``.
120122
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:
123126
124127.. code-block :: python
125128
0 commit comments