11import os
22import platform
33from setuptools import setup
4- from setuptools .command .develop import develop
5- from setuptools .command .install import install
4+ from setuptools .command .build_ext import build_ext
65
76# "import" __version__
87__version__ = 'unknown'
3837 package_data = None
3938 zip_safe = True
4039
40+
41+ def post_install ():
42+ if system == 'Darwin' :
43+ # Bizarrely, on macOS, there doesn't seem to be another way to do this: you MUST use install_name_tool
44+ import subprocess
45+ # It could be either of these, so try both
46+ subprocess .run (["install_name_tool" , "-change" , "/usr/local/lib/libportaudio.dylib" , "@rpath/libportaudio.dylib" , "./_sounddevice.abi3.so" ])
47+ subprocess .run (["install_name_tool" , "-change" , "/usr/local/lib/libportaudio.2.dylib" , "@rpath/libportaudio.dylib" , "./_sounddevice.abi3.so" ])
48+
49+
4150try :
4251 from wheel .bdist_wheel import bdist_wheel
4352except ImportError :
@@ -60,32 +69,16 @@ def get_tag(self):
6069
6170 cmdclass = {'bdist_wheel' : bdist_wheel_half_pure }
6271
63- def post_install ():
64- if system == 'Darwin' :
65- # Bizarrely, on macOS, there doesn't seem to be another way to do this: you MUST use install_name_tool
66- import subprocess
67- # It could be either of these, so try both
68- subprocess .run (["install_name_tool" , "-change" , "/usr/local/lib/libportaudio.dylib" , "@rpath/libportaudio.dylib" , "./_sounddevice.abi3.so" ])
69- subprocess .run (["install_name_tool" , "-change" , "/usr/local/lib/libportaudio.2.dylib" , "@rpath/libportaudio.dylib" , "./_sounddevice.abi3.so" ])
7072
71- class PostDevelopCommand ( develop ):
73+ class PostBuildCommand ( build_ext ):
7274 """Post-installation for development mode."""
7375
7476 def run (self ):
75- develop .run (self )
76- post_install ()
77-
78-
79- class PostInstallCommand (install ):
80- """Post-installation for installation mode."""
81-
82- def run (self ):
83- install .run (self )
77+ build_ext .run (self )
8478 post_install ()
8579
8680
87- cmdclass ['develop' ] = PostDevelopCommand
88- cmdclass ['install' ] = PostInstallCommand
81+ cmdclass ['build_ext' ] = PostBuildCommand
8982
9083
9184setup (
0 commit comments