On Thu, Jan 31, 2013 at 4:01 AM, Matthew Honnibal <
honn...@gmail.com> wrote:
> I've been using Cython as the main development language for a small project
> (an English statistical parser), about 2000 lines of code. Currently my
> build system is an ugly mix of make and setup scripts, and I'm confused
> about how to best build a package that has several Cython modules.
yeah, I'd try to clean that up!
> 1) When I have multiple Cython modules in a single package, can I use a
> single setup script?
yes.
> What if one of the modules uses different C/C++
> extensions?
yes.
How are you linking the C++ == where it got tricky for us was we had a
bunch of C++ that many of the cython modules have to link to -- we
found that we had to do this quite differently on Windows and OS-X
(haven't tested, but I suspect Linux would be like OS-X)
> If someone has an example
> package with multiple Cython modules that would be great.
enclosed -- a bit ugly, but it all gets built with one setup.py
(except he Windows DLL, which is build independently, though called
from the setup.py)
> the pandas code, but had trouble understanding it, as it involves
> subclassing Extension in a pretty complicated way.
we avoided that.
> 2) Can I have the generated .cpp files sit in some subdirectory, such as
> src, rather than in the main package folder?
I don't think so -- at least not easily.
> What's the best practice for
> directory structure in general?
for Cython, the *.pyx, *.pyd files in dirs that mimic your package
stucture -- jsut like python files would (even though there are more
of them) and the generated *.c or *.cpp get laid in next to them.
> 3) What's the best way to setup other packages that a main package depends
> on? Are general-purpose build tools such as make the best system for this?
if you mean python/cython packages, then, no I wouldn't use make --
stick with distutils. If you mean other, non-python dependencies, then
whatever the native system is (i.e. make on *nix)
> Also, I found that distutils' "clean" wasn't wiping the Cython-generated cpp
> files, which was further incentive to use make.
yeah, distuils "clean" is not so smart -- we hand-wrote a "cleanall"
for that reason -- hacky, but pretty easy.
> 4) I wanted to name two modules "io" and "state", but this caused a
> namespace clash. Is there a good work-around, or should I settle for
> renaming the modules?
what was the clash? If you put them in a package, it shouldn't be an
issue if they match std lib names. Though you probably don't want to
re-use common stdlib names anyway.
HTH,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R
(206) 526-6959 voice
7600 Sand Point Way NE
(206) 526-6329 fax
Seattle, WA 98115
(206) 526-6317 main reception
Chris....@noaa.gov