Skip to main content

Self-contained wheels for Windows

Project description

CI PyPI version Python versions

delvewheel

delvewheel is a command-line tool for creating self-contained Python wheel packages for Windows that have DLL dependencies that may not be present on the target system. It is functionally similar to auditwheel (for Linux) and delocate (for macOS).

Suppose that you have built a Python wheel for Windows containing an extension module, and the wheel depends on DLLs that are present in the build environment but may not be present on the end user's machine. This tool determines which DLLs a wheel depends on (aside from system libraries) and copies those DLLs into the wheel. This tool also takes extra steps to avoid DLL hell and to ensure that the DLLs are properly loaded at runtime.

Installation

delvewheel can be installed using pip.

pip install delvewheel

You can also install from the source code by opening a command-line shell at the repository root and running

pip install .

Supported Platforms

delvewheel can be run using Python 3.7+ on any platform.

delvewheel can repair wheels targeting Python 2.6+ for win32, win_amd64, or win_arm64.

The environment used to run delvewheel does not need to match the target environment of the wheel being repaired. For example, you can run delvewheel using 32-bit Python 3.7 to repair a wheel for 64-bit Python 2.6. You can even run delvewheel with PyPy3.6 on 32-bit x86 Linux to repair a wheel whose target environment is CPython 3.11 on Windows arm64.

Usage

delvewheel show: show external DLLs that the wheel depends on

delvewheel repair: copy external DLL dependencies into the wheel and patch the wheel so that these libraries are loaded at runtime

delvewheel needed: list the direct DLL dependencies of a single executable

delvewheel uses the PATH environment variable to search for DLL dependencies. To specify an additional directory to search for DLLs, add the location of the DLL to the PATH environment variable or use the --add-path option.

For a summary of additional command-line options, use the -h option (delvewheel -h, delvewheel show -h, delvewheel repair -h, delvewheel needed -h).

Additional Options

The path separator to use in the following options is ';' on Windows and ':' on Unix-like platforms.

delvewheel show

  • --add-path: additional path(s) to search for DLLs, path-separator-delimited. These paths are searched before those in the PATH environment variable.
  • --add-dll: name(s) of additional DLL(s) to vendor into the wheel, path-separator-delimited. We do not automatically search for dependencies of these DLLs unless another included DLL depends on them. If you use this option, it is your responsibility to ensure that the additional DLL is found at load time.
  • --no-dll: name(s) of DLL(s) to specifically exclude from the wheel, path-separator-delimited. Dependencies of these DLLs are also automatically excluded if no other included DLL depends on them.
  • --ignore-in-wheel: don't search for or vendor in DLLs that are already in the wheel. We still search for and vendor in dependencies of these DLLs if they are not in the wheel. This flag is meant for simpler integration with other DLL bundling tools/techniques but is not a catch-all. If you use this flag, it is your responsibility to ensure that the DLLs that are already in the wheel are loaded correctly.
  • -v: verbosity
    • -v: level 1, some diagnostic information
    • -vv: level 2, include warnings from pefile
  • --extract-dir: directory to store extracted contents of wheel for debug use (default is a temp directory)

delvewheel repair

  • --add-path: additional path(s) to search for DLLs, path-separator-delimited. These paths are searched before those in the PATH environment variable.
  • --add-dll: name(s) of additional DLL(s) to vendor into the wheel, path-separator-delimited. We do not automatically search for or vendor in dependencies of these DLLs unless another included DLL depends on them. We do not mangle the names of these DLLs or their direct dependencies. If you use this option, it is your responsibility to ensure that the additional DLL is found at load time.
  • --no-dll: name(s) of DLL(s) to specifically exclude from the wheel, path-separator-delimited. Dependencies of these DLLs are also automatically excluded if no other included DLL depends on them.
  • --ignore-in-wheel: don't search for or vendor in DLLs that are already in the wheel. Don't mangle the names of these DLLs or their direct dependencies. We still search for and vendor in dependencies of these DLLs if they are not in the wheel. This flag is meant for simpler integration with other DLL bundling tools/techniques but is not a catch-all. If you use this flag, it is your responsibility to ensure that the DLLs that are already in the wheel are loaded correctly.
  • -v: verbosity
    • -v: level 1, some diagnostic information
    • -vv: level 2, include warnings from pefile
  • --extract-dir: directory to store extracted contents of wheel for debug use (default is a temp directory)
  • -w,--wheel-dir: directory to write the repaired wheel (default is wheelhouse relative to current working directory)
  • --no-mangle: name(s) of DLL(s) not to mangle, path-separator-delimited
  • --no-mangle-all: don't mangle any DLL names
  • --strip: strip DLLs that contain trailing data when name-mangling. The GNU strip utility must be present in PATH.
  • -L,--lib-sdir: subdirectory suffix to store vendored DLLs (default .libs). For example, if your wheel is named mywheel-0.0.1-cp310-cp310-win_amd64.whl, then the vendored DLLs are stored in mywheel.libs by default. If your wheel contains a top-level extension module that is not in any package, then this setting is ignored, and vendored DLLs are instead placed directly into site-packages when the wheel is installed.

