Skip to content

Python wrapper package for precompiled Bootstrap assets #41294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

MaximilianClemens
Copy link

@MaximilianClemens MaximilianClemens commented Mar 12, 2025

Description

A trivial change to make the precompiled CSS and JS files available for Python projects.

Motivation & Context

The motivation behind this change is to avoid having to manually update the assets (CSS + JS) in my FastAPI application. By integrating these assets as a dependency, users will always have access to the latest version automatically.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would change existing functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live previews

pip install git+https://github.com/MaximilianClemens/bootstrap.git
( pip install git+https://github.com/twbs/bootstrap.git ) # when accepted
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from pathlib import Path
import importlib.metadata

app = FastAPI()

# Retrieve the distribution information for the 'bootstrap' package.
dist = importlib.metadata.distribution("bootstrap")

# Locate the static assets installed as package data.
static_path = Path(dist.locate_file("bootstrap/dist"))

app.mount("/bootstrap", StaticFiles(directory=str(static_path)), name="bootstrap")

Related issues

@github-project-automation github-project-automation bot moved this to Needs review in v5.4.0 Mar 13, 2025
@julien-deramond julien-deramond moved this from Needs review to To analyze in v5.4.0 Mar 13, 2025
@julien-deramond julien-deramond removed this from v5.4.0 Mar 13, 2025
@mdo
Copy link
Member

mdo commented Apr 6, 2025

A trivial change to make the precompiled CSS and JS files available for Python projects.

Trivial perhaps, but adding it here means we're maintaining it. I'm not so sure about adding this to our project at this point. Could this be a separate repo and dependency that consumes the upstream project? I'd be happy to see that in the @twbs org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants