Skip to content

Commit eb805c0

Browse files
committed
Allow use of Aillio R1 winusb driver
Changes windows to use libusb_package which includes the required dlls to allow artisan to connect to R1 without any modification of drivers. Removes unnecessary libusb drivers from windows build process
1 parent 593cf90 commit eb805c0

5 files changed

Lines changed: 15 additions & 24 deletions

File tree

.appveyor.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ for:
7676

7777
# pull library versions from requirments file
7878
- ps: $env:PYINSTALLER_VER = Select-String -Path ./src/requirements.txt "pyinstaller==([\d\.]*).*platform_system='Windows'" -List | ForEach-Object {$_.Matches.Groups[1].Value}
79-
- ps: $env:LIBUSB_VER = Select-String -Path ./src/requirements.txt "libusb==([\d\.]*).*platform_system='Windows'" -List | ForEach-Object {$_.Matches.Groups[1].Value}
8079
- ps: Write-Host "PYINSTALLER_VER= $env:PYINSTALLER_VER"
81-
- ps: Write-Host "LIBUSB_VER= $env:LIBUSB_VER"
8280

8381
# update path env var
8482
- cmd: set PATH=%PYTHON_PATH%;%PYTHON_PATH%\Scripts;%PATH%
@@ -145,9 +143,7 @@ for:
145143

146144
# pull library versions from requirments file
147145
- ps: $env:PYINSTALLER_VER = Select-String -Path ./src/requirements.txt "pyinstaller==([\d\.]*).*platform_system='Windows'" -List | ForEach-Object {$_.Matches.Groups[1].Value}
148-
- ps: $env:LIBUSB_VER = Select-String -Path ./src/requirements.txt "libusb==([\d\.]*).*platform_system='Windows'" -List | ForEach-Object {$_.Matches.Groups[1].Value}
149146
- ps: Write-Host "PYINSTALLER_VER= $env:PYINSTALLER_VER"
150-
- ps: Write-Host "LIBUSB_VER= $env:LIBUSB_VER"
151147

152148
# update path env var
153149
- cmd: set PATH=%PYTHON_PATH%;%PYTHON_PATH%\Scripts;%PATH%

.ci/install-win.bat

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,6 @@ if not exist vc_redist.x64.exe (exit /b 140)
9393
copy "%PYTHON_PATH%\Lib\site-packages\snap7\lib\snap7.dll" "C:\Windows"
9494
if not exist "C:\Windows\snap7.dll" (exit /b 150)
9595

96-
::
97-
:: download and copy the libusb-win32 dll. NOTE-the version number for libusb is set in the requirements-win*.txt file.
98-
::
99-
echo curl libusb-win32
100-
curl -k -L -O https://netcologne.dl.sourceforge.net/project/libusb-win32/libusb-win32-releases/%LIBUSB_VER%/libusb-win32-bin-%LIBUSB_VER%.zip
101-
if not exist libusb-win32-bin-%LIBUSB_VER%.zip (exit /b 160)
102-
7z x libusb-win32-bin-%LIBUSB_VER%.zip
103-
copy "libusb-win32-bin-%LIBUSB_VER%\bin\amd64\libusb0.dll" "C:\Windows\SysWOW64"
104-
if not exist "C:\Windows\SysWOW64\libusb0.dll" (exit /b 170)
105-
10696
::
10797
:: show set of libraries are installed
10898
::

src/artisan-win.spec

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ PYQT_QT_BIN = PYQT_QT + r'\bin'
9999
PYQT_QT_TRANSLATIONS = QT_TRANSL
100100
YOCTO_BIN = PYTHON_PACKAGES + r'\yoctopuce\cdll'
101101
SNAP7_BIN = r'C:\Windows'
102-
LIBUSB_BIN = r'C:\Windows\SysWOW64'
103102

104103
from PyInstaller.utils.hooks import is_module_satisfies
105104
if is_module_satisfies('scipy >= 1.3.2'):
@@ -233,10 +232,6 @@ copy_file(YOCTO_BIN + r'\yapi64.dll', TARGET + '_internal\yoctopuce\cdll')
233232
# copy Snap7 lib
234233
copy_file(SNAP7_BIN + r'\snap7.dll', TARGET)
235234

236-
# copy libusb0.1 lib
237-
238-
copy_file(LIBUSB_BIN + r'\libusb0.dll', TARGET + '_internal')
239-
240235
for fn in [
241236
'artisan.png',
242237
'artisanAlarms.ico',

src/artisanlib/aillio.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
import array
2828

29+
if system().startswith('Windows'):
30+
import libusb_package
31+
2932
#import requests
3033
#from requests_file import FileAdapter # type: ignore # @UnresolvedImport
3134
#import json
@@ -124,11 +127,18 @@ def __open(self) -> None:
124127
return
125128
if self.usbhandle is not None:
126129
return
127-
self.usbhandle = usb.core.find(idVendor=self.AILLIO_VID,
128-
idProduct=self.AILLIO_PID)
129-
if self.usbhandle is None:
130+
if not system().startswith('Windows'):
130131
self.usbhandle = usb.core.find(idVendor=self.AILLIO_VID,
131-
idProduct=self.AILLIO_PID_REV3)
132+
idProduct=self.AILLIO_PID)
133+
if self.usbhandle is None:
134+
self.usbhandle = usb.core.find(idVendor=self.AILLIO_VID,
135+
idProduct=self.AILLIO_PID_REV3)
136+
else:
137+
self.usbhandle = libusb_package.find(idVendor=self.AILLIO_VID,
138+
idProduct=self.AILLIO_PID)
139+
if self.usbhandle is None:
140+
self.usbhandle = libusb_package.find(idVendor=self.AILLIO_VID,
141+
idProduct=self.AILLIO_PID_REV3)
132142
if self.usbhandle is None:
133143
raise OSError('not found or no permission')
134144
self.__dbg('device found!')

src/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# the following commented package versions are read by appveyor.yml and downloaded outside of pip.
2121
#
2222
# pyinstaller==6.3.0; platform_system='Windows'
23-
# libusb==1.2.7.3; platform_system='Windows' #1.2.6.0
2423
# libusb==1.0.26; platform_system='Linux'
2524
#
2625
# HACK: temporary require an older version of Pillow (PIL) as the current v10.0.0 breaks py2app on macOS
@@ -117,3 +116,4 @@ SecretStorage==3.3.3; platform_system=='Linux'
117116
build==1.0.3; platform_system=='Windows' # required to build pyinstaller bootloader
118117
pywin32==306; platform_system=='Windows'
119118
pyinstaller-versionfile==2.1.1; platform_system=='Windows'
119+
libusb-package==1.0.26.2; platform_system=='Windows'

0 commit comments

Comments
 (0)