Skip to content

Commit 1d82d05

Browse files
zycztejlmand
authored andcommitted
scripts: hid_configurator: Add support in Windows for dll folder
Adding the path to find a .dll to PATH environment variable has been removed in Python 3.8. Now os.add_dll_directory is recommended solution for adding dll. This commit adds an optional argument to script with path to dll folder. Jira: NCSDK-27863 Signed-off-by: Jan Zyczkowski <jan.zyczkowski@nordicsemi.no>
1 parent 7c120df commit 1d82d05

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ ext/lib/bin/libsupl.zip
3737
ext/BSEC_*
3838

3939
applications/nrf5340_audio/src/fw_info_app.c
40+
scripts/hid_configurator/hidapi.dll

scripts/hid_configurator/README.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ Complete the following steps:
6363
Use the bundled DLL or build it according to instructions in `HIDAPI library`_.
6464

6565
#. Select the appropriate HIDADPI library version for the used Windows system (either ``x86`` or ``x64``).
66-
Copy the :file:`hidapi.dll` file and paste it into either of the following directory:
67-
68-
* The directory where used Python executable is located.
69-
* The :file:`Windows\\System32` directory, for example :file:`C:\\Windows\\System32`.
66+
Copy the :file:`hidapi.dll` file and paste it into the directory where the :file:`configurator_cli.py` script is located.
7067

7168
#. Install `pyhidapi Python wrapper`_ and other required libraries with the following command:
7269

scripts/hid_configurator/configurator_cli.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
import os
99
import pprint
1010

11+
if os.name == "nt":
12+
try:
13+
script_dir = os.path.dirname(os.path.abspath(__file__))
14+
os.add_dll_directory(script_dir)
15+
except AttributeError:
16+
print('Cannot add directory containing configurator_cli.py script to DLL search path. \
17+
Please update to Python 3.8 or newer to allow placing hidapi.dll in the directory \
18+
containing configurator_cli.py script')
19+
1120
from NrfHidManager import NrfHidManager
1221

1322
from modules.module_config import MODULE_CONFIG
@@ -186,12 +195,7 @@ def perform_led_stream(dev, args):
186195

187196

188197
def parse_arguments():
189-
try:
190-
parser = argparse.ArgumentParser(allow_abbrev=False)
191-
except TypeError:
192-
# The allow_abbrev argument was added in Python 3.5.
193-
# Skip setting the value if used Python version does not support it.
194-
parser = argparse.ArgumentParser()
198+
parser = argparse.ArgumentParser(allow_abbrev=False)
195199

196200
parser.add_argument(dest='device', default=None, nargs='?',
197201
help='Device specified by type, board name or HW ID '

0 commit comments

Comments
 (0)