Skip to main content

Package containing libusb so it can be installed via Python package managers

Project description

Container package for libusb

This Python package functions as an installation vehicle for libusb shared libraries, to simplify installation of tools that require libusb. The main use case is so that users don't have to install libusb manually for projects that use pyusb. However, any Python project that uses a libusb wrapper can also benefit.

See libusb.info for more information about libusb.

Note: Currently the included libusb is built without udev support on Linux.

Note: The libusb upstream git repository is included as a submodule, so you need to clone with submodules enabled. You can either clone with --recurse-submodules or run git submodule update --init after cloning.

Installation

All releases include wheels for Linux, macOS, and Windows for multiple architectures. In addition, a source distribution is released.

If a matching wheel is not available, the source distribution will be installed and libusb will be compiled. This means the libusb build requirements must be installed:

  • Linux and macOS: autoconf, automake, libtool, and m4. As mentioned above, libusb is built without udev support, so libudev-dev is not required on Linux.
  • Windows: Visual Studio 2019 (Community is ok).

If the libusb build fails when installing from a source distribution, the libusb-package install will still succeed. In this case, an "empty" libusb-package is installed that doesn't contain a libusb shared library. get_library_path() returns None and find_library() falls back to returning a system installation of libusb, if available.

You can also install from a clone of the git repository by running pip install . from the repository root directory. Editable installs are supported. Please note that running setup.py directly is no longer supported for PEP 517 compliant packages. When building from the repo, because libusb 1.0.24 does not support out of tree builds, the build is done in-place in the src/libusb directory. make clean is run before compiling to ensure a clean build.

APIs

There are four public functions exported by libusb_package.

  • find(*args, **kwargs): Wrapper around pyusb's usb.core.find() that sets the backend parameter to a libusb1 backend created from the libusb library included in libusb_package. All other parameters are passed unmodified

  • get_libusb1_backend(): Returns a pyusb backend object for the libusb version contained in libusb_package.

  • find_library(candidate): Lower level function that returns either the full path to a library contained in libusb_package with a name starting with candidate, or None if no matching library is found. This function is suitable for use with the find_library callback parameter for pyusb's get_backend() functions.

    If get_library_path() returns None, indicating there is no included library, this function will fall back to ctypes.util.find_library().

  • get_library_path(): Returns an absolute Path object for the included library. If there is not an included library, None is returned.

Both get_libusb1_backend() and get_library_path() cache their return values.

Versioning

The version of libusb-package is composed of the libusb version plus an additional field for the version of the Python code. For instance, 1.0.24.0. The Python code version will be reset to 0 when the libusb version is incremented for new libusb release.

Examples

Usage example for find():

import libusb_package

for dev in libusb_package.find(find_all=True):
    print(dev)

Usage example for find_library():

import libusb_package
import usb.core
import usb.backend.libusb1

libusb1_backend = usb.backend.libusb1.get_backend(find_library=libusb_package.find_library)
# -> calls usb.libloader.load_locate_library(
#                ('usb-1.0', 'libusb-1.0', 'usb'),
#                'cygusb-1.0.dll', 'Libusb 1',
#                win_cls=win_cls,
#                find_library=find_library, check_symbols=('libusb_init',))
#
# -> calls find_library(candidate) with candidate in ('usb-1.0', 'libusb-1.0', 'usb')
#   returns lib name or path (as appropriate for OS) if matching lib is found

# It would also be possible to pass the output of libusb_package.get_libsusb1_backend()
# to the backend parameter here. In fact, that function is simply a shorthand for the line
# above.
print(list(usb.core.find(find_all=True, backend=libusb1_backend)))

Source distribution

Before building a source distribution, be sure to clean all untracked files from the libusb submodule using git -C src/libusb clean -dfx.

License

The Python code for libusb-package is licensed with Apache 2.0.
The libusb library and its source code are licensed with LGPLv2.1.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

libusb_package-1.0.26.4-py3-none-win_amd64.whl (90.7 kB view details)

Uploaded Python 3Windows x86-64

libusb_package-1.0.26.4-py3-none-win32.whl (77.7 kB view details)

