Skip to main content

A set of tools for putting together buildscripts and other CLI applications

Project description

python-build-tools

A toolkit containing many powerful utilities, including:

  • OS utilities (buildtools.os_utils)
  • Indented logging with colorama support (buildtools.bt_logging.log)
  • The powerful Maestro build management system (buildtools.maestro)
  • A powerful VCS repository wrapper system (buildtools.repo)
  • A mess of other random things.

This is mostly a personal toolkit that grew out of control.

os_utils

from buildtools import os_utils

# Ensure test/ exists
os_utils.ensureDirExists('test')

# Get copy of current environmental variables.
ENV = os_utils.ENV.clone()

# Add .bin/ to the beginning of PATH in our virtual environment
ENV.prependTo('PATH', '.bin/')

# Remove any duplicate entries from PATH
ENV.removeDuplicatedEntries('PATH')

# Find gcc in our virtual environment (checks PATHEXT on Windows, too!)
# Returns the path to gcc, or None if it couldn't be found.
GCC = ENV.which('gcc')

# Ensure bash exists before continuing (same rules as above)
ENV.assertWhich('bash')

# Bring up gcc's help page. Crash if non-0 exit code, echo command to console, and output STDOUT/STDERR to console.
os_utils.cmd([GCC, '--help'], critical=True, echo=True, show_output=True)

Logging

from buildtools import log

def a():
  log.info('This will be indented if a() is called in a log block.')

log.info('No indentation, yet.')
with log.warning('A warning. Next line will be indented.'):
  log.error('Error!')
  with log.info('The following function\'s log output will be indented by another layer.')
    a()
    log.critical('So will %s!', 'this')

Maestro

Maestro is currently synchronous, with plans to make it async.

from buildtools.maestro import BuildMaestro
from buildtools.maestro.fileio import ReplaceTextTarget
from buildtools.maestro.coffeescript import CoffeeBuildTarget
from buildtools.maestro.web import SCSSBuildTarget, SCSSConvertTarget

bm = BuildMaestro()

# Compile CoffeeScript to JS
bm.add(CoffeeBuildTarget('htdocs/js/vgws.js',                 ['coffee/src/vgws.coffee']))
bm.add(CoffeeBuildTarget('htdocs/js/editpoll.multichoice.js', ['coffee/editpoll.multichoice.coffee'], dependencies=['htdocs/js/vgws.js']))
bm.add(CoffeeBuildTarget('htdocs/js/editpoll.option.js',      ['coffee/editpoll.editpoll.coffee'], dependencies=['htdocs/js/vgws.js']))

# Convert CSS to SCSS
bm.add(SCSSBuildTarget('htdocs/css/style.css', ['style/style.scss'], [], import_paths=['style'], compass=True))

# Compile, taking dependencies into count when ordering operations.
bm.run()

# Same as above, but providing command line arguments such as --clean, and --rebuild.
bm.as_app()

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

pybuildtools-0.5.14.tar.gz (80.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybuildtools-0.5.14-py3-none-any.whl (133.2 kB view details)

Uploaded Python 3

File details

Details for the file pybuildtools-0.5.14.tar.gz.

File metadata

  • Download URL: pybuildtools-0.5.14.tar.gz
  • Upload date:
  • Size: 80.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pybuildtools-0.5.14.tar.gz
Algorithm Hash digest
SHA256 222c707027e61cf60e91c12520758f0d60937ce94fbf784b4b0e8700f9d6d5c8
MD5 b016ed207e0d68dd148479f1b6d6a5ff
BLAKE2b-256 9e4d72abe56b35938bb75842773084fb502870f10ba3b300754d894ae780a25e

See more details on using hashes here.

File details

Details for the file pybuildtools-0.5.14-py3-none-any.whl.

File metadata

  • Download URL: pybuildtools-0.5.14-py3-none-any.whl
  • Upload date:
  • Size: 133.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pybuildtools-0.5.14-py3-none-any.whl
Algorithm Hash digest
SHA256 aa8a270cb91d6fd20aaf5f90d3d256b4ee6141a55bf9b78a9e4e2eacd1ca70b9
MD5 a7128072ebf6091ad83599bf9712d178
BLAKE2b-256 f6c24f05355aa0c20bd494637e4cf95273002d532d5ad235e876b9de23c40d7a

See more details on using hashes here.

Supported by

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