Chris Colbert wrote:
> so, what would the setup script look like for something like this?
>
> if i do:
>
> sources = ['file1.pyx', 'file2.pyx', ... ]
>
> setup(
> cmdclass = {'build_ext': build_ext},
> ext_modules = [Extension("mymodule", sourcefiles,
> include_dirs=include_dirs,
> library_dirs=library_dirs,
> libraries = libraries)])
>
> it fails.
>
> but if i build each module separately, everything works. i.e.:
>
> sources = ['file1.pyx']
>
> setup(
> cmdclass = {'build_ext': build_ext},
> ext_modules = [Extension("mymodule1", sourcefiles,
> include_dirs=include_dirs,
> library_dirs=library_dirs,
> libraries = libraries)])
>
> ^^^repeat the above for each module.
>
>
> What I want to be able to do, is have all of my multiple .pyx and .pxd
> files compiled and built into a single .pyd
>
> Is that possible?
>
each .pyx defines a module (name), so how do you want to address
that stuff consistently?
Why not merge the 2 .pyx (and .pxd) in the first place in one
module? Or make a package dir with a __init__.py which merges with
from ... import * ?
But just for fun its possible to squeeze 2 pyx modules it one DLL:
say modules a.pyx/a.c and b.pyx/b.c
#in a.pyx add (Python2.x):
cdef extern from *:
void initb()
def loadmod_b():
initb()
##exec "from b import *" in globals()
##loadmod_b()
#cython both, :
#in b.c edit (cython forgot a 'static'):
const char *__pyx_modulename = "b";
->
static const char *__pyx_modulename = "b";
#then on e.g. Windows/MingW do like
gcc -mno-cygwin -O -IC:\Python26\include -g a.c b.c -shared
-mno-cygwin -LC:\Python26\libs -lpython26 -lmsvcr90 -o a.pyd
# then you can import a, and let a.loadmod_b() initialize your
module b
then you can 'import b' from everywhere too...
Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev