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
9 changes: 6 additions & 3 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ pip list
if [[ -n ${UPDATE_CONTENT} ]]; then
mkdir -p ${TMP_DIR} && cd ${TMP_DIR} || exit 1
REPO_NAME="api-examples"
BRANCH_NAME= "main"
BRANCH_NAME_FALLBACK="dev"
BRANCH_NAME= "dev"

# Clone repository if it doesn't exist
[[ ! -e "${REPO_NAME}" ]] && git clone https://github.com/Exabyte-io/${REPO_NAME}.git
cd ${REPO_NAME} || exit 1
(git checkout ${BRANCH_NAME} || git checkout ${BRANCH_NAME_FALLBACK}) && git pull
git checkout ${BRANCH_NAME} && git pull

# Install git-lfs and pull LFS files
git lfs install && git lfs pull
Expand All @@ -56,6 +55,10 @@ if [[ -n ${UPDATE_CONTENT} ]]; then
cp -r ${RESOLVED_CONTENT_DIR}/other/materials_designer ${CONTENT_DIR}/made
# Copy other required files
cp -r ${RESOLVED_CONTENT_DIR}/{packages,utils,config.yml,README*} ${CONTENT_DIR}/

# Override utils/__init__.py with auto-installer
cp utils_autoinstall.py ${CONTENT_DIR}/utils/__init__.py

# Update path references in README*
sed -i "s/examples\//api\//g" ${CONTENT_DIR}/README.*
fi
Expand Down
30 changes: 30 additions & 0 deletions utils_autoinstall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Utils package for JupyterLite with automatic package installation
"""
import sys

# Auto-start package installation when utils is imported
if sys.platform == "emscripten":
try:
import asyncio
import micropip

async def install_packages_simple():
print("🔧 Utils loaded - installing packages...")
await micropip.install("mat3ra-api-examples", deps=False)
await micropip.install("mat3ra-utils")

from mat3ra.utils.jupyterlite.packages import install_packages
await install_packages("")

print("✅ Package installation complete!")

# Start installation in background
asyncio.create_task(install_packages_simple())

except Exception as e:
print(f"⚠️ Auto-installer failed: {e}")
print("💡 Manual install: import micropip; await micropip.install('mat3ra-utils')")
else:
# Standard Python environment
pass