The latest Cython sources have a "cythonrun" script that does what you
want. We considered merging it into the main "cython" script, but that
hasn't been done yet.
https://github.com/cython/cython/blob/master/bin/cythonrun
Stefan
Sure. We take patches.
> * It seems to ignore the setup.py file (?);
Using a "setup.py" doesn't make sense for a module on the PYTHONPATH, so
that's a contradicting goal.
> then how would I specify
> e.g. include_dirs and library_dirs?
According to the source code (hint, hint), you can at least pass CFLAGS.
Don't think there's currently a way to pass external libraries.
Stefan
If you're not doing something too complicated,
from distutils.core import setup
from Cython.Build import cythonize
setup(
name = 'MyProject',
ext_modules = cythonize(["*.pyx"]),
)
could be the only setup.py file you'd ever need.
>> > then how would I specify
>> > e.g. include_dirs and library_dirs?
In your .pyx file you can do
# distutils: include_dirs = /opt/food/include
if needed. See http://wiki.cython.org/enhancements/distutils_preprocessing
>> According to the source code (hint, hint),
>
> Please understand that I do put in quite a lot of googling, reading
> docstrings, and also looking at source code before bothering the list
> with questions. (Digression: My only experience with CFLAGS comes from
> following other people's installation instructions, and both CFLAGS,
> include_dirs and library_dirs look like voodoo from my point of
> vantage.) I represent the user who is quite skilled in pure Python and
> high-level scientific computing, and is using Cython to minimize my
> dealings with the intricacies of C. I think this is an important
> market segment for Cython, but users are likely to be alienated by
> admonishments for not knowing how to debug C compilation.
If you're just using Cython, you don't need to worry about details
like this. It's only when trying to interface with C libraries that
you have to know a bit about C compilation, and there's not much we
can do to avoid that.
- Robert
That would be nice. How about this:
diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py
index db765e3..ac21f74 100644
--- a/Cython/Compiler/Main.py
+++ b/Cython/Compiler/Main.py
@@ -647,6 +647,11 @@ def setuptools_main():
def main(command_line = 0):
args = sys.argv[1:]
any_failures = 0
+
+ if sys.argv[1] == "run":
+ from Cython.Build.BuildExecutable import build_and_run
+ return build_and_run(sys.argv[2:])
+
if command_line:
from CmdLine import parse_command_line
options, sources = parse_command_line(args)
That doesn't add anything to the current interface, though. The idea is
rather to support the "-m" switch in the same way CPython does, so that you
can just say "cython -m somemodule", and have it find the module in the
PYTHONPATH, etc.
Stefan