Skip to content

Commit

Permalink
Fixed setup.py so it works on Raspbian Stretch/Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
nmctseb committed Oct 31, 2017
1 parent 82b2002 commit c178c3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/Python3/snowboydecoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import collections
import pyaudio
import snowboydetect
from . import snowboydetect
import time
import wave
import os
Expand Down
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import os
import sys
from setuptools import setup, find_packages
from distutils.command.build import build
from distutils.dir_util import copy_tree
from subprocess import call


py_dir = 'Python' if sys.version_info[0] < 3 else 'Python3'

class SnowboyBuild(build):

def run(self):

cmd = ['make']

swig_dir = os.path.join('swig', py_dir)
def compile():
call(cmd, cwd='swig/Python')
call(cmd, cwd=swig_dir)

self.execute(compile, [], 'Compiling snowboy...')

# copy generated .so to build folder
self.mkpath(self.build_lib)
snowboy_build_lib = os.path.join(self.build_lib, 'snowboy')
self.mkpath(snowboy_build_lib)
target_file = 'swig/Python/_snowboydetect.so'
target_file = os.path.join(swig_dir, '_snowboydetect.so')
if not self.dry_run:
self.copy_file(target_file,
snowboy_build_lib)
Expand All @@ -42,8 +45,8 @@ def compile():
maintainer_email='[email protected]',
license='Apache-2.0',
url='https://snowboy.kitt.ai',
packages=find_packages('examples/Python/'),
package_dir={'snowboy': 'examples/Python/'},
packages=find_packages(os.path.join('examples', py_dir)),
package_dir={'snowboy': os.path.join('examples', py_dir)},
py_modules=['snowboy.snowboydecoder', 'snowboy.snowboydetect'],
package_data={'snowboy': ['resources/*']},
zip_safe=False,
Expand Down

0 comments on commit c178c3c

Please sign in to comment.