Created
May 24, 2013 23:37
-
-
Save bsmithyman/5647232 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
amodulename = 'modulename' | |
try: | |
import pyximport | |
pyximport.install() | |
except: | |
print('Cython import failed; {0} will use the legacy (pure Python) mode.'.format(amodulename)) | |
from modulenamevanilla import class1, class2, class3 | |
else: | |
try: | |
from modulename import class1, class2, class3 | |
except ImportError: | |
print('Could not build/import {0}.pyx; {0} will use the legacy (pure Python) mode.'.format(amodulename)) | |
from modulenamevanilla import class1, class2, class3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the magic ingredient to make your Cython module compile automatically when imported (with a pure-Python fallback).