jupyterlite_core#
配置#
JupyterLite 生命周期的一个可观测配置对象
- class jupyterlite_core.config.LiteBuildConfig(**kwargs)#
- JupyterLite 构建的描述 - 这很可能从以下方面进行配置:- 环境变量 - pyproject.toml - 命令行 直接实例化是最后不太可能的方式。 - 这在概念上与 jupyter_server_config.json 规模相似,并将利用 {sys.prefix}/share/jupyter_{notebook,server}_config.d/ 加载器路径 - 
app_archive: Path#
- JUPYTERLITE_APP_ARCHIVE - 类型:
- 要使用的应用存档。env 
 
 - 
apps: tuple[str]#
- 要在构建中明确包含的 Lite 应用,例如 lab、tree、repl 
 - 
base_url: str#
- JUPYTERLITE_BASE_URL - 类型:
- [serve] 要使用的前缀。env 
 
 - 
cache_dir: Path#
- 一个缓存文件夹 
 - 
contents: tuple[Path]#
- 要添加和索引的内容 
 - 
disable_addons: tuple[str]#
- 应该是字典 - 类型:
- 跳过这些插件的 entry_point 加载。TODO 
 
 - 
extra_file_types: dict#
- 用于服务器和浏览器的额外 JupyterLab 兼容文件类型 
 - 
extra_http_headers: dict#
- 要添加到所有提供响应的默认标头的 HTTP 标头 
 - 
extra_ignore_contents: tuple[str]#
- 不应作为内容包含的其他路径正则表达式 
 - 
federated_extensions: tuple[str]#
- 用于查找 federated_extensions 的本地路径或 URL 
 - 
file_types: dict#
- 用于服务器和浏览器的 JupyterLab 兼容文件类型 
 - 
http_headers: dict#
- 要添加到所有提供响应的 HTTP 标头 
 - 
ignore_contents: tuple[str]#
- 不应作为内容包含的路径正则表达式 
 - 
ignore_sys_prefix: Union[bool,tuple[str]]#
- 忽略来自 sys.prefix 的组件 
 - 
lite_dir: Path#
- JUPYTERLITE_DIR - 类型:
- JupyterLite 项目的根文件夹。env 
 
 - 
no_libarchive: bool#
- 不要检测和使用 libarchive-c 以获得更高的性能和更多的存档 
 - 
no_sourcemaps: bool#
- 从应用程序和扩展中剥离所有源映射 
 - 删除未被 –apps 使用的任何共享包 
 - 
output_archive: Path#
- JUPYTERLITE_OUTPUT_ARCHIVE - 类型:
- 要创建的存档。env 
 
 - 
output_dir: Path#
- JUPYTERLITE_OUTPUT_DIR - 类型:
- 构建 JupyterLite 站点的位置。env 
 
 - 
port: int#
- JUPYTERLITE_PORT - 类型:
- [serve] 要通过 http (不安全地) 暴露的端口 
- 类型:
- //127.0.0.1. env 
 
 - 
settings_overrides: tuple[str]#
- 要包含的特定 overrides.json 
 - 
source_date_epoch: Optional[int]#
- 触发可重现构建,将时间戳限制为此值 
 
