Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.7.1 instead.
Reason given by maintainers: Moved fastapi/uvicorn behind an extra, breaking installs of existing installations

Monaco Editor Assets

A Python package that provides easy access to Monaco Editor assets. Assets are automatically downloaded on first use, eliminating the need to bundle large files with the package. Optionally, the assets can be served by a local webserver on a custom port (requires the server extra).

Installation

python3 -m pip install monaco-assets
# or
uv pip install monaco-assets

To also use the optional webserver (MonacoServer), install the server extra:

python3 -m pip install "monaco-assets[server]"
# or
uv pip install "monaco-assets[server]"

Quick Start

import monaco_assets
server = monaco_assets.MonacoServer(port=8000)

Now, you can use http://localhost:8000/min/vs/loader.js in a webbrowser to see, e.g., loader.js. Please note that there are no directory listings, one has to directly address the file(s).

Cache Management

import monaco_assets

# Clear cache to free space before uninstalling the package
monaco_assets.clear_cache()

# Check whether the assets are already cached (no download needed)
if monaco_assets.has_cached_assets():
    ...
else:
    # a download will take place; e.g. show a progress indicator
    assets_path = monaco_assets.get_path(progress_callback=show_progress)

Download Progress

On a cold cache, get_path() downloads the Monaco Editor assets (~100 MB extracted). You can report the download progress in real time by passing a progress_callback that receives (bytes_downloaded, total_bytes):

import monaco_assets


def show_progress(done: int, total: int | None) -> None:
    if total is not None:
        print(f"\r{done / total:.0%} of {total / 2**20:.1f} MiB", end="", flush=True)
    else:
        print(f"\r{done / 2**20:.1f} MiB", end="", flush=True)


assets_path = monaco_assets.get_path(progress_callback=show_progress)

Notes:

  • The callback is only invoked if a download actually takes place; on a warm cache get_path() returns immediately without calling it. If you build progress UI around the call, check has_cached_assets() first to avoid showing it unnecessarily.
  • total_bytes is None if the server does not send a Content-Length header. The first chunk is always reported; further calls are throttled to at most one per 0.5 seconds, plus a final call when the download completes.
  • If you call get_path() from a background thread yourself, make the callback thread-safe accordingly.

Cache Locations

Assets are cached in platform-appropriate directories using the platformdirs library

How It Works

  1. First Use: When get_path() is called for the first time, the package:

    • Downloads Monaco Editor from npmjs.org
    • Verifies the download integrity with SHA1 hash
    • Extracts assets to the user cache directory
    • Returns the path to the assets
  2. Subsequent Uses: The package checks the cache and returns the existing assets path immediately.

Download Issues

If asset download fails:

  1. Check internet connectivity
  2. Verify firewall settings allow access to registry.npmjs.org
  3. Check disk space in cache directory

Cache Issues

Clear and re-download if corrupted.

monaco_assets.clear_cache()
assets_path = monaco_assets.get_path()

Version Correspondence

Version correspondence will be ensured after initial bugfixes.

Package Version Monaco Editor Version
0.5.1 0.54.0
0.7.0 0.54.0

Requirements

  • Python 3.10+
  • Internet connection (only for initial asset download)
  • ~100MB disk space for Monaco Editor assets

License

MIT License - see LICENSE file for details.

Monaco Editor is licensed under the MIT License by Microsoft Corporation.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monaco_assets-0.7.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

monaco_assets-0.7.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file monaco_assets-0.7.0.tar.gz.

File metadata

  • Download URL: monaco_assets-0.7.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for monaco_assets-0.7.0.tar.gz
Algorithm Hash digest
SHA256 e1f38a6bfd6e2d529c8640afc25054616a82cc9fb4b3adaee608c131c23ba094
MD5 e9d75f47b9d31787aaac01d21833f701
BLAKE2b-256 cd6e89469d45cab4f34286ed225912b7044df87ef73d6e48b81898d133d63393

See more details on using hashes here.

File details

Details for the file monaco_assets-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: monaco_assets-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for monaco_assets-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9b8e2f5e8909510289a2693a237bbed0a47a94da1dd2578616a4816c5d4f769
MD5 7054dc94412ce6f341275f86f85a07cd
BLAKE2b-256 6d2c9ba020336bdade4e854fde46f4096c04df51c57b181cbdc8fb5ef9260cad

See more details on using hashes here.

Release history Release notifications | RSS feed

0.7.1

2 files

This release

0.7.0 This release

2 files

0.5.1

2 files

0.4.3

2 files

0.4.1

2 files

0.4.0

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page