2017-05-02 10:41:59 +01:00
#! /usr/bin/env python
from setuptools import setup , Extension
from distutils . command . build import build
import os
import subprocess
2017-11-16 10:11:58 +01:00
import sys
2017-05-02 10:41:59 +01:00
2019-04-24 21:35:10 -03:00
def main ( ) :
2017-10-30 12:40:22 +01:00
try :
2019-04-24 21:35:10 -03:00
import numpy
try :
numpy_include = numpy . get_include ( )
except AttributeError :
numpy_include = numpy . get_numpy_include ( )
except ImportError :
numpy_include = ' '
assert ' NUMPY_INCLUDE ' in os . environ
def read ( fname ) :
return open ( os . path . join ( os . path . dirname ( __file__ ) , fname ) ) . read ( )
numpy_include = os . getenv ( ' NUMPY_INCLUDE ' , numpy_include )
numpy_min_ver = os . getenv ( ' NUMPY_DEP_VERSION ' , ' ' )
2020-08-25 15:37:58 +02:00
project_name = ' deepspeech '
2019-04-24 21:35:10 -03:00
if ' --project_name ' in sys . argv :
project_name_idx = sys . argv . index ( ' --project_name ' )
project_name = sys . argv [ project_name_idx + 1 ]
sys . argv . remove ( ' --project_name ' )
sys . argv . pop ( project_name_idx )
2020-08-25 15:36:22 +02:00
with open ( ' ../../training/deepspeech_training/VERSION ' , ' r ' ) as ver :
2019-04-24 21:35:10 -03:00
project_version = ver . read ( ) . strip ( )
class BuildExtFirst ( build ) :
sub_commands = [ ( ' build_ext ' , build . has_ext_modules ) ,
( ' build_py ' , build . has_pure_modules ) ,
( ' build_clib ' , build . has_c_libraries ) ,
( ' build_scripts ' , build . has_scripts ) ]
# Properly pass arguments for linking, setuptools will perform some checks
def lib_dirs_split ( a ) :
if os . name == ' posix ' :
return a . split ( ' -L ' ) [ 1 : ]
if os . name == ' nt ' :
return [ ]
raise AssertionError ( ' os.name == java not expected ' )
def libs_split ( a ) :
if os . name == ' posix ' :
return a . split ( ' -l ' ) [ 1 : ]
if os . name == ' nt ' :
return a . split ( ' .lib ' ) [ 0 : 1 ]
raise AssertionError ( ' os.name == java not expected ' )
2020-08-25 15:37:58 +02:00
ds_ext = Extension ( name = ' deepspeech._impl ' ,
2019-04-24 21:35:10 -03:00
sources = [ ' impl.i ' ] ,
include_dirs = [ numpy_include , ' ../ ' ] ,
library_dirs = list ( map ( lambda x : x . strip ( ) , lib_dirs_split ( os . getenv ( ' MODEL_LDFLAGS ' , ' ' ) ) ) ) ,
libraries = list ( map ( lambda x : x . strip ( ) , libs_split ( os . getenv ( ' MODEL_LIBS ' , ' ' ) ) ) ) ,
2020-02-18 12:15:23 +01:00
swig_opts = [ ' -c++ ' , ' -keyword ' ] )
2019-04-24 21:35:10 -03:00
setup ( name = project_name ,
2020-08-25 15:37:58 +02:00
description = ' A library for running inference on a DeepSpeech model ' ,
2019-12-06 17:33:00 +01:00
long_description = read ( ' README.rst ' ) ,
2019-10-02 16:37:47 +02:00
long_description_content_type = ' text/x-rst; charset=UTF-8 ' ,
2019-04-24 21:35:10 -03:00
author = ' Mozilla ' ,
version = project_version ,
2020-08-25 15:37:58 +02:00
package_dir = { ' deepspeech ' : ' . ' } ,
2019-04-24 21:35:10 -03:00
cmdclass = { ' build ' : BuildExtFirst } ,
license = ' MPL-2.0 ' ,
2020-08-25 15:35:12 +02:00
url = ' https://github.com/mozilla/DeepSpeech ' ,
2019-04-24 21:35:10 -03:00
project_urls = {
2020-08-25 15:35:12 +02:00
' Documentation ' : ' https://github.com/mozilla/DeepSpeech/tree/v {} #project-deepspeech ' . format ( project_version ) ,
' Tracker ' : ' https://github.com/mozilla/DeepSpeech/issues ' ,
' Repository ' : ' https://github.com/mozilla/DeepSpeech/tree/v {} ' . format ( project_version ) ,
' Discussions ' : ' https://discourse.mozilla.org/c/deep-speech ' ,
2019-04-24 21:35:10 -03:00
} ,
ext_modules = [ ds_ext ] ,
2020-08-25 15:37:58 +02:00
py_modules = [ ' deepspeech ' , ' deepspeech.client ' , ' deepspeech.impl ' ] ,
entry_points = { ' console_scripts ' : [ ' deepspeech=deepspeech.client:main ' ] } ,
2019-04-24 21:35:10 -03:00
install_requires = [ ' numpy %s ' % numpy_min_ver ] ,
include_package_data = True ,
classifiers = [
' Development Status :: 3 - Alpha ' ,
' Environment :: Console ' ,
' Intended Audience :: Developers ' ,
' Intended Audience :: Science/Research ' ,
' License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0) ' ,
' Programming Language :: Python :: 2.7 ' ,
' Programming Language :: Python :: 3.4 ' ,
' Programming Language :: Python :: 3.5 ' ,
' Programming Language :: Python :: 3.6 ' ,
' Topic :: Multimedia :: Sound/Audio :: Speech ' ,
' Topic :: Scientific/Engineering :: Human Machine Interfaces ' ,
' Topic :: Scientific/Engineering ' ,
' Topic :: Utilities ' ,
] )
if __name__ == ' __main__ ' :
main ( )