- 
app_archive: 
常量#
JupyterLite 使用的众所周知(及其他)常量
- jupyterlite_core.constants.ADDON_ENTRYPOINT = 'jupyterlite.addon.v0'#
- 插件(包括核心)的扩展点 
- jupyterlite_core.constants.ALL_APP_ARCHIVES = [PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/jupyterlite/checkouts/stable/py/jupyterlite-core/jupyterlite_core/jupyterlite-app-0.6.4.tgz')]#
- 所有存档 
- jupyterlite_core.constants.ALL_JSON = 'all.json'#
- 常用的响应夹具文件名,例如 settings 
- jupyterlite_core.constants.API_CONTENTS = 'api/contents'#
- Contents API 的 Jupyter API 路由 
- jupyterlite_core.constants.C_LOCALE = 'C'#
- 用于可重现文件排序的区域设置 
- jupyterlite_core.constants.DEFAULT_FILE_TYPES = {'base64': {'gzip': [['.tgz', '.gz', '.gzip'], ['application/gzip']], 'ico': [['.ico'], ['image/x-icon']], 'jpeg': [['.jpeg', '.jpg'], ['image/jpeg']], 'pdf': [['.pdf'], ['application/pdf']], 'png': [['.png'], ['image/png']], 'wasm': [['.wasm'], ['application/wasm']], 'wheel': [['.whl'], ['octet/stream', 'application/x-wheel+zip']]}, 'json': {'geojson': [['.geojson'], ['application/geo+json']], 'ipynb': [['.ipynb'], ['application/x-ipynb+json']], 'jsmap': [['.map'], ['application/json']], 'json': [['.json'], ['application/json']]}, 'text': {'css': [['.css'], ['text/css']], 'csv': [['.csv'], ['text/csv']], 'fasta': [['.fasta'], ['text/plain']], 'html': [['.html'], ['text/html']], 'ical': [['.ical', '.ics', '.ifb', '.icalendar'], ['text/calendar']], 'js': [['.js', '.mjs'], ['application/javascript']], 'manifest': [['.manifest'], ['text/cache-manifest']], 'md': [['.md', '.markdown'], ['text/markdown']], 'plain': [['.txt'], ['text/plain']], 'py': [['.py'], ['text/x-python', 'application/x-python-code']], 'svg': [['.svg'], ['image/svg+xml']], 'toml': [['.toml'], ['application/toml']], 'vue': [['.vue'], ['text/plain']], 'xml': [['.xml'], ['application/xml']], 'yaml': [['.yaml', '.yml'], ['application/x-yaml']]}}#
- 足以提供我们所有演示文件的文件类型 
- jupyterlite_core.constants.DEFAULT_OUTPUT_DIR = '_output'#
- 需要更好的规范位置 
- jupyterlite_core.constants.DISABLED_EXTENSIONS = 'disabledExtensions'#
- 禁用扩展的配置键 
- jupyterlite_core.constants.EXTENSION_TAR = ('.tgz', '.tar.bz2', '.tar.gz')#
- 已知的压缩 tar 扩展名 
- jupyterlite_core.constants.EXTENSION_ZIP = ('.whl', '.zip', '.conda')#
- 已知的 zip 扩展名 
- jupyterlite_core.constants.FEDERATED_EXTENSIONS = 'federated_extensions'#
- 预构建扩展的配置键 
- jupyterlite_core.constants.HOOKS = ['status', 'init', 'build', 'check', 'serve', 'archive']#
- 我们基于 doit 任务的插件系统 
- jupyterlite_core.constants.HOOK_PARENTS = {'archive': 'build', 'build': 'init', 'check': 'build', 'serve': 'build'}#
- 上一个钩子的名称 
- jupyterlite_core.constants.INDEX_HTML = 'index.html'#
- 一个可预测地提供服务的 HTML 文件 
- jupyterlite_core.constants.JSON_FMT = {'indent': 2, 'sort_keys': True}#
- 规范化 JSON 的默认参数 
- jupyterlite_core.constants.JUPYTERLITE_IPYNB = 'jupyter-lite.ipynb'#
- 我们的配置文件 
- jupyterlite_core.constants.JUPYTERLITE_JSON = 'jupyter-lite.json'#
- 我们的配置文件 
- jupyterlite_core.constants.JUPYTERLITE_SCHEMA = 'jupyterlite.schema.v0.json'#
- 我们的模式 
- jupyterlite_core.constants.JUPYTER_CONFIG_DATA = 'jupyter-config-data'#
- 大多数 jupyter 页面上的脚本 DOM ID 
- jupyterlite_core.constants.LITE_PLUGIN_SETTINGS = 'litePluginSettings'#
- lite 插件设置的顶层键 
- jupyterlite_core.constants.MOD_DIRECTORY = 493#
- 目录的默认权限 
- jupyterlite_core.constants.MOD_FILE = 420#
- 文件的默认权限 
- jupyterlite_core.constants.NPM_SOURCE_DATE_EPOCH = 499162500#
- 这是通过检查得出的 
- jupyterlite_core.constants.OVERRIDES_JSON = 'overrides.json'#
- 设置覆盖。用于 JupyterLab 构建系统,通常位于 $PREFIX/share/jupyter/lab/ 
- jupyterlite_core.constants.PACKAGE_JSON = 'package.json'#
- labextension 元数据的规范位置 
- jupyterlite_core.constants.PHASES = ['pre_', '', 'post_']#
- 钩子内部的生命周期阶段 
- jupyterlite_core.constants.REQUIREMENTS_TXT = 'requirements.txt'#
- 常用的 pip 需求列表 
- jupyterlite_core.constants.SETTINGS_FILE_TYPES = 'fileTypes'#
- 文件类型的配置键 
- jupyterlite_core.constants.SETTINGS_OVERRIDES = 'settingsOverrides'#
- 扩展设置覆盖的配置键 
- jupyterlite_core.constants.SHA256SUMS = 'SHA256SUMS'#
- 提供本地数据清单的 sha256sum * 等效输出 
- jupyterlite_core.constants.SHARE_LABEXTENSIONS = 'share/jupyter/labextensions'#
- 环境中(或存档中)labextensions 的规范位置 
- jupyterlite_core.constants.SOURCEMAPS = ['.js.map', '.mjs.map']#
- 被视为源映射的扩展名 
- jupyterlite_core.constants.SOURCE_DATE_EPOCH = 'SOURCE_DATE_EPOCH'#
- 触发可重现构建的规范环境变量 
- jupyterlite_core.constants.UTF8 = {'encoding': 'utf-8'}#
- 几乎所有 JupyterLite 写入和读取的文件的编码 
应用#
JupyterLite 命令行应用
- class jupyterlite_core.app.BaseLiteApp(**kwargs)#
- TODO: 一个未描述的应用 - property aliases#
- 获取 CLI 别名,包括插件提供的别名。 
 - emit_alias_help()#
- 生成帮助中别名部分的行。 - 复制自 - 与上游不同,这也考虑了 Addon 类(及其父类)。 
 - property flags#
- 获取 CLI 标志,包括插件提供的标志。 
 
- class jupyterlite_core.app.DescribedMixin#
- 一个自描述混合 
- class jupyterlite_core.app.LiteApp(**kwargs)#
- 构建即用型(或可发布)JupyterLite 站点 
- class jupyterlite_core.app.LiteArchiveApp(**kwargs)#
- 构建 JupyterLite 应用存档,可用作基线 
- class jupyterlite_core.app.LiteBuildApp(**kwargs)#
- 构建 JupyterLite 站点,包括用户内容 
- class jupyterlite_core.app.LiteCheckApp(**kwargs)#
- 使用可用模式和规则验证 JupyterLite 站点 
- class jupyterlite_core.app.LiteInitApp(**kwargs)#
- 从应用存档基线初始化 JupyterLite 站点 
- class jupyterlite_core.app.LiteListApp(**kwargs)#
- 描述 JupyterLite 站点 
- class jupyterlite_core.app.LiteRawDoitApp(**kwargs)#
- 使用完整的 doit CLI,请参阅 https://pydoit.org/contents.html - 告诉 jupyter 不要使用 – 解析参数,例如 - jupyter-lite doit – –help - parse_command_line(argv=None)#
- 解析命令行参数。 
 
- class jupyterlite_core.app.LiteServeApp(**kwargs)#
- 使用最佳可用 HTTP 服务器提供 JupyterLite 站点服务 
- class jupyterlite_core.app.LiteStatusApp(**kwargs)#
- 报告 JupyterLite 构建可能执行的操作 
- class jupyterlite_core.app.LiteTaskApp(**kwargs)#
- 运行 doit 任务,可选带 –force - property flags#
- CLI 标志,包括一些自定义标志。 
 - force#
- 忘记任务的先前运行并从头开始重新运行 
 - start()#
- 启动所有内容 
 
- jupyterlite_core.app.lite_flags = {'debug': ({'Application': {'log_level': 10}}, 'set log level to logging.DEBUG (maximize logging output)'), 'ignore-sys-prefix': ({'LiteBuildConfig': {'ignore_sys_prefix': True}}, 'Do not copy anything from sys.prefix'), 'no-libarchive': ({'LiteBuildConfig': {'no_libarchive': True}}, 'Do not try to use libarchive-c for archive operations'), 'no-sourcemaps': ({'LiteBuildConfig': {'no_sourcemaps': True}}, 'Strip all sourcemaps from applications and extensions'), 'no-unused-shared-packages': ({'LiteBuildConfig': {'no_unused_shared_packages': True}}, 'Remove shared packages not used by --apps'), 'y': ({'JupyterApp': {'answer_yes': True}}, 'Answer yes to any questions instead of prompting.')}#
- 所有已发现插件的全部标志 
管理器#
JupyterLite 管理器
- class jupyterlite_core.manager.LiteManager(**kwargs)#
- JupyterLite 站点构建管理器 - 这主要处理将 _addons_ 映射到 - doit_tasks_,然后调用- doitAPI 的业务。- create_addons()#
- 从 entry_points 初始化插件 - 如果已填充,将查询 - disable_addons。- 子类可以选择覆盖此方法,但鼓励包含默认插件 
 - doit_run(task, *args, raw=False)#
- 运行 doit 命令行的一个子集 
 - initialize()#
- 执行管理器的一次性初始化 
 - parsed_extra_args#
- LiteManager未使用的额外 CLI 参数
 - strict#
- 如果为 True,则在第一个错误时停止当前工作流 
 - task_prefix#
- 附加到此管理器生成的所有任务的前缀 
 
插件#
存档#
用于生成可用作输入的应用程序存档的 JupyterLite 插件
- class jupyterlite_core.addons.archive.ArchiveAddon(**kwargs: Any)#
- 将 - lite_dir中的内容添加到- output_dir,创建 API 输出- 如果设置了 - --source-date-epoch(SDE),将启用多项功能以提高最终工件的可重现性。除了将比 SDE 新的时间戳“钳制”到 SDE 之外,这还将调整 tarball 中的一些权限- archive(manager)#
- 将 - pre_archive之前创建的所有文件添加到存档
 - filter_tarinfo(tarinfo)#
- 尽力应用熵修复以提供更可重现的存档 
 - log_archive(tarball, prefix='')#
- 打印有关存档的一些信息 
 - make_archive_stdlib(tarball, root, members)#
- 实际构建存档。 - 这比任何其他钩子花费的时间都长
- 虽然需要维护这种纯 Python 实现,但基于 - libarchive的构建可能更适合例如 CI 性能。
 
 
- npm 兼容的 - .tgz是唯一受支持的存档格式,因为它与上游- webpack构建及其原生打包格式兼容。
 
 - setlocale(name)#
- 用于更改当前区域设置的上下文管理器 
 
基础#
- class jupyterlite_core.addons.base.BaseAddon(**kwargs: Any)#
- JupyterLite 构建链插件的基类 - 子类化是可选的,但提供了一些有用的实用程序 - copy_one(src, dest)#
- 复制一个 Path(一个文件或文件夹) 
 - dedupe_federated_extensions(config)#
- 就地更新 federated_extension 列表,确保名称唯一。 
 - delete_one(*src)#
- 删除...某些内容 
 - extract_one(archive, dest)#
- 将存档的内容提取到路径。 
 - fetch_one(url, dest)#
- 获取一个文件 - TODO: 启用其他后端、身份验证等。 
 - get_lite_config_paths()#
- 生成 - lite_dir中存在的所有配置路径。- 返回类型:
- Generator[- Path,- None,- None]
 
 - get_lite_plugin_settings(config_path, plugin_id)#
- 从配置路径获取插件设置。 - 键遵循 JupyterLab 设置命名约定,例如模块和标识符:rtype: - dict[- str,- Any]- @jupyterlite/contents:plugin 
 - get_output_config_paths()#
- 生成 - output_dir中可能存在的所有配置路径。- 返回类型:
- Generator[- Path,- None,- None]
 
 - property log#
- Logger 或 LoggerAdapter 实例 
 - merge_jupyter_config_data(config, in_config)#
- 合并众所周知的 - jupyter-config-data字段
 - merge_one_jupyterlite(out_path, in_paths)#
- 用 - in_paths的合并内容写入- out_path,其中所有都是有效的- jupyter-lite.*文件。
 - set_lite_plugin_settings(config_path, plugin_id, settings)#
- 在配置路径中覆盖单个插件的插件设置。 - 返回类型:
- 无
 
 - property should_use_libarchive_c#
- 是否应使用 libarchive-c(如果可用)? 
 - task(**task)#
- 确保 - doit任务格式正确。- 任务名称不能包含 - =字符 - 随意替换为- --
 
 - timestamp_one(path)#
- 将时间戳调整为比其更新的文件的 –source-date-epoch 
 
内容#
一个支持 Jupyter Server 兼容内容的 JupyterLite 插件
- class jupyterlite_core.addons.contents.ContentsAddon(**kwargs: Any)#
- 将 - lite_dir中的内容添加到- output_dir,创建 API 输出- build(manager)#
- 执行预填充 - /files/的主要用户构建
 - check(manager)#
- 验证所有 Contents API 是否有效(某种程度上) 
 - property file_src_dest#
- 将要复制的内容对 - 这些是按 逆序 处理的,因此只有最后一个路径获胜 
 - maybe_add_one_path(path, root=None)#
- 添加文件或文件夹的内容(如果未被忽略) 
 - one_contents_path(output_file_dir, api_path)#
- 懒惰地重用 - jupyter_serverContents API 生成器
 - patch_listing_timestamps(listing, sde=None)#
- 将内容列表的时间限制为 - SOURCE_DATE_EPOCH
 - post_build(manager)#
- 为 - /files/中的每个子目录创建一个 Contents API 索引
 - status(manager)#
- 生成有关内容状态的一些状态信息 
 
- class jupyterlite_core.addons.contents.DateTimeEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)#
- 一个自定义的日期感知 JSON 编码器 - default(o)#
- 在子类中实现此方法,使其返回 - o的可序列化对象,或调用基实现(以引发- TypeError)。- 例如,为了支持任意迭代器,您可以像这样实现 default - def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o) 
 
