Python Wrapper for Bootstrap CSS/JavaScript Assets
This repository automatically syncs with the latest Bootstrap distribution files from the official Bootstrap repository and packages them for easy distribution via Python's packaging system.
✨ NEW: Now installable as a Python package!
pip install bootstrap-wrapper==5.3.8This repository automatically syncs with the latest Bootstrap distribution files from the official Bootstrap repository.
pip install bootstrap-wrapper==5.3.8FastAPI Example:
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
import bootstrap_wrapper
app = FastAPI()
# Get Bootstrap assets path
static_path = bootstrap_wrapper.get_bootstrap_dir()
# Mount Bootstrap static files
app.mount("/bootstrap", StaticFiles(directory=str(static_path)), name="bootstrap")
# Access Bootstrap at:
# http://localhost:8000/bootstrap/css/bootstrap.min.css
# http://localhost:8000/bootstrap/js/bootstrap.bundle.min.jsFlask Example:
from flask import Flask, send_from_directory
import bootstrap_wrapper
app = Flask(__name__)
BOOTSTRAP_PATH = bootstrap_wrapper.get_bootstrap_dir()
@app.route('/bootstrap/<path:filename>')
def bootstrap_static(filename):
return send_from_directory(str(BOOTSTRAP_PATH), filename)Django Example:
# In settings.py
import bootstrap_wrapper
BOOTSTRAP_STATIC_ROOT = bootstrap_wrapper.get_bootstrap_dir()
STATICFILES_DIRS = [
BOOTSTRAP_STATIC_ROOT,
]- Schedule: The Bootstrap assets are automatically updated weekly on Mondays at 09:00 UTC
- Manual Trigger: You can manually trigger an update by running the "Sync Bootstrap Dist" workflow
- Force Update: Use the
force_updateoption to force an update even if the version is the same
- Force Update: Use the
- Auto-Merge: When a new Bootstrap version is available, the workflow automatically:
- Creates a pull request with the updated files
- Auto-merges the PR (no manual review required)
- Creates a git tag matching the Bootstrap version (e.g.,
5.3.8) - Creates a GitHub release automatically
- Triggers PyPI publishing via the existing publish workflow
The Bootstrap distribution files are stored in the bootstrap/ directory:
bootstrap/css/- Bootstrap CSS files (minified and source)bootstrap/js/- Bootstrap JavaScript files (minified and source)bootstrap/version.txt- Current Bootstrap version
The sync process uses the GitHub Actions workflow located at .github/workflows/sync-bootstrap-dist.yml which:
- Checks the latest Bootstrap release via GitHub API
- Compares with the current version in
bootstrap/version.txt - Downloads and extracts the official Bootstrap dist ZIP if an update is needed
- Creates a pull request with the updated files
- Auto-merges the pull request immediately (no manual review required)
- Creates a git tag matching the Bootstrap version for PyPI releases
- Creates a GitHub release automatically
- Triggers PyPI package publishing through the existing publish workflow
Run the example script to see usage examples:
python example_usage.pyThe project is automatically published to PyPI as bootstrap-wrapper when:
- A new GitHub release is created
- The GitHub Actions workflow runs successfully
For manual publishing (if needed):
# Install build tools
pip install build twine
# Build the package
python -m build
# Upload to PyPI (requires API token)
twine upload dist/*Note: The package uses trusted publishing via GitHub Actions, so manual uploads should generally not be necessary.
This project is licensed under the MIT License - see the LICENSE file for details.
Bootstrap itself is also licensed under the MIT License.