USAGE.txt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. Cython - Usage Instructions
  2. ==========================
  3. Building Cython extensions using distutils
  4. -----------------------------------------
  5. Cython comes with an experimental distutils extension for compiling
  6. Cython modules, contributed by Graham Fawcett of the University of
  7. Windsor (fawcett@uwindsor.ca).
  8. The Demos directory contains a setup.py file demonstrating its use. To
  9. compile the demos:
  10. (1) cd Demos
  11. (2) python setup.py build_ext --inplace
  12. or
  13. python setup.py build --build-lib=.
  14. (You may get a screed of warnings from the C compiler, but you can
  15. ignore these -- as long as there are no actual errors, things are
  16. probably okay.)
  17. Try out the extensions with:
  18. python run_primes.py
  19. python run_spam.py
  20. python run_numeric_demo.py
  21. Building Cython extensions by hand
  22. ---------------------------------
  23. You can also invoke the Cython compiler on its own to translate a .pyx
  24. file to a .c file. On Unix,
  25. cython filename.pyx
  26. On other platforms,
  27. python cython.py filename.pyx
  28. It's then up to you to compile and link the .c file using whatever
  29. procedure is appropriate for your platform. The file
  30. Makefile.nodistutils in the Demos directory shows how to do this for
  31. one particular Unix system.
  32. Command line options
  33. --------------------
  34. The cython command supports the following options:
  35. Short Long Argument Description
  36. -----------------------------------------------------------------------------
  37. -v --version Display version number of cython compiler
  38. -l --create-listing Write error messages to a .lis file
  39. -I --include-dir <directory> Search for include files in named
  40. directory (may be repeated)
  41. -o --output-file <filename> Specify name of generated C file (only
  42. one source file allowed if this is used)
  43. -p, --embed-positions If specified, the positions in Cython files of each
  44. function definition is embedded in its docstring.
  45. -z, --pre-import <module> If specified, assume undeclared names in this
  46. module. Emulates the behavior of putting
  47. "from <module> import *" at the top of the file.
  48. Anything else is taken as the name of a Cython source file and compiled
  49. to a C source file. Multiple Cython source files can be specified
  50. (unless -o is used), in which case each source file is treated as the
  51. source of a distinct extension module and compiled separately to
  52. produce its own C file.