Can I configure pydev to automatically compile cython files?

I just pick up Cython. I use it to create a base library in my Python project. I have currently configured the file setup.pywith distutilsand am running the following command when I want to recompile the Cython file:

python ./setup.py build_ext --inplace

However, I often forget. I love how Eclipse automatically creates class files for Java every time I edit / save. Is it possible to configure similar behavior for PyDev, Eclipse, or some other smart way?

+5
source share
2 answers

PyDev cython ... , :

project > properties > builders > new > program, python, ${build_files}.

, , - .pyx, , - , , .

+5

cython "magic" sitecustomize.py PYTHONPATH, pyximport, (, , mingw), :

import pyximport
import os
import numpy
#import cython
import Cython.Compiler.Options as Options
Options.cimport_from_pyx = True

if os.name == 'nt':
    if os.environ.has_key('CPATH'):
        os.environ['CPATH'] = os.environ['CPATH'] + numpy.get_include()
    else:
        os.environ['CPATH'] = numpy.get_include()

    # XXX: we're assuming that MinGW is installed in C:\MinGW (default)
    if os.environ.has_key('PATH'):
        os.environ['PATH'] = os.environ['PATH'] + ';C:\MinGW\bin'
    else:
        os.environ['PATH'] = 'C:\MinGW\bin'

    mingw_setup_args = { 'options': { 'build_ext': { 'compiler': 'mingw32' } } }
    pyximport.install(setup_args=mingw_setup_args)
elif os.name == 'posix':
    if os.environ.has_key('CFLAGS'):
        os.environ['CFLAGS'] = os.environ['CFLAGS'] + ' -I' + numpy.get_include()
    else:
        os.environ['CFLAGS'] = ' -I' + numpy.get_include()

    pyximport.install()

pyximport.DEBUG_IMPORT = True

, , , cython mingw.

*.pyx . : , Pydev .

+1

All Articles