setup.py 2.4 KB
Newer Older
Y
Yibing Liu 已提交
1
#  Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Y
Yibing Liu 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
Y
Yibing Liu 已提交
16
import glob
Y
Yibing Liu 已提交
17 18 19
from distutils.core import setup, Extension
from distutils.sysconfig import get_config_vars

20 21 22 23 24 25
try:
    kaldi_root = os.environ['KALDI_ROOT']
except:
    raise ValueError("Enviroment variable 'KALDI_ROOT' is not defined. Please "
                     "install kaldi and export KALDI_ROOT=<kaldi's root dir> .")

Y
Yibing Liu 已提交
26
args = [
27
    '-std=c++11', '-fopenmp', '-Wno-sign-compare', '-Wno-unused-variable',
Y
Yibing Liu 已提交
28 29 30
    '-Wno-unused-local-typedefs', '-Wno-unused-but-set-variable',
    '-Wno-deprecated-declarations', '-Wno-unused-function'
]
Y
Yibing Liu 已提交
31 32 33 34 35

# remove warning about -Wstrict-prototypes
(opt, ) = get_config_vars('OPT')
os.environ['OPT'] = " ".join(flag for flag in opt.split()
                             if flag != '-Wstrict-prototypes')
Y
Yibing Liu 已提交
36 37 38 39 40 41 42 43
os.environ['CC'] = 'g++'

LIBS = [
    'fst', 'kaldi-base', 'kaldi-util', 'kaldi-matrix', 'kaldi-tree',
    'kaldi-hmm', 'kaldi-fstext', 'kaldi-decoder', 'kaldi-lat'
]

LIB_DIRS = [
44 45
    'tools/openfst/lib', 'src/base', 'src/matrix', 'src/util', 'src/tree',
    'src/hmm', 'src/fstext', 'src/decoder', 'src/lat'
Y
Yibing Liu 已提交
46
]
47
LIB_DIRS = [os.path.join(kaldi_root, path) for path in LIB_DIRS]
Y
Yibing Liu 已提交
48
LIB_DIRS = [os.path.abspath(path) for path in LIB_DIRS]
Y
Yibing Liu 已提交
49 50 51

ext_modules = [
    Extension(
Y
Yibing Liu 已提交
52 53
        'post_latgen_faster_mapped',
        ['pybind.cc', 'post_latgen_faster_mapped.cc'],
Y
Yibing Liu 已提交
54
        include_dirs=[
55
            'pybind11/include', '.', os.path.join(kaldi_root, 'src'),
56
            os.path.join(kaldi_root, 'tools/openfst/src/include'), 'ThreadPool'
Y
Yibing Liu 已提交
57
        ],
Y
Yibing Liu 已提交
58
        language='c++',
59
        libraries=LIBS,
Y
Yibing Liu 已提交
60 61
        library_dirs=LIB_DIRS,
        runtime_library_dirs=LIB_DIRS,
Y
Yibing Liu 已提交
62 63 64 65
        extra_compile_args=args, ),
]

setup(
Y
Yibing Liu 已提交
66 67
    name='post_latgen_faster_mapped',
    version='0.1.0',
Y
Yibing Liu 已提交
68 69 70 71
    author='Paddle',
    author_email='',
    description='Decoder for Deep ASR model',
    ext_modules=ext_modules, )