Uploaded Python 3Windows x86

libusb_package-1.0.26.4-py3-none-musllinux_1_2_x86_64.whl (71.1 kB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

libusb_package-1.0.26.4-py3-none-musllinux_1_2_aarch64.whl (71.6 kB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

libusb_package-1.0.26.4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (70.8 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

libusb_package-1.0.26.4-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (70.6 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

libusb_package-1.0.26.4-py3-none-macosx_11_0_arm64.whl (58.0 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

libusb_package-1.0.26.4-py3-none-macosx_10_9_x86_64.whl (63.9 kB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file libusb_package-1.0.26.4-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for libusb_package-1.0.26.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 cd8c1f5df3906444ba6eff82ef44a75515b0444b76bba8abf21cc8569637af63
MD5 0a6313f1896ef071e0f658b5b502d729
BLAKE2b-256 eafc8c42060a9acf016a6dcb0ca352c9c0d6a993e64eecb1c9869fb59bbb4702

See more details on using hashes here.

File details

Details for the file libusb_package-1.0.26.4-py3-none-win32.whl.

File metadata

File hashes

Hashes for libusb_package-1.0.26.4-py3-none-win32.whl
Algorithm Hash digest
SHA256 9d1f5c925e11ecc9f0b9af888d45fd696fd96cf666b42694ee8c8628b5b4cd9a
MD5 8b13a0977fe40781b5e83b592368ce5a
BLAKE2b-256 3ac33e4a5891c8bec95ff856fadbffc84b8158703df7c09e7bd16d09f475d8f7

See more details on using hashes here.

File details

Details for the file libusb_package-1.0.26.4-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for libusb_package-1.0.26.4-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 dad68fc57d3e0562c2bd705ab8cbafbf27047b86bff74643c01f084b00a48557
MD5 7db1472b53d3ec93c4653cb98eb5d75c
BLAKE2b-256 caa08feafd54179c5c92b4d77adf43a91c8f13b45830d7e72c12707542309953

See more details on using hashes here.

File details

Details for the file libusb_package-1.0.26.4-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for libusb_package-1.0.26.4-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7ce9d8754b3531b4562ed209a807d80b8b6b82b1a6191726be1b9e5478b36a25
MD5 05bce55ec05ce925d60fa0810cec786e
BLAKE2b-256 e3bdd4f95fa0dcb361a52db973dd449110abe29bd82c9f035fc5ed870940576d

See more details on using hashes here.

File details

Details for the file libusb_package-1.0.26.4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libusb_package-1.0.26.4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 44baf60d639f97e61d2091212295b9f34e7ca58082c355f5fab44ad46ac4595e
MD5 37a4909eeeb8f5a61bdc120c8abae2de
BLAKE2b-256 fdd0ef347f6a283c1bde984af5aae3ba71ebf612d022c0a3cd1458ae58cc3c66

See more details on using hashes here.

File details

Details for the file libusb_package-1.0.26.4-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for libusb_package-1.0.26.4-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 41cf65507337277bd2a5b9ce3b4f4744214a3c42cdca7b31cade824b168f34cb
MD5 b340154052fbe9b19f7f68d81d8c6de5
BLAKE2b-256 044468c96f634d96edbfa792ff5f695a144ffddc146e581eaa9a25ab6d5c0f6d

See more details on using hashes here.

File details

Details for the file libusb_package-1.0.26.4-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libusb_package-1.0.26.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4ef4accbadd40f8a054b0298604555d8175ebd376a87978302a83d0311a0b116
MD5 2ffe39c37ccd946a35a357947c550b60
BLAKE2b-256 4e49bcc1e79a0d86f3da7cc3494093b4973cb1c74852d7356ce533bb1bd58342

See more details on using hashes here.

File details

Details for the file libusb_package-1.0.26.4-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for libusb_package-1.0.26.4-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ce3711a82a2b4b9936a6268c9cbad794c34ae3b1b2c5cc9aeced8340db678668
MD5 ea291634ff98fe818f640f179837fff5
BLAKE2b-256 0134fd042950325366cb8f01e1873cd87f8aa99e773586377a8e670d6127dc8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page