author | Tero Marttila <terom@fixme.fi> |
Wed, 27 Jan 2010 02:18:58 +0200 | |
changeset 126 | 2e0f7cbe528f |
parent 117 | 2da34e3aa885 |
child 132 | 0260aeca943c |
permissions | -rw-r--r-- |
30 | 1 |
from distutils.core import setup |
2 |
from distutils.extension import Extension |
|
117
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
3 |
|
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
4 |
import os.path |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
5 |
|
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
6 |
build_root = os.path.abspath(os.path.dirname(__file__)) |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
7 |
|
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
8 |
pypngtile_c = "python/pypngtile.c" |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
9 |
pypngtile_name = "python/pypngtile.pyx" |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
10 |
|
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
11 |
cmdclass = dict() |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
12 |
|
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
13 |
try : |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
14 |
from Cython.Distutils import build_ext |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
15 |
|
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
16 |
cmdclass['build_ext'] = build_ext |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
17 |
|
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
18 |
except ImportError : |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
19 |
path = os.path.join(build_root, pypngtile_c) |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
20 |
|
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
21 |
if os.path.exists(path) : |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
22 |
print "Warning: falling back from .pyx -> .c due to missing Cython" |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
23 |
# just use the .c |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
24 |
pypngtile_name = pypngtile_c |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
25 |
|
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
26 |
else : |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
27 |
# fail |
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
28 |
raise |
30 | 29 |
|
30 |
setup( |
|
31 |
name = 'pngtiles', |
|
117
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
32 |
cmdclass = cmdclass, |
30 | 33 |
ext_modules = [ |
117
2da34e3aa885
setup.py: fallback to .c if we don't have Cython
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
34 |
Extension("pypngtile", [pypngtile_name], |
30 | 35 |
include_dirs = ['include'], |
36 |
library_dirs = ['lib'], |
|
37 |
libraries = ['pngtile'], |
|
38 |
), |
|
39 |
], |
|
40 |
) |
|
41 |