How to create Python module distribution to gracefully fall-back to pure Python code
Posted
by Craig McQueen
on Stack Overflow
See other posts from Stack Overflow
or by Craig McQueen
Published on 2010-03-08T00:50:52Z
Indexed on
2010/03/08
0:52 UTC
Read the original article
Hit count: 742
python
|software-distribution
I have written a Python module, and I have two versions: a pure Python implementation and a C extension. I've written the __init__.py file so that it tries to import the C extension, and if that fails, it imports the pure Python code (is that reasonable?).
Now, I'd like to know what is the best way to distribute this module (e.g. write setup.py) so it can be easily used by people with or without the facility to build, or use, the C extension. My experience is limited but I see two possible cases:
- User does not have MS Visual Studio, or the GCC compiler suite, installed on their machine, to build the C extension
- User is running IronPython, Jython, or anything other than CPython. I only have used CPython. So I'm not sure how I could distribute this module so that it would work smoothly and be easy to install on those platforms, if they're unable to use the C extension.
© Stack Overflow or respective owner