Skip to main content

Module to create layers of dependencies

Project description

A simple module for creating layers of dependencies.

Installation

Just use pip!:

$ pip install layerz

Usage

from layerz import Layers

dep1 = type("dep1", (object, ), {"dependencies": lambda s, all_deps: []})()
dep2 = type("dep2", (object, ), {"dependencies": lambda s, all_deps: ["dep3"]})()
dep3 = type("dep3", (object, ), {"dependencies": lambda s, all_deps: ["dep1"]})()
dep4 = type("dep4", (object, ), {"dependencies": lambda s, all_deps: ["dep3"]})()
dep5 = type("dep1", (object, ), {"dependencies": lambda s, all_deps: ["dep4", "dep2"]})()

layers = Layers({"dep1": dep1, "dep2": dep2, "dep3": dep3, "dep4": dep4, "dep5": dep5})
layers.add_to_layers("dep5")
for layer in layers.layered:
    # might get something like
    # [("dep5", dep5)]
    # [("dep4", dep4), ("dep2", dep2)]
    # [("dep3", dep3)]
    # [("dep1", dep1)]

When we create the layers, it will do a depth first addition of all dependencies and only add a dep to a layer that occurs after all it’s dependencies.

Cyclic dependencies will be complained about.

Tests

Install locally:

$ pip install -e .
$ pip install -e ".[tests]"

And then use the helper script:

$ ./test.sh

Project details


Release history Release notifications | RSS feed

This version

0.5

Download files

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

Source Distribution

layerz-0.5.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file layerz-0.5.tar.gz.

File metadata

  • Download URL: layerz-0.5.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for layerz-0.5.tar.gz
Algorithm Hash digest
SHA256 cfc02e5d2519d3be5b6475c8d032aeac0dd69d98fda10eb9dd847d0ff2547a70
MD5 a991e61c634a4a6c8aa235a8f9b1fe79
BLAKE2b-256 a2d0334ce144224847c2fead1dc92b86eb4719dd81ff665fb3de47ff9733fe14

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page