Skip to content

Commit

Permalink
setup.py: switch to out of tree builds.
Browse files Browse the repository at this point in the history
libusb 1.0.25 added support for out of tree builds.
Removed no longer needed run of 'make clean' for posix builds.
Updated readme.
  • Loading branch information
flit committed Feb 21, 2022
1 parent 8042f87 commit b7d9581
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ 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.
compliant packages. Building libusb is done out of tree in an automatically created build directory for libusb 1.0.25
and later.


## APIs
Expand All @@ -42,7 +42,7 @@ 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
All other parameters are passed unmodified.

- `get_libusb1_backend()`: Returns a `pyusb` backend object for the libusb version contained
in `libusb_package`.
Expand Down
11 changes: 4 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Chris Reed
# Copyright (c) 2021-2022 Chris Reed
#
# SPDX-License-Identifier: Apache-2.0
#
Expand Down Expand Up @@ -86,12 +86,10 @@ def run(self):
build_lib = ROOT_DIR / Path(build_py.get_package_dir(PACKAGE_NAME)).parent
else:
build_lib = Path(os.path.abspath(self.build_lib))
# build_temp = Path(os.path.abspath(self.build_temp))

# Build in-tree for the time being. libusb commit 1001cb5 adds support for out of tree builds, but
# this is not yet supported in an existing release. Once libusb version 1.0.25 is released, we can
# build out of tree.
build_temp = LIBUSB_DIR
# Build out of tree. Requires libusb commit 1001cb5 which adds support for out of tree builds, present
# in libusb 1.0.25 and later.
build_temp = Path(os.path.abspath(self.build_temp))

print(f"build_temp = {build_temp}")
print(f"build_lib = {build_lib}")
Expand Down Expand Up @@ -142,7 +140,6 @@ def run(self):
self.spawn(['env']) # Dump environment for debugging purposes.
self.spawn(['bash', str(BOOTSTRAP_SCRIPT)])
self.spawn(['bash', str(CONFIGURE_SCRIPT), *extra_configure_args])
self.spawn(['make', 'clean'])
self.spawn(['make', f'-j{os.cpu_count() or 4}', 'all'])
except Exception as err:
# Exception is caught here and reraised as our specific Exception class because the actual
Expand Down

0 comments on commit b7d9581

Please sign in to comment.