File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 11import subprocess
22import sys
3- from os import environ , getenv
3+ from os import environ , getenv , path
44
55import numpy
66from setuptools import Extension , find_packages , setup
77from setuptools .command .build_ext import build_ext
8+ from setuptools .command .install import install
89from Cython .Build import cythonize
910
1011libraries = ['hackrf' ]
@@ -75,9 +76,22 @@ def run(self) -> None:
7576 super ().run ()
7677
7778
79+ class InstallWithPth (install ):
80+ def run (self ) -> None :
81+ super ().run ()
82+
83+ if PLATFORM .startswith ('win' ):
84+ pth_code = (
85+ 'import os; '
86+ 'os.add_dll_directory(os.getenv("HACKRF_LIB_DIR", "C:\\ Program Files\\ HackRF\\ lib"))'
87+ )
88+ with open (path .join (self .install_lib , "python_hackrf.pth" ), mode = 'w' , encoding = 'utf-8' ) as file :
89+ file .write (pth_code )
90+
91+
7892setup (
7993 name = 'python_hackrf' ,
80- cmdclass = {'build_ext' : CustomBuildExt },
94+ cmdclass = {'build_ext' : CustomBuildExt , 'install' : InstallWithPth },
8195 install_requires = INSTALL_REQUIRES ,
8296 setup_requires = SETUP_REQUIRES ,
8397 ext_modules = [
You can’t perform that action at this time.
0 commit comments