Skip to content

Commit 616865b

Browse files
committed
fixed windows setup
1 parent 81d7e11 commit 616865b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

setup.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import subprocess
22
import sys
3-
from os import environ, getenv
3+
from os import environ, getenv, path
44

55
import numpy
66
from setuptools import Extension, find_packages, setup
77
from setuptools.command.build_ext import build_ext
8+
from setuptools.command.install import install
89
from Cython.Build import cythonize
910

1011
libraries = ['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+
7892
setup(
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=[

0 commit comments

Comments
 (0)