Skip to main content

A library and CLI to aid in configuring layered fingerprints.

Project description

Fingerprinter

This utility library can be used to create SHA256 fingerprints using globs and paths. It is meant to be a replacement for the sources/fingerprints.sh in common-build-scripts.

Installation

pip install uw-it-build-fingerprinter

Use

fingerprinter --help
fingerprinter -f fingerprints.yml -t assets

Configuration File

To get started, you'll need a configuration file. This file is a yaml file that defines your fingerprint targets.

targets:
  target-name: 
    include-paths:
      - src/**/*.py   # Glob to match all python files recursively under a directory
      - src/        # Will match every file under src/, recursively. (Same as 'src/**/*.*)
      - src         # interchangeable with `src/` or `src/**/*.*`
      - src/foo.py  # Include a specific file

You may also declare other targets as dependencies:

# This example has a source fingerprint that is generated for all python files
# under the src/ directory, but the fingerprint is dependent on the 
# dependency locks. This means that even if all python files remain
# untouched, an update to the dependencies will generate a new
# source fingerprint. 
# `fingerprints.yaml` is also included here to ensure that changes
# to the actual fingerprint configuration regenerates all fingerprints.
targets:
  dependencies:
    include-paths:
      - poetry.lock
      - fingerprints.yaml 
  source:
    depends-on: [dependencies]
    include-paths: ['src/**/*.py']

All paths will be lexicographically sorted at runtime, however dependencies are always resolved in the order provided.

python -m fingerprinter.cli -f fingerprints.yaml -t source will do the rest!

Excluding Files

There may be some paths that you never want to consider. .pyc, __pycache__ and .pytest_cache/ are always ignored by default.

You can exclude paths at the base of your yaml:

ignore-paths:
  - '**/ignore-me.py'  # Ignore every 'ignore-me.py' in the tree
  - 'src/special/ignore-me-also.py'  # Ignores this specific file 

targets:
  foo:
    # Will include src/foo/bar, but not src/.secrets/sekret or src/foo/__pycache__/blah
    include-paths: ['src']

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

uw-it-build-fingerprinter-0.1.1.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

uw_it_build_fingerprinter-0.1.1-py3-none-any.whl (6.3 kB view hashes)

Uploaded Python 3

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