Skip to content

Instantly share code, notes, and snippets.

@skseth
Created February 2, 2023 02:40
Show Gist options
  • Save skseth/81ee2ae16a53b3260260bac21b75a581 to your computer and use it in GitHub Desktop.
Save skseth/81ee2ae16a53b3260260bac21b75a581 to your computer and use it in GitHub Desktop.

How to package / distribute / install a wheel

Packaging

The following command builds a wheel for your project.

poetry build

Dependencies are listed in the METADATA file inside the wheel. You can see the dependencies by extracting this file, as the wheel file is just a zip. See the references below.

Wheels can be installed using :

  • pip install

or, to install in a specific directory

  • pip install --target >

In this case you can zip the target directory and distribute it as a zip also.

Distribution

You can distribute the wheel, or you can distribute the distribute the zip after the "pip install ... --target" command.

Installing wheel / zip in another machine

If the installation machine can get dependencies, then simply distribute the wheel file and run pip install. You can optionally deploy to a virtual environment.

If the installation needs all dependencies pre-packaged, then distribute the zip, and unzip to a target directory. Then,

export PYTHONPATH=<install_dir>:$PYTHONPATH
export PATH=<install_dir>/bin:$PATH
python3 -m <your package / module name>

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment