From 130ea121c19aa37bd0a6eab5b7cc9875a81c9edb Mon Sep 17 00:00:00 2001 From: Leonardo Sampaio Ferraz Ribeiro Date: Sat, 13 May 2017 02:07:05 -0300 Subject: [PATCH] Implemented setup.py that compiles python wrapper using Makefile --- .gitignore | 3 +++ MANIFEST.in | 7 +++++++ setup.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 MANIFEST.in create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 47e7afa4..c77a8087 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ Snowboy.pm /node_modules /lib/node/binding /lib/node/index.js + +/dist +**/snowboy.egg-info \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..4d620472 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,7 @@ +recursive-include examples/Python * +recursive-include include * +recursive-include lib * +recursive-include swig/Python * +include README.md + +exclude *.txt \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..82b2a937 --- /dev/null +++ b/setup.py @@ -0,0 +1,50 @@ +import os +from sys import platform +from setuptools import setup, find_packages +from setuptools.command.install import install +from distutils.command.build import build +from subprocess import call +from multiprocessing import cpu_count + + +class SnowboyBuild(build): + + def run(self): + + cmd = ['make'] + + def compile(): + call(cmd, cwd='swig/Python') + + self.execute(compile, [], 'Compiling snowboy') + + # copy generated .so to build folder + self.mkpath(self.build_lib) + target_file = os.path.join('swig/Python/_snowboydetect.so') + if not self.dry_run: + self.copy_file(target_file, self.build_lib) + + build.run(self) + + +setup( + name='snowboy', + version='0.1', + description='', + maintainer='', + maintainer_email='', + license='', + url='', + packages=find_packages('examples/Python/'), + package_dir={'snowboy': 'examples/Python/'}, + py_modules=['snowboy.snowboydecoder', 'snowboy.snowboydetect'], + include_package_data=True, + long_description="", + classifiers=[], + install_requires=[ + 'PyAudio', + ], + cmdclass={ + 'build': SnowboyBuild + } +)