Cpyx

An utility script to automatically run Cython and GCC
Download

Cpyx Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Other/Proprietary Li...
  • Price:
  • FREE
  • Publisher Name:
  • David N. Mashburn

Cpyx Tags


Cpyx Description

Cpyx is a Python utility script to automatically run Cython and GCC with support for numpy. It can also run inlined Cython code from within Python via an import mechanism (see CythonInlineTest.py). I find this immensely helpful for testing simple Cython code, especially when using a GUI shell like PySlices or DreamPie.The three core functions in Cpyx are Cdll, Cpyx, and CpyxLib. Cdll is a simple gcc frontend, Cpyx runs cython and then compiles the c output, and CpyxLib compiles a .pyx file and links in an external .c file (useful when wrapping a single C source with Cython). CythonInline directly compiles Cython code passed as a string (by generating a temp file and running Cpyx) and returns the python call to "import \*" the resulting module. Calling exec() will run the code inline (see CythonInlineTest.py).For standard (non-inline) usage, if the directory is not set in the input file, Cpyx looks for the environment variable 'MYPYREX' and falls back to the current directory. Correct file extensions (.pyx and .c) are assumed, so you can leave them off and they are automatically inserted. With this in mind, calls to Cpyx can be very compact, i.e.:Cpyx('CythonModule')This compiles CythonModule.pyx to CythonModule.c and then to CythonModule.dll or libCythonModule.so.By default, Cpyx makes direct system calls to Cython and gcc, with switches for the 3 different major OS's (Windows, Linux, Mac). Still, some aspects of the paths are hard-coded, so you may have problems if cython or gcc (or libpython) in a non-standard place. If this happens and Cpyx fails, you can either place a link to the real file in the spot Cpyx was looking for it in or just go into Cpyx.py and edit the paths at the top to match yours (just make sure you are looking at the right OS).Also, Cpyx is quite verbose, outputting each command in sequence. So, you can also copy and manually run/modify the compiler commands in cmd/sh if you need to (and/or change the options inside Cdll/Cpyx/CpyxLib). This way even if Cpyx doesn't quite work, maybe you can use it to help you learn how to use cython and gcc ;) Cpyx is quite simple (the 3 main functions are Product's homepage


Cpyx Related Software