Limitations

  • delvewheel reads DLL file headers to determine which libraries a wheel depends on. DLLs that are loaded at runtime using ctypes/cffi (from Python) or LoadLibrary (from C/C++) will be missed. You can, however, specify additional DLLs to vendor into the wheel using the --add-dll option. If you elect to do this, it is your responsibility to ensure that the additional DLL is found at load time.
  • Wheels created using delvewheel are not guaranteed to work on systems older than Windows 7 SP1. If you intend to create a wheel for an old Windows system, you should test the resultant wheel thoroughly. If it turns out that getting the wheel to work on an older system simply requires an extra DLL, you can use the --add-dll flag to vendor additional DLLs into the wheel.
  • To avoid DLL hell, we mangle the file names of most DLLs that are vendored into the wheel. This way, a Python process that tries loading a vendored DLL does not end up using a different DLL with the same name. Due to a limitation in how name-mangling is performed, delvewheel is unable to name-mangle DLLs whose dependents contain insufficient internal padding to fit the mangled names and contain trailing data at the end of the binary. An exception will be raised if such a DLL is encountered. Commonly, trailing data consist of symbols that can be safely removed using the GNU strip utility, although there exist situations where the data must be present for the DLL to function properly. To remove the trailing data, execute strip -s EXAMPLE.dll or use the --strip flag. To keep the trailing data and skip name mangling, use the --no-mangle or --no-mangle-all flag.
  • Any DLL containing an Authenticode signature will have its signature cleared if its dependencies are name-mangled.
  • delvewheel cannot repair a wheel that contains extension modules targeting more than one CPU architecture (e.g. both win32 and win_amd64). You should create a separate wheel for each CPU architecture and repair each individually.
  • delvewheel creates or patches __init__.py in each top-level package so that the DLLs are loaded properly during import. This will cause issues if you have a top-level namespace package that requires __init__.py to be absent to function properly.

Project details


Download files

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

Source Distribution

delvewheel-1.3.3.tar.gz (50.6 kB view details)

Uploaded Source

Built Distribution

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

delvewheel-1.3.3-py3-none-any.whl (49.3 kB view details)

Uploaded Python 3

File details

Details for the file delvewheel-1.3.3.tar.gz.

File metadata

  • Download URL: delvewheel-1.3.3.tar.gz
  • Upload date:
  • Size: 50.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 PyPy/7.3.11

File hashes

Hashes for delvewheel-1.3.3.tar.gz
Algorithm Hash digest
SHA256 d7276e92e462dd26c645a8408a359e2213c4873e8b7014c58058c44be20992d9
MD5 f1635b2aea80020842ddb3f14e174967
BLAKE2b-256 51af579d8546c4dd662da76c92fa24c0ed1db8d7997281497823367f2ba93415

See more details on using hashes here.

File details

Details for the file delvewheel-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: delvewheel-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 49.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 PyPy/7.3.11

File hashes

Hashes for delvewheel-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ad213052b702df0799ef7d519075b5cb469f253958b369db9f14b0ee79643962
MD5 6a00e726dd04a93507324c76c40a070d
BLAKE2b-256 a849aca8b9e6137211a604b1a890fc24d2fc297884bca59a0398716d9e8ab63a

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