Skip to main content

Freeze Wheel Plugin

Poetry plugin for creating frozen wheels using lockfiles.

Why

A common issue when publishing a Python application's release into PyPI, is whether or not the dependencies specified will continue to work over time. This tends to happen due to a confluence of reasons, poor dependency specification, bad observance of semantic versioning, or poor release management by the dependency. That translates to a reality where installing an older release of the application is unlikely to work, due to changes in the underlying dependency graph.

The dependency ecosystem is both complex and fragile. The emergence of lock files to ensure repeatability is testimony both to the problem and one solution. Yet when we go to publish in the packaging ecosystem we do so with non frozen dependencies specifications not with lockfiles. That means the testing pipelines that goes to produce and validate a release is against a lockfile but the release artifact is divorced of the lockfile contents, and starts to diverge from the moment of publication.

The various language package distribution channels (npm, pypi, rubygems, etc) are used for two different primary distribution purposes, for both libraries and applications. Generally speaking the extant behavior is reasonable for a library. Libraries should be relatively liberal on their own dependencies baring perhaps major versions to minimize conflicts for applications depending on them and ideally consist of minimal dependencies graphs. But for applications distribution, repeatable and verifyable installs are fundamental goals with potentially large dependency graphs. Using a frozen dependency graph versus version specifications is the only way to ensure repeatiblity of installation over time. Fundamentally the two different distribution purposes have different audiences, ie. libraries have developers and applications as consumers, applications have users as consumers.

What

A post build / pre publish command to allow for creating wheels with frozen dependencies. Basically we update wheel metadata for Requires-Dist to replace the pyproject.toml based version specification to a frozen (ie. ==version) one based on the version from the poetry lock information.

Note we can't use poetry to publish because the frozen wheel because it uses metadata from pyproject.toml instead of frozen wheel metadata.

Optional Dependencies

Frozen wheel metadata will contain Provides-Extra entries for any extra / optional dependencies. Frozen Requires-Dist lines will specify extra names _for packages that appear only in the optional/extra dependency graph.

If a package appears as both a nested "main" dependency and also as an "extra" dependency, its Requires-Dist entry in the frozen wheel will not specify an extra name.

To define this behavior in relation to poetry's export plugin, these two flows should result in the same installed package set:

# Export Flow
poetry export -f requirements.txt > requirements.txt && pip install -r requirements.txt

# Freeze-wheel Flow
poetry build && poetry freeze-wheel && pip install my_frozen_wheel

And introducing extras:

# Export Flow
poetry export --extras gcp -f requirements.txt && pip install -r requirements.txt

# Freeze-wheel Flow
poetry build && poetry freeze-wheel && pip install my_frozen_wheel[gcp]

The difference is in when to choose which extras to install - export does that at freeze time. freeze-wheel embeds the extra context at freeze time, but defers the actual extra selection until install time.

Usage

# install plugin
poetry self add poetry-plugin-freeze

# build per normal
poetry build

# add freeze step
poetry freeze-wheel

# avoid freezing specific packages
poetry freeze-wheel --exclude boto3 -e attrs

# Note we can't use poetry to publish because it uses metadata from pyproject.toml instead
# of frozen wheel metadata.

# publish per normal
twine upload dist/*.whl

Mono-Repo Support

To support mono repos consisting of multiple libraries/applications, when creating a frozen wheel, main group dependencies specified by path can be optionally substituted out for references to their release artifact versions.

This assumes automation to run build and publish across the various subpackages, ie typically via make or just.

Release files for poetry-plugin-freeze 1.2.0

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

Source distribution (sdist)

Source distribution for poetry-plugin-freeze 1.2.0
File Size Uploaded
poetry_plugin_freeze-1.2.0.tar.gz 34.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for poetry-plugin-freeze 1.2.0
File Interpreter ABI Platform
poetry_plugin_freeze-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.8 kB

Release files / poetry_plugin_freeze-1.2.0.tar.gz

Download URL poetry_plugin_freeze-1.2.0.tar.gz
Size 34.1 kB
Tags Source
SHA-256 checksum
How to use checksums
304559867004b2e4d3adf7918dc24f7cfd4b42a24a3eb0bfd3fc4348804b92f6
BLAKE2b-256 checksum
How to use checksums
131bb36eb2ae9eeb21c778c105ccf1a600fbaeba4a8a598cb97821a291598f23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.12.3 Linux/6.8.0-1021-azure

Release files / poetry_plugin_freeze-1.2.0-py3-none-any.whl

Download URL poetry_plugin_freeze-1.2.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f58687b414d2842e33cfffc2e01aca7c81e6a3ac5dd7c1c59debdcd7dabae5bc
BLAKE2b-256 checksum
How to use checksums
0e19b7c813aee0d7dac2db886e5c888b0c5e4ac7fce3cbee92dabcfbf16d9c38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.12.3 Linux/6.8.0-1021-azure

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.0

2 release files

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