public api in a sub package

14 views
Skip to first unread message

gary thompson

unread,
Mar 23, 2015, 3:33:37 AM3/23/15
to cython...@googlegroups.com
Dear All

I am having a problem with exporting a public  api with the right package loading code

specifically I have something like the following in setup.py


ext_modules = [Extension("yy.xx",  ['yy.xx.pyx'],
                         define_macros = [('CPLUSPLUS', '1') ,
                                          ('USE_CDS_NAMESPACE', '1') ,
                                          ('OLD_ENSEMBLE_INTERFACE',old_ensemble_interface)],

                         language="c++",
                         extra_compile_args=extra_compile_args,
                         extra_link_args=extra_link_args,
                         include_dirs=include_dirs)]

setup(
    package_dir = {'yy':''},
    ext_modules=cythonize(ext_modules[0:1]),
    cmdclass = {'build_ext': build_ext},
)


and yy.xx.py has 

cdef public api double zz(object self, int i, ...):

..... some very interesting cython code

now when I do the build everything cython goes in the right pace and looks good (ie we have a yy directory with an xx in it

Howvere, now I expect to have a file called


yy.xx_api.h but I am just getting a file called xx_api.h furthermore inside I get

import_xx() 

not 

import_yy__xx()

could someone tell me what I am doing wrong and how to solve it?

regards

gary






Stefan Behnel

unread,
Mar 25, 2015, 4:18:54 AM3/25/15
to cython...@googlegroups.com
gary thompson schrieb am 22.03.2015 um 23:10:
> I am having a problem with exporting a public api with the right package
> loading code
>
> specifically I have something like the following in setup.py
>
>
> ext_modules = [Extension("yy.xx", ['yy.xx.pyx'],
> define_macros = [('CPLUSPLUS', '1') ,
> ('USE_CDS_NAMESPACE', '1') ,
>
> ('OLD_ENSEMBLE_INTERFACE',old_ensemble_interface)],
>
> language="c++",
> extra_compile_args=extra_compile_args,
> extra_link_args=extra_link_args,
> include_dirs=include_dirs)]
>
> setup(
> package_dir = {'yy':''},
> ext_modules=cythonize(ext_modules[0:1]),
> cmdclass = {'build_ext': build_ext},
> )
>
>
> and yy.xx.py has
>
> cdef public api double zz(object *self*, int i, ...):
>
> ..... some very interesting cython code
>
> now when I do the build everything cython goes in the right pace and looks
> good (ie we have a yy directory with an xx in it
>
> Howvere, now I expect to have a file called
>
> yy.xx_api.h but I am just getting a file called xx_api.h

That's how it currently works.


> furthermore inside I get
>
> import_xx()
>
> not
>
> import_yy__xx()

And that's, well, less intentional. ;)

The reason is (I think) that your module does not live in a package. If you
create a folder "yy" and a file "yy/__init__.py" and then move your code
file into that folder, it should work.

Stefan

Reply all
Reply to author
Forward
0 new messages