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?
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
Assuming that you already have setuptools installed, Edit setup.py of the egg package target and replace the import setup, Extension
in order to get them from setuptools.
from setuptools import setup, Extension, Command
Rational: setuptools redefines Extension
so it's possible that it does not recognize the object that you have in the ext_modules argument as a valid Extension object. Hence the error message.
ext_modules is one of the arguments of setup() method that describe the extension of your module, and it's specified in setup.py.
setup(name='foo', version='1.0', ext_modules=[Extension('foo', ['foo.c'])], )
More info available in Python documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With