- jupyterlite_core.addons.contents.isoformat(dt)#
- 一个用于用户 - Z作为 UTC ISO 字符串的小型助手
联合扩展#
支持 federated_extensions 的 JupyterLite 插件
- class jupyterlite_core.addons.federated_extensions.FederatedExtensionAddon(**kwargs: Any)#
- 同步已安装的 federated_extensions 并更新 jupyter-lite.json - property archive_cache#
- 存档在缓存中的位置 
 - build(manager)#
- 生成 doit 任务,将每个本地扩展复制到 output_dir 
 - copy_all_federated_extensions(unarchived)#
- 实际复制文件夹中找到的所有联合扩展。 
 - copy_conda2_extensions(conda_pkg)#
- 从本地嵌套的 - .conda包复制 labextensions
 - copy_one_env_extension(pkg_json)#
- 生成任务,将一个解压的磁盘上扩展从 sys.prefix 复制到输出目录 
 - copy_one_extension(pkg_json)#
- 生成任务,将一个解压的磁盘上扩展从任何位置复制到输出目录 
 - copy_one_federated_extension(pkg_json)#
- 实际从提取的存档中复制一个 labextension 
 - copy_one_folder_extension(path)#
- 生成任务,从给定路径复制一个扩展 
 - copy_simple_archive_extensions(archive)#
