Skip to main content

OpenDrama 核心库:编剧 / 资产 / 分镜 / 视频 / 后期流水线(web.Runner)

Project description

OpenDrama(Python 包)

English

本目录提供 setup.py,用于把同级的 OpenDrama/ 目录打成可安装的 Python 分发包(包名 opendrama)。
源码布局是扁平顶层导入(例如 from web import Runner),与 OpenDrama_Webbackend 的用法一致。

当前 setup.py 中的分发版本0.1.0(发布请在 submodules/setup.py_VERSION 处递增)。

与本仓库 backend / web 的关系

  • backend(FastAPI)并不通过 PyPI 依赖本包;它在运行时把 OpenDrama 根目录 插入 sys.path,再执行与 CLI 相同的导入:
    • from web import Runner
    • from utils.common_utils import load_config
    • from 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_direnv 等字段。
  • utils.common_utils 中的工程根 _PROJECT_ROOTutils/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 to sys.path and uses the same imports as the CLI:
    • from web import Runner
    • from utils.common_utils import load_config
    • from step0_config import Step0_SetConfig
    • Set CONFIG_PATH to 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 contain config/default.yaml).
  • web (Vite frontend) talks to that backend via /api/v1/...; in local dev, Vite proxies /api to the API port. Aliases like @opendramaRoot still point at the submodule tree and are unrelated to whether you pip 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_PATH must point to an existing project YAML; load_config / Runner rely on fields such as save_dir, env, etc.
  • utils.common_utils derives project root _PROJECT_ROOT from utils/common_utils.py’s location: editable installs resolve to your OpenDrama/ checkout; plain installs resolve to site-packages (this package installs config/, prompt/, admin/ next to utils/ so defaults like config/default.yaml still resolve).
  • The top-level module name web is generic; use a dedicated virtualenv if you risk clashing with another web package.

License

Follow the upstream OpenDrama repository (this file only describes packaging and integration).

Project details


Download files

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

Source Distribution

opendrama-0.1.0.tar.gz (391.5 kB view details)

Uploaded Source

Built Distribution

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

opendrama-0.1.0-py3-none-any.whl (452.4 kB view details)

Uploaded Python 3

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

Hashes for opendrama-0.1.0.tar.gz
Algorithm Hash digest
SHA256 706d80b5a255e41139518d5330f99f68baed339b7ad260d9c9ea355151e1a236
MD5 cf27fdd026ceae916e3fcd4d2e5c1348
BLAKE2b-256 8ea77f6046d4e62cb33b4b485a60e99495b43b5333b246ab83a177285c58bb03

See more details on using hashes here.

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

Hashes for opendrama-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd731679c69f36ad9152b19d9b282ac94ebd1c8b2f36fa294b6b29fffaa00c44
MD5 8e6824a4023f646168541ca6060ede8e
BLAKE2b-256 1d4ca54e361eb04ffa8a2a7c471fc76b69bfc47e74def26a6956b032d3756796

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page