Skip to main content

Build Status codecov.io PyPI Status license

Copyright (C) 2013-2020 Samuel Colvin

Kind of like bower, but in Python, and simpler, and with some more features.

grablib can:

  • download files from urls, including extracting selectively from zip files.

  • create .grablib.lock which retains hashes of all downloaded files meaning assets can’t change unexpectedly.

  • compile sass/scss/css using libsass.

  • concatenate and minify javascript using jsmin.

Definition files can either be JSON or YAML (see examples).

Installation

grablib requires python 3.6+.

pip install grablib[build]

(You can also use simply pip install grablib to install without build requirements, this is useful when you’re not using grablib for building as it avoids installing jsmin and libsass which can be slow.)

CLI Usage

Define your static files thus: (grablib.yml)

download_root: 'static/libs'
download:
  'http://code.jquery.com/jquery-1.11.3.js': 'js/jquery.js'
  'https://github.com/twbs/bootstrap-sass/archive/v3.3.6.zip':
    'bootstrap-sass-3.3.6/assets/(.+)$': 'bootstrap-sass/'

  'GITHUB/codemirror/CodeMirror/5.8.0/lib/codemirror.js': 'codemirror/'
  # simple scss file to import and compile bootstrap from above,
  # generally this would be in your code
  # this file just reads "@import 'bootstrap-sass/stylesheets/bootstrap';"
  'https://git.io/v1Z5J': 'build_bootstrap.scss'

debug: true
build_root: 'static/prod'
build:
  # delete the entire static/prod directory before building, this is required for sass,
  # and generally safer
  wipe: '.*'
  cat:
    # concatenate jquery and codemirror into "libraries.js"
    # it won't get minified as debug is true, but without that it would
    'libraries.js':
      - 'DL/js/jquery.js'
      - 'DL/codemirror/codemirror.js'
  sass:
    # compile all css, scss and sass files which don't start with _ from the "download_root"
    # into the "css" directory, here that will just be build_bootstrap.scss which will
    # build the whole of bootstrap.
    # debug: true means you'll get map files and a copy of sass files so maps work properly.
    'css': 'DL/'

Then download and build you static files with just:

grablib

Library Usage

You can also call grablib from python:

from grablib import Grab

grab = Grab('path/to/definitions.json|yml')
grab.download()
grab.build()

Metadata

Release files for grablib 0.8

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

Source distribution (sdist)

Source distribution for grablib 0.8
File Size Uploaded
grablib-0.8.tar.gz 14.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for grablib 0.8
File Interpreter ABI Platform
grablib-0.8-py3-none-any.whl Python 3 none any Details

Total release size: 29.0 kB

Release files / grablib-0.8.tar.gz

Download URL grablib-0.8.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bcb94d9ffef4227ab5e5e79398d3a7ca6c7e072c72e5a42665c3869a64695b6e
BLAKE2b-256 checksum
How to use checksums
0e11947fcb2d3d1464cb7c45d3d55583072229136784fdb7f8b5a9cb183ad7f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Release files / grablib-0.8-py3-none-any.whl

Download URL grablib-0.8-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f746735df47e9a21884767a57ac73a84dc1382d977d59333cabb4d53f568e16
BLAKE2b-256 checksum
How to use checksums
305565db621d67969fef8bcc816ed6bd372b334e103c525eb86e9a58e5ad8809
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.8 This release

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7

2 release files

0.6.1

2 release files

0.6

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

0.2.1

2 release files

0.2

2 release files

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

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