OpenDrama 核心库:编剧 / 资产 / 分镜 / 视频 / 后期流水线(web.Runner)
Project description
OpenDrama(Python 包)
本目录提供 setup.py,用于把同级的 OpenDrama/ 目录打成可安装的 Python 分发包(包名 opendrama)。
源码布局是扁平顶层导入(例如 from web import Runner),与 OpenDrama_Web 里 backend 的用法一致。
当前 setup.py 中的分发版本 为 0.1.0(发布请在 submodules/setup.py 的 _VERSION 处递增)。
与本仓库 backend / web 的关系
backend(FastAPI)并不通过 PyPI 依赖本包;它在运行时把 OpenDrama 根目录 插入sys.path,再执行与 CLI 相同的导入:from web import Runnerfrom utils.common_utils import load_configfrom step0_config import Step0_SetConfig- 并在调用前设置
CONFIG_PATH指向项目 YAML(绝对路径)。 - 默认 OpenDrama 根目录为仓库内
OpenDrama_Web/submodules/OpenDrama;可通过整站配置 / 环境变量OPENDRAMA_ROOT指向其它检出路径(须含config/default.yaml)。
web(Vite 前端)通过/api/v1/...调用上述后端;本地开发时由 Vite 把/api代理到后端端口。前端里@opendramaRoot等别名仍指向子模块目录,与「是否 pip 安装 opendrama」无关。
若你希望在任意虚拟环境里 import web / import utils 而不手动改 sys.path,可使用本 setup.py 安装(见下文)。
安装
在 OpenDrama_Web/submodules 下执行:
# 可编辑安装(开发推荐;与直接改 OpenDrama/ 源码一致)
pip install -e .
# 或打 wheel / 安装发行版
pip install .
完整依赖见 OpenDrama/requirements.txt。其中 -r submodules/MediaCrawler/requirements.txt 在打包时会被忽略(避免未检出 MediaCrawler 时安装失败);若你需要爬虫相关能力,请自行按 OpenDrama 仓库说明安装 MediaCrawler 及其依赖。
系统工具(非 pip):流水线中的后期与视频工具会通过子进程调用 FFmpeg 等,请安装并保证在 PATH 中。
使用方式(与 backend 对齐的最小示例)
import os
from pathlib import Path
from utils.common_utils import load_config
from web import Runner
cfg_path = os.environ.get("CONFIG_PATH") or str(
Path("/path/to/OpenDrama/config/your_project.yaml").resolve()
)
os.environ["CONFIG_PATH"] = cfg_path
cfg = load_config(cfg_path)
runner = Runner(cfg)
# 再调用 runner 上与 web 流程一致的方法(由业务 YAML 与步骤决定)
要点:
CONFIG_PATH:必须指向已存在的项目 YAML;load_config/Runner依赖其中的save_dir、env等字段。utils.common_utils中的工程根_PROJECT_ROOT由utils/common_utils.py的位置推导:可编辑安装时即为你的OpenDrama/目录;普通安装时为 site-packages 根(本包会把config/、prompt/、admin/等数据装到同一根下,以便默认能找到config/default.yaml等)。- 顶层模块名
web较通用;若环境中有同名包,请使用虚拟环境隔离。
许可
以 OpenDrama 上游仓库为准(本文件仅描述打包与集成方式)。
OpenDrama (Python package)
This directory contains setup.py to build the sibling OpenDrama/ tree into an installable Python distribution named opendrama.
The code layout uses flat top-level imports (e.g. from web import Runner), matching how OpenDrama_Web’s backend uses it.
The distribution version in setup.py is 0.1.0 (bump _VERSION in submodules/setup.py when releasing).
How this relates to backend / web in this repo
backend(FastAPI) does not depend on this package via PyPI. At runtime it prepends the OpenDrama root tosys.pathand uses the same imports as the CLI:from web import Runnerfrom utils.common_utils import load_configfrom step0_config import Step0_SetConfig- Set
CONFIG_PATHto your project YAML (absolute path) before calling into OpenDrama. - By default the OpenDrama root is
OpenDrama_Web/submodules/OpenDrama; override with site config /OPENDRAMA_ROOT(must containconfig/default.yaml).
web(Vite frontend) talks to that backend via/api/v1/...; in local dev, Vite proxies/apito the API port. Aliases like@opendramaRootstill point at the submodule tree and are unrelated to whether youpip install opendrama.
Use this setup.py when you want import web / import utils in any venv without manually editing sys.path.
Installation
From OpenDrama_Web/submodules:
# Editable install (recommended for dev; edits in OpenDrama/ apply immediately)
pip install -e .
# Or build/install a wheel
pip install .
Full Python deps are listed in OpenDrama/requirements.txt. The line -r submodules/MediaCrawler/requirements.txt is skipped during packaging so installs do not fail when MediaCrawler is missing; install crawler deps separately if you need that stack.
System tools (not from pip): post-processing and video helpers invoke FFmpeg (and similar) via subprocess—install them and ensure they are on PATH.
Minimal usage (aligned with backend)
import os
from pathlib import Path
from utils.common_utils import load_config
from web import Runner
cfg_path = os.environ.get("CONFIG_PATH") or str(
Path("/path/to/OpenDrama/config/your_project.yaml").resolve()
)
os.environ["CONFIG_PATH"] = cfg_path
cfg = load_config(cfg_path)
runner = Runner(cfg)
# Then call the same Runner methods as in the web flow (depends on your YAML and step)
Notes:
CONFIG_PATHmust point to an existing project YAML;load_config/Runnerrely on fields such assave_dir,env, etc.utils.common_utilsderives project root_PROJECT_ROOTfromutils/common_utils.py’s location: editable installs resolve to yourOpenDrama/checkout; plain installs resolve to site-packages (this package installsconfig/,prompt/,admin/next toutils/so defaults likeconfig/default.yamlstill resolve).- The top-level module name
webis generic; use a dedicated virtualenv if you risk clashing with anotherwebpackage.
License
Follow the upstream OpenDrama repository (this file only describes packaging and integration).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opendrama-0.1.0.tar.gz.
File metadata
- Download URL: opendrama-0.1.0.tar.gz
- Upload date:
- Size: 391.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
706d80b5a255e41139518d5330f99f68baed339b7ad260d9c9ea355151e1a236
|
|
| MD5 |
cf27fdd026ceae916e3fcd4d2e5c1348
|
|
| BLAKE2b-256 |
8ea77f6046d4e62cb33b4b485a60e99495b43b5333b246ab83a177285c58bb03
|
File details
Details for the file opendrama-0.1.0-py3-none-any.whl.
File metadata
- Download URL: opendrama-0.1.0-py3-none-any.whl
- Upload date:
- Size: 452.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd731679c69f36ad9152b19d9b282ac94ebd1c8b2f36fa294b6b29fffaa00c44
|
|
| MD5 |
8e6824a4023f646168541ca6060ede8e
|
|
| BLAKE2b-256 |
1d4ca54e361eb04ffa8a2a7c471fc76b69bfc47e74def26a6956b032d3756796
|