Skip to content

Commit

Permalink
Add uv support
Browse files Browse the repository at this point in the history
  • Loading branch information
celsiusnarhwal committed Nov 22, 2024
1 parent 8695328 commit 548ec97
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
9 changes: 0 additions & 9 deletions docs/.overrides/404.html

This file was deleted.

21 changes: 12 additions & 9 deletions iconoclast/cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import contextlib
import shutil
import subprocess
import sys
from datetime import datetime
from pathlib import Path
from tempfile import TemporaryDirectory
Expand All @@ -24,9 +23,7 @@

app = typer.Typer(rich_markup_mode="rich")

here = Path(__file__).parent

pip = [sys.executable, "-m", "pip", "--disable-pip-version-check"]
HERE = Path(__file__).parent


def common_options(func: Callable):
Expand Down Expand Up @@ -61,7 +58,7 @@ def install(ctx: typer.Context):
"""
Download Font Awesome Pro.
"""
forbidden = {"--index-url", "-i"}.intersection(ctx.args)
forbidden = {"--index-url", "--index", "-i"}.intersection(ctx.args)

if forbidden:
raise Iconoquit(
Expand All @@ -82,7 +79,7 @@ def install(ctx: typer.Context):
index_url = f"https://dl.fontawesome.com/{token}/fontawesome-pro/python/simple"

subprocess.run(
[*pip, "install", "fontawesomepro", "--index-url", index_url, *ctx.args],
[*plugin_config.installer_args, "fontawesomepro", "-i", index_url, *ctx.args],
)


Expand All @@ -101,7 +98,8 @@ def kit(
"""
config_file = ctx.params.get("config_file")
config = load_config(str(config_file) if config_file else None)
kit_config: IconokitConfig = config.plugins["iconoclast"].config.kit
plugin_config: IconoclastConfig = config.plugins["iconoclast"].config
kit_config: IconokitConfig = plugin_config.kit

if not kit_config.enabled:
raise Iconoquit(
Expand Down Expand Up @@ -147,7 +145,7 @@ def kit(
iconokit_root = Path.cwd() / "iconokit"
iconokit_pkg = iconokit_root / "iconokit"

shutil.copytree(here / "iconokit", iconokit_root, dirs_exist_ok=True)
shutil.copytree(HERE / "iconokit", iconokit_root, dirs_exist_ok=True)
(iconokit_pkg / ".token").write_text(kit_["token"])

icons_dir = iconokit_pkg / ".overrides" / ".icons" / "fontawesome" / "kit"
Expand All @@ -161,7 +159,12 @@ def kit(
(icons_dir / icon["name"]).with_suffix(".svg").write_text(svg)

subprocess.run(
[*pip, "install", iconokit_root.absolute(), *ctx.args],
[
*plugin_config.installer_args,
"install",
iconokit_root.absolute(),
*ctx.args,
],
)

if not {"--quiet", "-q"}.intersection(ctx.args):
Expand Down
8 changes: 8 additions & 0 deletions iconoclast/plugins/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ class IconoclastConfig(Config):
"FONTAWESOME_PKG_TOKEN", os.getenv("FONTAWESOME_NPM_AUTH_TOKEN", "")
),
)
uv = c.Type(bool, default=False)
kit: IconokitConfig = c.SubConfig(IconokitConfig)

@property
def installer_args(self):
if self.uv and shutil.which("uv"):
return ["uv", "pip", "install"]

return [sys.executable, "-m", "pip", "--disable-pip-version-check", "install"]


class IconoclastPlugin(BasePlugin[IconoclastConfig]):
def on_config(self, config: MkDocsConfig) -> Optional[Config]:
Expand Down
4 changes: 2 additions & 2 deletions iconoclast/plugins/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def get_package_path() -> Path:
except ImportError:
log.error(
ansify(
"Font Awesome Pro is [bold underline red]not installed[/]. "
"Run [bold underline green]iconoclast install[/] to install it."
"Font Awesome Pro is not installed. "
"Run [cyan]iconoclast install[/] to install it."
)
)
sys.exit(1)
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ plugins:
- social
- iconoclast:
css: true
uv: true
- artwall

# Extensions
Expand Down

0 comments on commit 548ec97

Please sign in to comment.