2
# build script for 'ecbufr' - Python libecbufr wrapper
5
from distutils.core import setup
6
from distutils.extension import Extension
8
libecbufrDir = os.path.dirname(os.getcwd())
9
libecbufrDir = os.path.dirname(libecbufrDir)
10
libecbufrIncludeDir = libecbufrDir + "/API/Headers"
11
libecbufrLibDir = libecbufrDir + "/API/Sources/.libs"
13
# we'd better have Cython installed, or it's a no-go
15
from Cython.Distutils import build_ext
17
print("libecbufr directory:", libecbufrDir )
18
print("You don't seem to have Cython installed. Please get a")
19
print("copy from www.cython.org and install it")
23
# scan the 'ecbufr' directory for extension files, converting
24
# them to extension names in dotted notation
25
def scandir(dir, files=[]):
26
for file in os.listdir(dir):
27
path = os.path.join(dir, file)
28
if os.path.isfile(path) and path.endswith(".pyx"):
29
files.append(path.replace(os.path.sep, ".")[:-4])
30
elif os.path.isdir(path):
35
# generate an Extension object from its dotted name
36
def makeExtension(extName):
37
extPath = extName.replace(".", os.path.sep)+".pyx"
41
include_dirs = [libecbufrIncludeDir, "."], # adding the '.' to include_dirs is CRUCIAL!!
42
library_dirs = [libecbufrLibDir, "."], # adding the '.' to include_dirs is CRUCIAL!!
43
extra_compile_args = ["-fPIC", "-Wall"],
44
extra_link_args = ['-g'],
45
libraries = ["ecbufr",],
48
# get the list of extensions
49
extNames = scandir("ecbufr")
51
# and build up the set of Extension objects
52
extensions = [makeExtension(name) for name in extNames]
54
# finally, we can pass all this to distutils
58
ext_modules=extensions,
59
cmdclass = {'build_ext': build_ext},