29 Apr 2012 02:06
Re: Building distutils setup.py to find PXD files for Pure Python file
Ian Bell <ian.h.bell <at> gmail.com>
2012-04-29 00:06:45 GMT
2012-04-29 00:06:45 GMT
On Sun, Apr 29, 2012 at 12:20 AM, mark florisson <markflorisson88 <at> gmail.com> wrote:
Interestingly, if I use Cython.Distutils.extension.Extension but leave the extension module name as example (see setup4.py below), it doesn't include the PXD file.
But if I change the module name to integrate_py in setup.py(as below), it does work and finds the PXD file properly. The file I list below for setup.py DOES work, either using
from distutils.core import Extension
or
from Cython.Distutils.extension import Extension. I would argue this is a bug, or at worst should spit out a warning at build time. It is quite unexpected behavior, especially considering the documentation of pure Python mode in the docs online.
#### setup.py #####
from distutils.core import setup,Extension
from Cython.Distutils import build_ext
#Note: the name of the module MUST be the same as the name of the pure Python file
ext_modules = [Extension("integrate_py", ["integrate_py.py"])]
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
#### setup4.py #####
#NB: This code doesn't include the PXD properly
from distutils.core import setup
from Cython.Distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("example", ["integrate_py.py"])]
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
Have you tried using Cython.Distutils.extension.Extension instead ofOn 27 April 2012 14:03, Ian Bell <ian.h.bell <at> gmail.com> wrote:
> Stefan,
>
>>
>> In any case, the new and preferred way is described here:
>>
>> http://wiki.cython.org/enhancements/distutils_preprocessing
>>
>> And, yes, it would be good to visibly present this in the documentation.
>> The build documentation is mostly ok but lacks this feature:
>>
>> http://docs.cython.org/src/userguide/source_files_and_compilation.html
>>
> The build docs are in good shape - lots of useful information, but from
> browsing the mailing lists, seems like quite a few people are having varied
> issues with PXD files and distutils. Would be great to have a (nominally)
> working example in the documentation online and/or a downloadable version.
> Also, an example of getting Cython distutils parameters would be great.
>
> Just for fun, tried a new setup.py file, like the link you recommended using
> cythonize. Works a charm. Weird. I think I am in business for now. Thanks
> for your help and patience.
>
> So it seems that cythonize does something slightly different than the Cython
> build_ext command. I suppose this shouldn't be the expected behavior?
>
> Cheers,
> Ian
>
> ##### setup2.py #######
> from distutils.core import setup
> from Cython.Build import cythonize
>
> setup(
> name = 'MyProject',
> ext_modules = cythonize(["integrate_py.py"]),
> )
distutils' Extension class?
Interestingly, if I use Cython.Distutils.extension.Extension but leave the extension module name as example (see setup4.py below), it doesn't include the PXD file.
But if I change the module name to integrate_py in setup.py(as below), it does work and finds the PXD file properly. The file I list below for setup.py DOES work, either using
from distutils.core import Extension
or
from Cython.Distutils.extension import Extension. I would argue this is a bug, or at worst should spit out a warning at build time. It is quite unexpected behavior, especially considering the documentation of pure Python mode in the docs online.
#### setup.py #####
from distutils.core import setup,Extension
from Cython.Distutils import build_ext
#Note: the name of the module MUST be the same as the name of the pure Python file
ext_modules = [Extension("integrate_py", ["integrate_py.py"])]
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
#### setup4.py #####
#NB: This code doesn't include the PXD properly
from distutils.core import setup
from Cython.Distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("example", ["integrate_py.py"])]
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
RSS Feed