summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2012-01-05 18:37:09 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2012-01-05 18:37:09 +0000
commit3cdd7e583a7b4030485903fcd0365ec22ec4edfb (patch)
treea12eac69aacfdd85a0bc9741738f02bcde4e4686
parenta5ffe7ceeca6a1f4c73d2963fc3e34fe44a2348c (diff)
downloadpysendfile-3cdd7e583a7b4030485903fcd0365ec22ec4edfb.tar.gz
instead of attempting to import the module in setup.pt to figure out whether the platform is supported, use #error pre processor directive in the C code
-rw-r--r--sendfilemodule.c21
-rw-r--r--setup.py11
2 files changed, 14 insertions, 18 deletions
diff --git a/sendfilemodule.c b/sendfilemodule.c
index c6efd02..d0b643a 100644
--- a/sendfilemodule.c
+++ b/sendfilemodule.c
@@ -43,6 +43,16 @@
#include <Python.h>
#include <stdlib.h>
+// force a compilation error if platform is not supported
+#if !defined(__FreeBSD__) && \
+ !defined(__DragonFly__) && \
+ !defined(__APPLE__) && \
+ !defined(_AIX) && \
+ !defined(__linux__) && \
+ !defined(__sun)
+#error platfom not supported
+#endif
+
static int
_parse_off_t(PyObject* arg, void* addr)
{
@@ -291,15 +301,10 @@ method_sendfile(PyObject *self, PyObject *args, PyObject *kwdict)
#else
/* --- end SUN OS --- */
-/* --- being not supported --- */
-static PyObject *
-method_sendfile(PyObject *self, PyObject *args)
-{
- PyErr_SetString(PyExc_NotImplementedError, "platform not supported");
- return NULL;
-}
+#error platfom not supported
+
#endif
-/* --- end not supported --- */
+
static PyMethodDef
diff --git a/setup.py b/setup.py
index 66feeba..4bef8b9 100644
--- a/setup.py
+++ b/setup.py
@@ -53,16 +53,7 @@ def main():
ext_modules = [Extension('sendfile',
sources=['sendfilemodule.c'],
libraries=libraries)],
- )
- # check for NotImplementedError exception if platform is not supported
- import sendfile
- try:
- sendfile.sendfile(0, 0, 0, 0)
- except NotImplementedError:
- raise NotImplementedError("platform %r not supported" % sys.platform)
- except:
- pass
-
+ )
if __name__ == '__main__':
main()