Skip to main content

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 or later (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. Building libusb is done out of tree in an automatically created build directory for libusb 1.0.25 and later.

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.30.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.

Metadata

Release files for libusb-package 1.0.30.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for libusb-package 1.0.30.0
File
libusb_package-1.0.30.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
libusb_package-1.0.30.0-py3-none-win32.whl Python 3 none Windows x86-32 Details
libusb_package-1.0.30.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
libusb_package-1.0.30.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
libusb_package-1.0.30.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
libusb_package-1.0.30.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
libusb_package-1.0.30.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
libusb_package-1.0.30.0-py3-none-macosx_10_9_x86_64.whl Python 3 none macOS 10.9+ x86-64 Details

Total release size: 610.9 kB

Release files / libusb_package-1.0.30.0-py3-none-win_amd64.whl

Download URL libusb_package-1.0.30.0-py3-none-win_amd64.whl
Size 90.7 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
90808da724c8939a333d931d0c7226372ca5fefd98e2f2f3ef79fd918aa37522
BLAKE2b-256 checksum
How to use checksums
604aff49bd77f33af05ca26fee29d601beb1e19ca791bb86efece82a3833885c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / libusb_package-1.0.30.0-py3-none-win32.whl

Download URL libusb_package-1.0.30.0-py3-none-win32.whl
Size 78.8 kB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
79728146e1f01e525786900b2ccd8298a8eca53cd94b37fb0885e56aa6f9d60a
BLAKE2b-256 checksum
How to use checksums
e595d166eeefe0d9dd5833d5724a97b023ec380c3a2d364040ec0485fd57703c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / libusb_package-1.0.30.0-py3-none-musllinux_1_2_x86_64.whl

Download URL libusb_package-1.0.30.0-py3-none-musllinux_1_2_x86_64.whl
Size 76.7 kB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
2ee5ef8ac6f08402b4e8334f7404850316bdd26037c9a97f2a7456ee9a5d1550
BLAKE2b-256 checksum
How to use checksums
7b03264cefc51275ecb047194c4973bc40b3b278566a64bbe6e74f86bf1e0afc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / libusb_package-1.0.30.0-py3-none-musllinux_1_2_aarch64.whl

Download URL libusb_package-1.0.30.0-py3-none-musllinux_1_2_aarch64.whl
Size 77.2 kB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
7a2a1c82f6ef85d9920cbe2898aa6927d4c487744ef9f20b0d7d6d95705095bb
BLAKE2b-256 checksum
How to use checksums
de56a1fb1726fc96a8ee3bd0e04e5e505500f022dd310dd348ecebf5cdae7a60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / libusb_package-1.0.30.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL libusb_package-1.0.30.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 76.2 kB
Tags Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
f502ad5a0527b8c0431de817662325c88a1bba2cc334173665b04ad168d7b6d3
BLAKE2b-256 checksum
How to use checksums
6fe1a7c83535749332825f02d6693868f8ee9ae99c4104e60a483773bb652c0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / libusb_package-1.0.30.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL libusb_package-1.0.30.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 76.2 kB
Tags Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
c71b5f8c65b286425c02c7d624eee1fd7f08bfb1dfa492ddc20e27f06fee3829
BLAKE2b-256 checksum
How to use checksums
11129ba8fa91dc95b1cbfa4a68207d4048b08b900fd3686fa72b99846608de01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / libusb_package-1.0.30.0-py3-none-macosx_11_0_arm64.whl

Download URL libusb_package-1.0.30.0-py3-none-macosx_11_0_arm64.whl
Size 65.7 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4ad25f8d254bbbdd234446d5580b24d62d59bb0e690d8090457dac347f044437
BLAKE2b-256 checksum
How to use checksums
526f26de4e9f858ab50e87931f0be268f3c1bbfce33e8584add60da857632142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / libusb_package-1.0.30.0-py3-none-macosx_10_9_x86_64.whl

Download URL libusb_package-1.0.30.0-py3-none-macosx_10_9_x86_64.whl
Size 69.5 kB
Tags Python 3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
2b98784bac3bedda7e95bb5039dd0eded84b02f36110e4d5d607375366c61090
BLAKE2b-256 checksum
How to use checksums
42a88b3d5dae7340880d556f9f866874b9674b2e3a22fee1e2b96f1ab0feae36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page