Guy Blanc
Guy Blanc

Reputation: 861

Errors when compiling first cython program

I am trying to start using cython and and attempting to compile my first program. I have created a hello.pyx with the following code:

def show():
    print ("Hello World")

and a setup.py with the folowing code:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

ext_modules = [Extension("hello", ["hello.pyx"])]

setup(
    name = 'Hello world app',
    cmdclass = {'build_ext': build_ext},
    ext_modules = ext_modules
)

both in a folder that I called "cython programs" which is at C:\Python32\cython programs. Cython is at C:\Python32\Lib\site-packages\Cython. However, when I run setup.py I get the following error:

Traceback (most recent call last):
  File "C:\Python32\cython programs\setup.py", line 10, in <module>
    ext_modules = ext_modules
  File "C:\Python32\lib\distutils\core.py", line 136, in setup
    raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied

I'm guessing that I am missing something very simple but I can't seem to figure out what it is. Any help would be appreciated.

Upvotes: 4

Views: 7948

Answers (2)

Henry Gomersall
Henry Gomersall

Reputation: 8692

Run python setup.py build_ext. That works for me.

Upvotes: 5

user590028
user590028

Reputation: 11730

I'm taking a wild guess here...but I think it's the space in your directory name. I just spent a few minutes googling Cython & Distutils because I seem to recall one of the recommending you not use space in directory names when using them on Windows -- but I wasn't able to find the link I was looking for.

Try a quick test and just rename your 'cython programs' to 'cythonprograms' and see what happens.

Upvotes: 0

Related Questions