You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+23-8Lines changed: 23 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,7 @@ Cython
87
87
======
88
88
This template has an option to add boilerplate for Cython_.
89
89
Cython is a programming language that simplifies the creation of C extensions for Python.
90
-
The Cython documentation is quite good; the aim of this section is to explain what this
90
+
The `Cython documentation is quite good<https://cython.readthedocs.io/en/latest/src/userguide/language_basics.html>`_; the aim of this section is to explain what this
91
91
template sets up, and what actions will still need to be performed by you.
92
92
This explanation assumes you are familiar with C.
93
93
Replace any reference here to ``pythontemplate`` with your project name.
@@ -97,31 +97,46 @@ Replace any reference here to ``pythontemplate`` with your project name.
97
97
98
98
2. Update ``pythontemplate/cpythontemplate.pxd`` with header information from the files in (1).
99
99
Example of common definitions (functions, structs, and enums) are provided.
100
-
Think of ``*.pxd`` as a header file that allows Cython ``.pyx`` code to access pure C files.
101
-
This file will be compiled into a package that can be imported in a ``.pyx`` file via ``cimport``.
102
-
If you don't plan on using any explicit C files, you may delete this file.
100
+
Think of ``*.pxd`` as a header file that allows Cython ``.pyx`` code to access pure C ``.c`` files.
101
+
This file will be compiled into a package of the same name that can be imported in a ``.pyx`` file via ``cimport``.
102
+
If you don't plan on using any explicit C files, you may delete this file and the ``_c_src`` directory.
103
103
104
104
3. Add Cython code to ``pythontemplate/_c_extension.pyx``. Some class starter code is provided.
105
105
This is where a good pythonic interface (functions and classes) should be written.
106
106
107
-
4. Optionally tweak ``build.py`` (runs at setup/installation) with compiler options.
107
+
4. If adding type hints, update ``pythontemplate/_c_extension.pyi`` to reflect your ``.pyx`` implementation.
108
+
109
+
5. Optionally tweak ``build.py`` (runs at setup/installation) with compiler options.
108
110
The default ``build.py`` offers a good, working starting point for most projects and performs the following:
109
111
110
112
a. Recursively searches for all C files in ``pythontemplate/_c_src/``.
111
113
To change this action, modify the variable ``c_files``.
112
114
113
115
b. Compiles the code defined in ``_c_extension.pyx`` into a shared object file.
114
116
115
-
c. Adds ``pythontemplate`` and ``pythontemplate/_c_src`` to the Include Path (variable ``include_dirs``).
117
+
c. Adds ``pythontemplate`` and ``pythontemplate/_c_src`` to the Include Path (python variable ``include_dirs``).
116
118
117
119
d. If your codebase contains a slower, python implementation of your Cython code,
118
120
we can allow building to fail by uncommenting the ``allowed_to_fail`` logic at the top.
121
+
The logic checks for the environment variable ``CIBUILDWHEEL`` because we don't want to allow
122
+
build failures in our CI when creating pre-built wheels that we upload to PyPI.
119
123
120
-
5. The Github Action workflow defined in ``.github/workflows/build_wheels.yaml`` will create pre-built
124
+
6. The Github Action workflow defined in ``.github/workflows/build_wheels.yaml`` will create pre-built
121
125
binaries for all major Python versions, operating systems, and computer architectures.
122
126
It will also create a Source Distribution (sdist).
123
-
Finally, on git semver tags (``vX.X.X``), it will upload all the resulting wheels to PyPI.
127
+
All of these distributions will be uploaded to the github action job page.
128
+
On git semver tags (``vX.X.X``), they will be uploaded to PyPI.
129
+
130
+
When developing, you must re-run ``poetry-install`` to re-compile changes made in C/Cython code.
131
+
The resulting, built Cython code will be importable from ``pythontemplate._c_extension``, so it may be
132
+
good to add something like the following to your ``pythontemplate/__init__.py``:
0 commit comments