setup.py
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--
remove print output
30
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
from distutils.core import setup
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     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
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
setup(
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    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
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    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
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
            include_dirs = ['include'],
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
            library_dirs = ['lib'],
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
            libraries = ['pngtile'],
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
        ),
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
    ],
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
)
53e99e552122 move the python/web code in
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41