pyocd / libusb-package Goto Github PK
View Code? Open in Web Editor NEWPackaged libusb shared libraries for Python.
License: Apache License 2.0
Packaged libusb shared libraries for Python.
License: Apache License 2.0
I'd be nice to have the built wheels tested in CI as well.
If it's something simple like running the test.py
script I'd be happy to provide a PR adding a test step/job to the GitHub Actions workflow, just need a confirmation about how to test it.
README.md
says:
All releases include wheels for Linux, macOS, and Windows for multiple architectures.
Where exactly do I find these "wheels" for Windows, and how exactly do I use them to install libusb-package
?
It would be nice if README.md
made this clear.
As a side note, I ran pip install .
in the libusb-package-1.0.26.0
directory, but then
import os
os.environ['PYUSB_DEBUG'] = 'debug'
import usb.core
usb.core.find()
from here yields
2022-09-03 00:00:00,241 ERROR:usb.libloader:'Libusb 1' could not be found
2022-09-03 00:00:00,241 ERROR:usb.backend.libusb1:Error loading libusb 1.0 backend
2022-09-03 00:00:00,242 ERROR:usb.libloader:'OpenUSB library' could not be found
2022-09-03 00:00:00,242 ERROR:usb.backend.openusb:Error loading OpenUSB backend
2022-09-03 00:00:00,244 ERROR:usb.libloader:'Libusb 0' could not be found
2022-09-03 00:00:00,244 ERROR:usb.backend.libusb0:Error loading libusb 0.1 backend
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python310\lib\site-packages\usb\core.py", line 1309, in find
raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available
Add BSD support to libusb-package. I'd like to make sure that libusb-package can install and work successfully from the source distribution on BSD systems, since prebuilt wheels for BSD are highly unlikely.
@cederom I don't have a BSD environment to test with. Could you help here?
One question is: what does platform.system()
return for BSD, and what is the file extension for shared libraries? This will allow an entry to be added to the library extension mapping dict:
libusb-package/src/libusb_package/__init__.py
Lines 40 to 45 in 7b3a847
I would assume none of the C code from this package is using the Python C API, is that correct?
If so, I think maybe the wheels can be declared abi3
compatible (the reduced Python3 API) and that'd reduce the total number of wheels to 1 per platform, instead of having one per Python version and per platform.
This would also have the advantage that existing wheels marked with abi3
would be inmediately installable in newer Python versions (at least until a Python release updates the ABI to abi4
, maybe the future no-gil), so the package would not have to be updated just to support the latest Python release, like in #16.
I've not yet had to create a Python wheel with C extensions, so not my area of expertise and I could be wrong here, but worth exploring?
From pip install --no-cache-dir -v libusb-package
:
Using pip 23.1.2 from \\Mac\Home\dev\pysensornet2\venv\Lib\site-packages\pip (python 3.11)
Collecting libusb-package
Downloading libusb-package-1.0.26.1.tar.gz (3.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 6.7 MB/s eta 0:00:00
Running command pip subprocess to install build dependencies
Collecting setuptools>=42
Using cached setuptools-68.0.0-py3-none-any.whl (804 kB)
Collecting setuptools_scm[toml]>=6.2
Using cached setuptools_scm-7.1.0-py3-none-any.whl (43 kB)
Collecting wheel
Using cached wheel-0.40.0-py3-none-any.whl (64 kB)
Collecting tomli
Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting packaging>=20.0 (from setuptools_scm[toml]>=6.2)
Using cached packaging-23.1-py3-none-any.whl (48 kB)
Collecting typing-extensions (from setuptools_scm[toml]>=6.2)
Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Installing collected packages: wheel, typing-extensions, tomli, setuptools, packaging, setuptools_scm
Successfully installed packaging-23.1 setuptools-68.0.0 setuptools_scm-7.1.0 tomli-2.0.1 typing-extensions-4.7.1 wheel-0.40.0
Installing build dependencies ... done
Running command Getting requirements to build wheel
C:\Users\mduan\AppData\Local\Temp\pip-build-env-pq91fekh\overlay\Lib\site-packages\setuptools\config\setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
!!
********************************************************************************
The license_file parameter is deprecated, use license_files instead.
By 2023-Oct-30, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
********************************************************************************
!!
parsed = self.parsers.get(option_name, lambda x: x)(value)
running egg_info
writing src\libusb_package.egg-info\PKG-INFO
writing dependency_links to src\libusb_package.egg-info\dependency_links.txt
writing entry points to src\libusb_package.egg-info\entry_points.txt
writing top-level names to src\libusb_package.egg-info\top_level.txt
listing git files failed - pretending there aren't any
reading manifest file 'src\libusb_package.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '__pycache__' found anywhere in distribution
warning: no previously-included files matching '*.py[cod]' found anywhere in distribution
adding license file 'LICENSE'
writing manifest file 'src\libusb_package.egg-info\SOURCES.txt'
Getting requirements to build wheel ... done
Running command Preparing metadata (pyproject.toml)
C:\Users\mduan\AppData\Local\Temp\pip-build-env-pq91fekh\overlay\Lib\site-packages\setuptools\config\setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
!!
********************************************************************************
The license_file parameter is deprecated, use license_files instead.
By 2023-Oct-30, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
********************************************************************************
!!
parsed = self.parsers.get(option_name, lambda x: x)(value)
running dist_info
creating C:\Users\mduan\AppData\Local\Temp\pip-modern-metadata-y7l5q0py\libusb_package.egg-info
writing C:\Users\mduan\AppData\Local\Temp\pip-modern-metadata-y7l5q0py\libusb_package.egg-info\PKG-INFO
writing dependency_links to C:\Users\mduan\AppData\Local\Temp\pip-modern-metadata-y7l5q0py\libusb_package.egg-info\dependency_links.txt
writing entry points to C:\Users\mduan\AppData\Local\Temp\pip-modern-metadata-y7l5q0py\libusb_package.egg-info\entry_points.txt
writing top-level names to C:\Users\mduan\AppData\Local\Temp\pip-modern-metadata-y7l5q0py\libusb_package.egg-info\top_level.txt
writing manifest file 'C:\Users\mduan\AppData\Local\Temp\pip-modern-metadata-y7l5q0py\libusb_package.egg-info\SOURCES.txt'
listing git files failed - pretending there aren't any
reading manifest file 'C:\Users\mduan\AppData\Local\Temp\pip-modern-metadata-y7l5q0py\libusb_package.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '__pycache__' found anywhere in distribution
warning: no previously-included files matching '*.py[cod]' found anywhere in distribution
warning: no previously-included files matching '.*' found anywhere in distribution
adding license file 'LICENSE'
writing manifest file 'C:\Users\mduan\AppData\Local\Temp\pip-modern-metadata-y7l5q0py\libusb_package.egg-info\SOURCES.txt'
creating 'C:\Users\mduan\AppData\Local\Temp\pip-modern-metadata-y7l5q0py\libusb_package-1.0.26.1.dist-info'
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: libusb-package
Running command Building wheel for libusb-package (pyproject.toml)
C:\Users\mduan\AppData\Local\Temp\pip-build-env-pq91fekh\overlay\Lib\site-packages\setuptools\config\setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
!!
********************************************************************************
The license_file parameter is deprecated, use license_files instead.
By 2023-Oct-30, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
********************************************************************************
!!
parsed = self.parsers.get(option_name, lambda x: x)(value)
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-arm64-cpython-311
creating build\lib.win-arm64-cpython-311\libusb_package
copying src\libusb_package\_version.py -> build\lib.win-arm64-cpython-311\libusb_package
copying src\libusb_package\__init__.py -> build\lib.win-arm64-cpython-311\libusb_package
creating build\lib.win-arm64-cpython-311\libusb_package\__pyinstaller
copying src\libusb_package\__pyinstaller\hook-libusb_package.py -> build\lib.win-arm64-cpython-311\libusb_package\__pyinstaller
copying src\libusb_package\__pyinstaller\__init__.py -> build\lib.win-arm64-cpython-311\libusb_package\__pyinstaller
running egg_info
writing src\libusb_package.egg-info\PKG-INFO
writing dependency_links to src\libusb_package.egg-info\dependency_links.txt
writing entry points to src\libusb_package.egg-info\entry_points.txt
writing top-level names to src\libusb_package.egg-info\top_level.txt
listing git files failed - pretending there aren't any
reading manifest file 'src\libusb_package.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '__pycache__' found anywhere in distribution
warning: no previously-included files matching '*.py[cod]' found anywhere in distribution
adding license file 'LICENSE'
writing manifest file 'src\libusb_package.egg-info\SOURCES.txt'
copying src\libusb_package\py.typed -> build\lib.win-arm64-cpython-311\libusb_package
running build_ext
build_temp = C:\Users\mduan\AppData\Local\Temp\pip-install-c5kd4cjj\libusb-package_952f9245dd9048eaafa755cc96a0038e\src\libusb
build_lib = C:\Users\mduan\AppData\Local\Temp\pip-install-c5kd4cjj\libusb-package_952f9245dd9048eaafa755cc96a0038e\build\lib.win-arm64-cpython-311
cmd.exe /c "C:\Users\mduan\AppData\Local\Temp\pip-install-c5kd4cjj\libusb-package_952f9245dd9048eaafa755cc96a0038e\scripts\vsenv.bat && msbuild -p:Configuration=Release -p:Platform=x64 C:\Users\mduan\AppData\Local\Temp\pip-install-c5kd4cjj\libusb-package_952f9245dd9048eaafa755cc96a0038e\src\libusb\msvc\libusb_dll_2019.vcxproj"
C:\Users\mduan\AppData\Local\Temp\pip-install-c5kd4cjj\libusb-package_952f9245dd9048eaafa755cc96a0038e\src\libusb>rem From: https://renenyffenegger.ch/notes/development/tools/scripts/personal/vsenv_bat
'""' is not recognized as an internal or external command,
operable program or batch file.
Microsoft (R) Build Engine version 4.8.9032.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 7/7/2023 1:10:35 PM.
Project "C:\Users\mduan\AppData\Local\Temp\pip-install-c5kd4cjj\libusb-package_952f9245dd9048eaafa755cc96a0038e\src\libusb\msvc\libusb_dll_2019.vcxproj" on node 1 (default targets).
C:\Users\mduan\AppData\Local\Temp\pip-install-c5kd4cjj\libusb-package_952f9245dd9048eaafa755cc96a0038e\src\libusb\msvc\libusb_dll_2019.vcxproj(45,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "C:\Users\mduan\AppData\Local\Temp\pip-install-c5kd4cjj\libusb-package_952f9245dd9048eaafa755cc96a0038e\src\libusb\msvc\libusb_dll_2019.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\Users\mduan\AppData\Local\Temp\pip-install-c5kd4cjj\libusb-package_952f9245dd9048eaafa755cc96a0038e\src\libusb\msvc\libusb_dll_2019.vcxproj" (default target) (1) ->
C:\Users\mduan\AppData\Local\Temp\pip-install-c5kd4cjj\libusb-package_952f9245dd9048eaafa755cc96a0038e\src\libusb\msvc\libusb_dll_2019.vcxproj(45,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.44
Error while building libusb: command 'C:\\Windows\\system32\\cmd.exe' failed with exit code 1
Ignoring build failure and creating system-only libusb-package
installing to build\bdist.win-arm64\wheel
running install
running install_lib
creating build\bdist.win-arm64
creating build\bdist.win-arm64\wheel
creating build\bdist.win-arm64\wheel\libusb_package
copying build\lib.win-arm64-cpython-311\libusb_package\py.typed -> build\bdist.win-arm64\wheel\.\libusb_package
copying build\lib.win-arm64-cpython-311\libusb_package\_version.py -> build\bdist.win-arm64\wheel\.\libusb_package
copying build\lib.win-arm64-cpython-311\libusb_package\__init__.py -> build\bdist.win-arm64\wheel\.\libusb_package
creating build\bdist.win-arm64\wheel\libusb_package\__pyinstaller
copying build\lib.win-arm64-cpython-311\libusb_package\__pyinstaller\hook-libusb_package.py -> build\bdist.win-arm64\wheel\.\libusb_package\__pyinstaller
copying build\lib.win-arm64-cpython-311\libusb_package\__pyinstaller\__init__.py -> build\bdist.win-arm64\wheel\.\libusb_package\__pyinstaller
running install_egg_info
Copying src\libusb_package.egg-info to build\bdist.win-arm64\wheel\.\libusb_package-1.0.26.1-py3.11.egg-info
running install_scripts
C:\Users\mduan\AppData\Local\Temp\pip-build-env-pq91fekh\overlay\Lib\site-packages\wheel\bdist_wheel.py:100: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
if get_flag("Py_DEBUG", hasattr(sys, "gettotalrefcount"), warn=(impl == "cp")):
creating build\bdist.win-arm64\wheel\libusb_package-1.0.26.1.dist-info\WHEEL
creating 'C:\Users\mduan\AppData\Local\Temp\pip-wheel-nsm3wkzw\.tmp-vl_lsy6u\libusb_package-1.0.26.1-cp311-cp311-win_arm64.whl' and adding 'build\bdist.win-arm64\wheel' to it
adding 'libusb_package/__init__.py'
adding 'libusb_package/_version.py'
adding 'libusb_package/py.typed'
adding 'libusb_package/__pyinstaller/__init__.py'
adding 'libusb_package/__pyinstaller/hook-libusb_package.py'
adding 'libusb_package-1.0.26.1.dist-info/LICENSE'
adding 'libusb_package-1.0.26.1.dist-info/METADATA'
adding 'libusb_package-1.0.26.1.dist-info/WHEEL'
adding 'libusb_package-1.0.26.1.dist-info/entry_points.txt'
adding 'libusb_package-1.0.26.1.dist-info/top_level.txt'
adding 'libusb_package-1.0.26.1.dist-info/RECORD'
removing build\bdist.win-arm64\wheel
Building wheel for libusb-package (pyproject.toml) ... done
Created wheel for libusb-package: filename=libusb_package-1.0.26.1-cp311-cp311-win_arm64.whl size=11119 sha256=11213fb03bc7cb37db9ac34eec7064d9e80374f50353346c1e1fbdbf0fec35f2
Stored in directory: C:\Users\mduan\AppData\Local\Temp\pip-ephem-wheel-cache-x5nwyx73\wheels\de\41\6c\533429639808e359a30d6aa548960815c1b4a14a2643ee185e
Successfully built libusb-package
Installing collected packages: libusb-package
Successfully installed libusb-package-1.0.26.1
No libusb DLL is ever built.
Hey, PyUSB/liquidctl maintainer here.
When you have some time, can you upload Python 3.11 wheels, at least for Windows. Many users on that platform (especially end users) don't have everything set up to build them locally.
Thanks!
Hello,
the readme says that libusb is licensed under GPLv2, but it's LGPLv2.1
License
The Python code for libusb-package is licensed with Apache 2.0.
The libusb library and its source code are licensed with GPLv2.
here is libusb license
Looks like wheels are built for each supported Python version individually.
Assuming it there are no other blockers to release a wheel for Python 3.12, could we have wheels generated for this version as well?
I'll try to find some time to look into it, in case it's something I can contribute via PR.
I know this is a somewhat niche use-case, but I've found that libusb_package.find_library()
does not work if libusb_package
is in a ZIP file that is added to the Python PATH.
In theory, this should work because libusb_package.get_library_path()
uses importlib.resources.path
to ask the resource manager to provide a filesystem path for the library. When libusb_package
is in a ZIP file, importlib.resources
extracts the library to a temporary file and returns the path to the temporary file. This is fine, but later on find_library()
checks the name of the returned file and accepts the library only if its name starts with the name of the library that the user expected -- and this is not true any more if the library is extracted to a temporary file. For instance, on macOS, the name of the temporary file is something like tmpXXXXXXXlibusb-1.0.dylib
where XXXXXXX
is a random part.
Would you accept a PR that relaxes the condtions in find_library()
such that it accepts the extracted file if the library name appears anywhere in the filename? This is still not a foolproof check because there are absolutely no guarantees about the name of the returned temporary file, but it would at least solve the problem with the current Python implementation of importlib.resources
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.