- 生成任务,从本地简单存档中提取和复制 labextensions 
 - ensure_federated_settings(manager, lab_extensions, all_federated_json)#
- 确保联合扩展中的设置聚合到单个文件中 
 - env_extensions(root)#
- 所有联合扩展的列表 
 - property ext_cache#
- 扩展在缓存中的位置 
 - extra_labextensions_path#
- 查找联合 JupyterLab 扩展的额外路径 
 - get_federated_settings(extension)#
- 获取联合扩展的设置 
 - is_prebuilt(pkg_json)#
- 验证这是否是实际的预构建扩展,包含加载信息 
 - property output_extensions#
- labextensions 在输出文件夹中的位置 
 - patch_jupyterlite_json(jupyterlite_json)#
- 将 federated_extensions 添加到 jupyter-lite.json 
 - post_build(manager)#
- 更新根 jupyter-lite.json,并将每个输出主题复制到每个应用 
 - post_init(manager)#
- 处理联合扩展的下载 
 - pre_build(manager)#
- 生成 doit 任务,将每个联合扩展复制到 output_dir 
 - resolve_one_extension(path_or_url, init)#
- 生成任务,尝试将一个 URL 或本地文件夹/存档解析为(一组)federated_extension 
 
Lite#
一个用于 jupyterlite 特有任务的 JupyterLite 插件
报告#
一个用于生成哈希值的 JupyterLite 插件
服务#
一个用于提供服务的JupyterLite插件
- 类 jupyterlite_core.addons.serve.ServeAddon(**kwargs: Any)#
设置#
一个支持扩展设置的JupyterLite插件
静态#
一个用于JupyterLab核心的JupyterLite插件
- 类 jupyterlite_core.addons.static.StaticAddon(**kwargs: Any)#
- 将核心“黄金标准”工件复制到输出文件夹中 - app_archive#
- 自定义npm风格tar包的路径(例如,带有package/package.json)。这也可以通过$JUPYTERLITE_APP_ARCHIVE环境变量指定。 
 - init(manager)#
- 解压并将tar包文件复制到output_dir中 
 - post_init(manager)#
- 如果未安装应用程序,则可能移除源映射或所有静态资产 
 - pre_init(manager)#
- 在其他任何操作之前,我们需要确保output_dir存在且为空(如果基线tar包已更改) 
 - 手动从共享包中移除未使用的webpack块