Skip to content

Commit

Permalink
pre release
Browse files Browse the repository at this point in the history
  • Loading branch information
ann-marie-ward committed Apr 26, 2021
1 parent a2b9b03 commit 4eb8acd
Show file tree
Hide file tree
Showing 33 changed files with 157 additions and 46 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Release

on:
release:
types: [published]

jobs:
build-and-publish:
name: Build and publish dash-bootstrap-templates to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install . build
- name: Build package
run: python -m build --sdist --wheel --outdir dist/

# - name: Publish dash-bootstrap-templates to TestPyPI
# uses: pypa/[email protected]
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/

# - name: Publish dash-bootstrap-templates to PyPI
# uses: pypa/[email protected]
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# python build artifacts
__pycache__
*.egg-info
.ipynb_checkpoints
build
dist
venv
.idea
3 changes: 1 addition & 2 deletions _create_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,9 @@ def try_build_plotly_template_from_bootstrap_css_path(css_url):
Generate Templates
"""


# set relative path
PATH = pathlib.Path(__file__).parent
TEMPLATES_PATH = PATH.joinpath("./templates").resolve()
TEMPLATES_PATH = PATH.joinpath("./src/dash_bootstrap_templates/templates").resolve()


# Creates all templates and save them as json files
Expand Down
44 changes: 0 additions & 44 deletions dash_bootstrap_templates.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file removed img.png
Binary file not shown.
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]

[tool.setuptools_scm]
41 changes: 41 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

[metadata]
name = dash-bootstrap-templates
description = A collection of Plotly figure templates with a Bootstrap theme
long_description = file: README.md
long_description_content_type = text/markdown
license = MIT
author = AnnMarieW
# author_email =
url = https://github.com/AnnMarieW/dash-bootstrap-templates
classifiers =
Development Status :: 3 - Alpha
Framework :: Dash
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Scientific/Engineering :: Visualization

[options]
package_dir=
=src
packages=find:
include_package_data = True
install_requires =
dash
dash-bootstrap-components
importlib_metadata>=3.4.0,<4.0.0; python_version == "3.7"
importlib_resources>=5.1.0,<6.0.0; python_version < "3.9"
numpy

[options.packages.find]
where = src

[options.package_data]
dash_bootstrap_templates = templates/*.json

[options.extras_require]
dev =
tinycss2
spectra
66 changes: 66 additions & 0 deletions src/dash_bootstrap_templates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import json

import plotly.io as pio

try:
from importlib.resources import files
except ImportError:
# if using Python 3.8 or lower import from the backport
from importlib_resources import files

try:
from importlib.metadata import (
PackageNotFoundError,
version,
)
except ModuleNotFoundError:
# if using Python 3.7, import from the backport
from importlib_metadata import (
PackageNotFoundError,
version,
)

try:
__version__ = version("dash_bootstrap_templates")
except PackageNotFoundError:
# package is not installed
pass
"""
Use this function to make the bootstrap figure templates available in your Dash app
"""


def read_template(theme):
try:
with (
files("dash_bootstrap_templates") / "templates" / f"{theme}.json"
).open() as f:
template = json.load(f)
except IOError:
with (
files("dash_bootstrap_templates") / "templates" / "bootstrap.json"
).open() as f:
template = json.load(f)
pio.templates[theme] = template


def load_figure_template(themes="bootstrap"):
"""Add figure template to plotly.io and sets the default template
Keyword arguments:
themes -- may be a string or list of strings. (Default "bootstrap")
The string is the lowercase name of a Bootstrap theme
built in _create_templates.py
The plotly.io.templates.default will be the first theme if
themes is a list. If the themes attribute is invalid, the
"bootstrap" theme will be used.
"""
if type(themes) is list:
for theme in themes:
read_template(theme)
pio.templates.default = themes[0]

else:
read_template(themes)
pio.templates.default = themes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 4eb8acd

Please sign in to comment.