diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2018-10-27 17:26:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-27 17:26:46 -0400 |
commit | fb84b3fdfd6d4e010d8397efacf4388ee418da7f (patch) | |
tree | 2be4e1c7b6ba0f3327f1ffa6a7adb8810c883aad | |
parent | 72293ecb02c345d0cb33e479df52dc55598df670 (diff) | |
parent | ab4e5b9b3c3404f897e12a9fd882fddc9a36cc77 (diff) | |
download | external_python_setuptools-fb84b3fdfd6d4e010d8397efacf4388ee418da7f.tar.gz external_python_setuptools-fb84b3fdfd6d4e010d8397efacf4388ee418da7f.tar.bz2 external_python_setuptools-fb84b3fdfd6d4e010d8397efacf4388ee418da7f.zip |
Merge pull request #1534 from xrmx/cythonvspyrex
Document building Cython projects instead of Pyrex
-rw-r--r-- | changelog.d/1395.doc.rst | 1 | ||||
-rw-r--r-- | docs/setuptools.txt | 39 |
2 files changed, 23 insertions, 17 deletions
diff --git a/changelog.d/1395.doc.rst b/changelog.d/1395.doc.rst new file mode 100644 index 00000000..346041ce --- /dev/null +++ b/changelog.d/1395.doc.rst @@ -0,0 +1 @@ +Document building Cython projects instead of Pyrex diff --git a/docs/setuptools.txt b/docs/setuptools.txt index f2774b65..ec40548a 100644 --- a/docs/setuptools.txt +++ b/docs/setuptools.txt @@ -41,9 +41,9 @@ Feature Highlights: files for any number of "main" functions in your project. (Note: this is not a py2exe replacement; the .exe files rely on the local Python installation.) -* Transparent Pyrex support, so that your setup.py can list ``.pyx`` files and - still work even when the end-user doesn't have Pyrex installed (as long as - you include the Pyrex-generated C in your source distribution) +* Transparent Cython support, so that your setup.py can list ``.pyx`` files and + still work even when the end-user doesn't have Cython installed (as long as + you include the Cython-generated C in your source distribution) * Command aliases - create project-specific, per-user, or site-wide shortcut names for commonly used commands and options @@ -1651,29 +1651,34 @@ See the sections below on the `egg_info`_ and `alias`_ commands for more ideas. -Distributing Extensions compiled with Pyrex -------------------------------------------- +Distributing Extensions compiled with Cython +-------------------------------------------- -``setuptools`` includes transparent support for building Pyrex extensions, as -long as you define your extensions using ``setuptools.Extension``, *not* -``distutils.Extension``. You must also not import anything from Pyrex in -your setup script. +``setuptools`` will detect at build time whether Cython is installed or not. +If Cython is not found ``setputools`` will ignore pyx files. In case it's +available you are supposed it will work with just a couple of adjustments. +``setuptools`` includes transparent support for building Cython extensions, as +long as you define your extensions using ``setuptools.Extension``. +Then you should use Cython own ``build_ext`` in ``cmdclass``, e.g.:: + + from Cython.Distutils import build_ext + + setup(... + cmdclass={"build_ext": build_ext} + ...) If you follow these rules, you can safely list ``.pyx`` files as the source -of your ``Extension`` objects in the setup script. ``setuptools`` will detect -at build time whether Pyrex is installed or not. If it is, then ``setuptools`` -will use it. If not, then ``setuptools`` will silently change the -``Extension`` objects to refer to the ``.c`` counterparts of the ``.pyx`` -files, so that the normal distutils C compilation process will occur. +of your ``Extension`` objects in the setup script. If it is, then ``setuptools`` +will use it. Of course, for this to work, your source distributions must include the C -code generated by Pyrex, as well as your original ``.pyx`` files. This means +code generated by Cython, as well as your original ``.pyx`` files. This means that you will probably want to include current ``.c`` files in your revision control system, rebuilding them whenever you check changes in for the ``.pyx`` source files. This will ensure that people tracking your project in a revision -control system will be able to build it even if they don't have Pyrex +control system will be able to build it even if they don't have Cython installed, and that your source releases will be similarly usable with or -without Pyrex. +without Cython. ----------------- |