Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v5
with:
version: 0.6.3
version: "0.6.3"
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "uv.lock"
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/palette.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Palette

on:
push:
branches:
- "main"
workflow_dispatch:
schedule:
- cron: "0 0 * * *" # Run every day at midnight UTC

jobs:
createPullRequest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
version: "0.6.3"
python-version: "3.13"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Fetch latest palette
run: curl -Lo src/palette.json 'https://raw.githubusercontent.com/catppuccin/palette/main/palette.json'

- name: Run codegen
run: uv run --extra matplotlib build.py

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
commit-message: "feat: auto-sync upstream palettes"
committer: "GitHub <noreply@github.com>"
author: "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
signoff: false
branch: new-palettes
delete-branch: true
title: "feat: auto-sync upstream palettes"
body: |
Auto-update `src/palette.json` based on https://github.com/catppuccin/palette/blob/main/palette.json
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
python-version-file: "pyproject.toml"
- uses: astral-sh/setup-uv@v5
with:
version: 0.6.3
version: "0.6.3"
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uv build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v5
with:
version: 0.6.3
version: "0.6.3"
python-version: "${{ matrix.python-version }}"
enable-cache: true
cache-dependency-glob: "uv.lock"
Expand Down
Binary file modified assets/frappe/bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/frappe/boxplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/frappe/imshow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/frappe/palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/frappe/patches.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/frappe/plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/frappe/scatter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/latte/bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/latte/boxplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/latte/imshow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/latte/palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/latte/patches.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/latte/plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/latte/scatter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/macchiato/bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/macchiato/boxplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/macchiato/imshow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/macchiato/palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/macchiato/patches.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/macchiato/plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/macchiato/scatter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/mocha/bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/mocha/boxplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/mocha/imshow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/mocha/palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/mocha/patches.png
Binary file modified assets/mocha/plot.png
Binary file modified assets/mocha/scatter.png
25 changes: 16 additions & 9 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,17 @@ def codegen() -> str:


if __name__ == "__main__":
# Generate the palette.py file

print("running codegen")
palette_path = Path.cwd() / "catppuccin" / "palette.py"
with palette_path.open("w") as f:
source = codegen()
print(source, file=f)
# Run `ruff format` on the generated file
with palette_path.open("w", newline="\n") as f:
f.write(codegen())
print("formatting with ruff")
ruff_format = f"ruff format {palette_path}"
subprocess.run(ruff_format.split(), check=True) # noqa: S603
subprocess.run(ruff_format.split(), check=True, stdout=subprocess.DEVNULL)
print("palette.py generation complete")

# Generate the matplotlib styles

print("generating matplotlib styles")
from catppuccin.extras.matplotlib import CATPPUCCIN_STYLE_DIRECTORY
from catppuccin.palette import PALETTE

Expand All @@ -91,34 +90,42 @@ def codegen() -> str:
).read_text()

for key, palette in asdict(PALETTE).items():
print(f"- {key}")
text = template_text
text = text.replace("<palette>", key)
for color in palette["colors"]:
text = text.replace(
f"<{color}>",
palette["colors"][color]["hex"].replace("#", ""),
)
with (CATPPUCCIN_STYLE_DIRECTORY / f"{key}.mplstyle").open("w") as f:
style_path = CATPPUCCIN_STYLE_DIRECTORY / f"{key}.mplstyle"
with style_path.open("w", newline="\n") as f:
f.write(text)
print("matplotlib styles generation complete")

# Generate matplotlib assets for the docs
import matplotlib as mpl
import matplotlib.pyplot as plt

import catppuccin # This loads the styles in matplotlib # noqa: F401

print("generating matplotlib asset images")
for palette_name in asdict(PALETTE):
print(f"- {palette_name}")
mpl.style.use(palette_name)

palette_path = Path.cwd() / "assets" / palette_name
palette_path.mkdir(exist_ok=True, parents=True)

# Plot palette separately
print(" - palette")
fig = plot_palette(palette_name)
fig.savefig(palette_path / "palette.png", dpi=DPI)

# Plot examples
for filename, plot_function in example_plots.items():
print(f" - {filename}")
fig = plot_function()
fig.savefig(palette_path / f"{filename}.png", dpi=DPI)
plt.close()
print("matplotlib asset image generation complete")
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ grid.color: <surface0>

# Boxplots: Overlay 0
boxplot.flierprops.color: <overlay0>
boxplot.flierprops.markerfacecolor: <overlay0>
boxplot.flierprops.markerfacecolor: <overlay0>
boxplot.flierprops.markeredgecolor: <overlay0>
boxplot.boxprops.color: <overlay0>
boxplot.whiskerprops.color: <overlay0>
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ gh-pages = ["tinycss2>=1.2.1"]
[dependency-groups]
dev = [
"mypy>=1.15.0",
"pytest>=8.3.4",
"pytest>=8.3.5",
"pytest-cov>=6.0.0",
"ruff>=0.9.7",
"ruff>=0.9.9",
"types-pygments>=2.19.0.20250219",
"types-colorama>=0.4.15.20240205",
]
Expand All @@ -49,6 +49,10 @@ ignore = [
"S101", # assert
"PLR2004", # magic-value-comparison
]
"build.py" = [
"T201", # print
"S603", # subprocess-without-shell-equals-true
]

[tool.mypy]
strict = true
Expand Down
52 changes: 27 additions & 25 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.