Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ bb473f6ff4a23e4fd5205eacdef713db15decadf
d6b447cab8c40aa47dc675a0f4349ae254e8b3ce
d8966d848af75751823e825eb76c5bbff58f5c07
4902d468c9606836b26b393379df4f49208ea847
1fd0ce6759be32be38bbfab32e83d157a82dfe25
2 changes: 1 addition & 1 deletion advanced/advanced_numpy/examples/mandel-answer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

cdef void mandel_single_point(double complex *z_in,
double complex *c_in,
double complex *z_out) nogil:
double complex *z_out) noexcept nogil:
#
# The Mandelbrot iteration
#
Expand Down
28 changes: 6 additions & 22 deletions advanced/advanced_numpy/examples/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,12 @@
C sources.
"""

import os
import sys
from os.path import join
from distutils.sysconfig import get_python_inc
from setuptools import setup, Extension
from Cython.Build import cythonize
import numpy
from numpy.distutils.misc_util import get_numpy_include_dirs

extensions = [
Extension("mandel", sources=["mandel.pyx"], include_dirs=[numpy.get_include()])
]

def configuration(parent_package="", top_path=None):
from numpy.distutils.misc_util import Configuration

for filename in ["mandel.so"]:
# make sure we don't have stale files lying around
if os.path.isfile(filename):
os.unlink(filename)

config = Configuration("", parent_package, top_path)
config.add_extension("mandel", sources=["mandel.c"])
return config


if __name__ == "__main__":
from numpy.distutils.core import setup

setup(**configuration(top_path="").todict())
setup(ext_modules=cythonize(extensions))
2 changes: 1 addition & 1 deletion advanced/advanced_numpy/examples/setup_myobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

"""

from distutils.core import setup, Extension
from setuptools import setup, Extension

setup(
name="myobject",
Expand Down
12 changes: 6 additions & 6 deletions advanced/interfacing_with_c/cython/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from distutils.core import setup, Extension
from Cython.Distutils import build_ext
from setuptools import setup, Extension
from Cython.Build import cythonize

setup(
cmdclass={"build_ext": build_ext},
ext_modules=[Extension("cos_module", ["cos_module.pyx"])],
)

extensions = [Extension("cos_module", sources=["cos_module.pyx"])]

setup(ext_modules=cythonize(extensions))
24 changes: 12 additions & 12 deletions advanced/interfacing_with_c/cython_numpy/setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from distutils.core import setup, Extension
from setuptools import setup, Extension
from Cython.Build import cythonize
import numpy
from Cython.Distutils import build_ext

setup(
cmdclass={"build_ext": build_ext},
ext_modules=[
Extension(
"cos_doubles",
sources=["_cos_doubles.pyx", "cos_doubles.c"],
include_dirs=[numpy.get_include()],
)
],
)

extensions = [
Extension(
"cos_doubles",
sources=["_cos_doubles.pyx", "cos_doubles.c"],
include_dirs=[numpy.get_include()],
)
]

setup(ext_modules=cythonize(extensions))
12 changes: 6 additions & 6 deletions advanced/interfacing_with_c/cython_simple/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from distutils.core import setup, Extension
from Cython.Distutils import build_ext
from setuptools import setup, Extension
from Cython.Build import cythonize

setup(
cmdclass={"build_ext": build_ext},
ext_modules=[Extension("cos_module", ["cos_module.pyx"])],
)

extensions = [Extension("cos_module", sources=["cos_module.pyx"])]

setup(ext_modules=cythonize(extensions))
20 changes: 10 additions & 10 deletions advanced/interfacing_with_c/interfacing_with_c.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ return types into place and for the module initialisation. Although some of
this is amortised, as the extension grows, the boilerplate required for each
function(s) remains.

The standard python build system ``distutils`` supports compiling C-extensions
from a ``setup.py``, which is rather convenient:
The standard python build system, ``setuptools``, supports compiling
C-extensions via a ``setup.py`` file:

.. literalinclude:: python_c_api/setup.py
:language: python

This can be compiled:
The setup file is called as follows:

.. sourcecode:: console

Expand Down Expand Up @@ -227,7 +227,7 @@ returns a resulting new array.
.. literalinclude:: numpy_c_api/cos_module_np.c
:language: c

To compile this we can use distutils again. However we need to be sure to
To compile this we can use ``setuptools`` again. However we need to be sure to
include the NumPy headers by using :func:`numpy.get_include`.

.. literalinclude:: numpy_c_api/setup.py
Expand Down Expand Up @@ -361,7 +361,7 @@ The function implementation resides in the following C source file:
.. literalinclude:: ctypes_numpy/cos_doubles.c
:language: c

And since the library is pure C, we can't use ``distutils`` to compile it, but
And since the library is pure C, we can't use ``setuptools`` to compile it, but
must use a combination of ``make`` and ``gcc``:

.. literalinclude:: ctypes_numpy/makefile
Expand Down Expand Up @@ -464,7 +464,7 @@ Generating the compiled wrappers is a two stage process:
module.

#. Compile the ``cos_module_wrap.c`` into the ``_cos_module.so``. Luckily,
``distutils`` knows how to handle SWIG interface files, so that our
``setuptools`` knows how to handle SWIG interface files, so that our
``setup.py`` is simply:

.. literalinclude:: swig/setup.py
Expand Down Expand Up @@ -576,7 +576,7 @@ file:
header, There is nothing there that we wish to expose to Python since we
expose the functionality through ``cos_doubles_func``.

And, as before we can use distutils to wrap this:
And, as before we can use ``setuptools`` to wrap this:

.. literalinclude:: swig_numpy/setup.py
:language: python
Expand Down Expand Up @@ -670,8 +670,8 @@ The main Cython code for our ``cos_module`` is contained in the file
Note the additional keywords such as ``cdef`` and ``extern``. Also the
``cos_func`` is then pure Python.

Again we can use the standard ``distutils`` module, but this time we need some
additional pieces from the ``Cython.Distutils``:
Again we can use the standard ``setuptools`` module, but this time we need some
additional pieces from ``Cython.Build``:

.. literalinclude:: cython/setup.py

Expand Down Expand Up @@ -774,7 +774,7 @@ This is wrapped as ``cos_doubles_func`` using the following Cython code:
.. literalinclude:: cython_numpy/_cos_doubles.pyx
:language: cython

And can be compiled using ``distutils``:
And can be compiled using ``setuptools``:

.. literalinclude:: cython_numpy/setup.py
:language: python
Expand Down
3 changes: 2 additions & 1 deletion advanced/interfacing_with_c/numpy_c_api/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from distutils.core import setup, Extension
from setuptools import setup, Extension
import numpy


# define the extension module
cos_module_np = Extension(
"cos_module_np", sources=["cos_module_np.c"], include_dirs=[numpy.get_include()]
Expand Down
3 changes: 2 additions & 1 deletion advanced/interfacing_with_c/python_c_api/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from distutils.core import setup, Extension
from setuptools import setup, Extension


# define the extension module
cos_module = Extension("cos_module", sources=["cos_module.c"])
Expand Down
3 changes: 2 additions & 1 deletion advanced/interfacing_with_c/swig/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from distutils.core import setup, Extension
from setuptools import setup, Extension


setup(ext_modules=[Extension("_cos_module", sources=["cos_module.c", "cos_module.i"])])
Loading