error: each element of 'ext_modules' option must be an Extension instance or 2-tuple

python, setuptools

Solution

I had to reorder import statements to get rid of this error. This code generates the error:

from Cython.Build import cythonize
from setuptools import find_packages, setup

This code does not generate the error:

from setuptools import find_packages, setup
from Cython.Build import cythonize

Edit: This works because setuptools monkey-patches distutils, and setuptools must therefore be the first one to import distutils.

Problem

I am trying to use setuptools in python to create an egg package, but I get this weird error: ``` error: each element of 'ext_modules' option must be an Extension instance or 2-tuple ``` How can I fix this?

Original source