Skip to content
Open
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
3 changes: 2 additions & 1 deletion xircuits/library/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .list_library import list_component_library
from .install_fetch_library import install_library, fetch_library, uninstall_library
from .create_library import create_or_update_library
from .update_library import update_library
from .update_library import update_library
from .core_libs import CORE_LIBS, is_core_library
16 changes: 16 additions & 0 deletions xircuits/library/core_libs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from typing import FrozenSet

# Core component libraries that are bundled with the xircuits wheel
CORE_LIBS: FrozenSet[str] = frozenset({
"xai_controlflow",
"xai_events",
"xai_template",
"xai_utils",
})

def is_core_library(library_name: str) -> bool:
"""Check if a library name refers to a core component."""
normalized = library_name.strip().lower()
if not normalized.startswith("xai_"):
normalized = f"xai_{normalized}"
return normalized in CORE_LIBS
8 changes: 3 additions & 5 deletions xircuits/library/install_fetch_library.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import shutil
from pathlib import Path

from .core_libs import is_core_library

from xircuits.utils.file_utils import is_valid_url, is_empty
from xircuits.utils.requirements_utils import read_requirements_for_library
from xircuits.utils.git_toml_manager import (
Expand All @@ -19,10 +21,6 @@
from ..handlers.request_remote import request_remote_library
from ..handlers.request_folder import clone_from_github_url


CORE_LIBS = {"xai_events", "xai_template", "xai_controlflow", "xai_utils"}


def get_component_library_path(library_name: str) -> str:
"""
If a URL is provided, clone to xai_components/xai_<name>.
Expand Down Expand Up @@ -149,7 +147,7 @@ def uninstall_library(library_name: str) -> str:
raw = "xai_" + raw
short = raw.split("/")[-1]

if short in CORE_LIBS:
if is_core_library(short):
raise RuntimeError(f"'{short}' is a core library and cannot be uninstalled.")

lib_path = resolve_library_dir(short)
Expand Down
Loading