Skip to main content
https://img.shields.io/pypi/status/wood.svg https://img.shields.io/pypi/v/wood.svg https://img.shields.io/pypi/pyversions/wood.svg https://travis-ci.org/gebn/wood.svg?branch=master https://coveralls.io/repos/github/gebn/wood/badge.svg?branch=master

Wood is a toolbox for representing directory trees, calculating comparisons between them, and effecting those changes in S3, CloudFront and Cloudflare. It started as a set of deploy scripts for my personal website, but grew into something that I was too chuffed with to keep hidden away in the bowls of another website repository. It’s not as refined as, say, requests, but should be useful to anyone looking to efficiently deploy a website to AWS, and/or using Cloudflare as a CDN.

Notably, unlike the AWS CLI tools or boto3, wood does not rely on file timestamps, instead using MD5 checksums to make the minimum number of changes possible in S3. It also has an algorithm for aggregating invalidation paths to make the CloudFront free tier go as far as possible. Syncers and invalidators are implemented in a generic way, allowing easy extension to additional services as needed.

Features

  • Tree representation

  • Tree comparison

    • Action that comparison in S3

    • Invalidate paths as necessary in CloudFront and Cloudflare

Demo

import wood

# low-level comparison of two local directories
comparison = wood.compare('~/dir', '~/.snapshot/hourly.1/dir')
comparison.new()       # files added since the snapshot
comparison.modified()  # files modified since the snapshot
comparison.deleted()   # files deleted since the snapshot


import pathlib
import boto3

local_base = pathlib.Path('/path/to/web/root')
bucket = boto3.resource('s3').Bucket('example.com')

# create representations of the local and remote trees
to_deploy = wood.root(local_base)
deployed = wood.s3.objects_to_root(bucket.objects.all())

# compare the two as if they were local directories
comparison = wood.compare(to_deploy, deployed)

# write all changes (additions, modifications, deletions) to the S3 bucket
syncer = wood.s3.Syncer(local_base, bucket)
syncer.sync(comparison)

# invalidate the minimum amount in CloudFront to ensure the changes are
# visible, using prefix grouping where possible
cloudfront = boto3.client('cloudfront')
invalidator = wood.cloudfront.Invalidator(cloudfront, '{distribution}',
                                          '{reference}')
invalidator.invalidate(comparison)

# do the same for Cloudflare in the case of a second CDN
invalidator = wood.cloudflare.Invalidator(sess, email, key, zone,
                                         'https://example.com/')
invalidator.invalidate(comparison)

Why “wood”?

Because it started as a tree comparison tool, and grew out from there. It’s also a little rough around the edges.

Metadata

Release files for wood 1.0.3

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

Source distribution (sdist)

Source distribution for wood 1.0.3
File Size Uploaded
wood-1.0.3.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wood 1.0.3
File Interpreter ABI Platform
wood-1.0.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 36.1 kB

Release files / wood-1.0.3.tar.gz

Download URL wood-1.0.3.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6c3d6c4e3f4a6f29c6f7fa48be0304112c2be0e7cb3e0adeb21777f3c248e725
BLAKE2b-256 checksum
How to use checksums
5e650e34734cbe30825c533265c2110f47093c89f247d30023e9929d00f8fc29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / wood-1.0.3-py2.py3-none-any.whl

Download URL wood-1.0.3-py2.py3-none-any.whl
Size 20.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f69a999e046a00cce4b9927246a05ff4123bbdecc73d00aca419106a0532dc3e
BLAKE2b-256 checksum
How to use checksums
f819e4d301af1125e82c45eab9f38b41894cb92b70f2a9bc5d4fe4011015ba08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

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