Skip to content

Commit 9e388d2

Browse files
committed
polish + i missed some code blocks earlier
1 parent 164c842 commit 9e388d2

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

advanced_source/cpp_custom_ops.rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ The first is the specification of ``Py_LIMITED_API`` in ``extra_compile_args`` t
8787
minimum 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
99100
and the dispatcher). We strongly recommend defining the ``Py_LIMITED_API`` flag to
100101
ensure 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

Comments
 (0)