Skip to content

Commit e2651f7

Browse files
committed
feat: implement shared runtime management for Windows, including installation, repair, and status commands
1 parent 7dcd324 commit e2651f7

9 files changed

Lines changed: 764 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- 默认启用 `.docugenius.json` 项目配置文件创建,确保项目启用/禁用状态可持久化
88
- 同步调整设置文案与运行时默认值,避免配置声明与代码兜底不一致
9+
- Windows 改为使用扩展级共享 runtime:首次确认后统一安装到全局存储目录,不再向每个工作区单独安装依赖
10+
- 新增共享 runtime 的安装、修复、状态命令,并将依赖准备流程迁移到 VS Code 原生通知、进度和日志通道中
911

1012
## [2.5.0] - 2025-04-14
1113

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,25 @@ DocuGenius 是一个 VSCode 插件,将 Word、Excel、PowerPoint、PDF 转换
9090
```bash
9191
sudo /usr/sbin/softwareupdate --install-rosetta --agree-to-license
9292
```
93-
- **Windows**:需预先安装 Python 3.6+(依赖库会自动安装)
93+
- **Windows**:需预先安装 Python 3.6+
94+
- 首次转换时,DocuGenius 会先提示你安装一套**共享本地运行时**
95+
- 这套运行时只会安装在扩展自己的存储目录中,并在所有工作区之间复用
96+
- 不会向每个项目目录单独创建 `.venv`,也不会把依赖安装到当前工作区
97+
98+
## Windows 运行时说明
99+
100+
在 Windows 上,DocuGenius 会使用系统里的 Python **只做一次引导**
101+
102+
1. 检测本机是否存在可用的 Python
103+
2. 在扩展的全局存储目录里创建一套共享运行时
104+
3.`python-docx``openpyxl``python-pptx``pdfplumber` 安装到这套共享运行时
105+
4. 后续所有工作区都复用这套运行时进行转换
106+
107+
如果你需要手动处理运行时,可以从命令面板使用:
108+
109+
- `DocuGenius: Install Shared Runtime`
110+
- `DocuGenius: Repair Shared Runtime`
111+
- `DocuGenius: Show Runtime Status`
94112

95113
## 常见问题
96114

@@ -106,6 +124,10 @@ A: 文档转换过程完全在本地执行,不会上传到任何服务器。
106124

107125
A: 不支持。DocuGenius 专注文档转换,如需在 IDE 中预览原始文件,建议搭配 Office Viewer 类插件使用。
108126

127+
**Q: Windows 会不会给每个项目都安装一份依赖?**
128+
129+
A: 不会。DocuGenius 现在会把 Windows 运行时安装到扩展自己的共享目录中,所有工作区共用一份,不会污染每个项目目录。
130+
109131
## 作者
110132

111133
- X: [@bruc3van](https://x.com/bruc3van)

bin/converter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2572,7 +2572,8 @@ def main():
25722572

25732573
# 调用对应转换函数
25742574
try:
2575-
deps_ok, err = check_dependencies(file_ext)
2575+
auto_install_deps = os.environ.get('DOCUGENIUS_AUTO_INSTALL_DEPS', '1').lower() not in ('0', 'false', 'no')
2576+
deps_ok, err = check_dependencies(file_ext, auto_install=auto_install_deps)
25762577
if not deps_ok:
25772578
print(f"Error: {err}", file=sys.stderr)
25782579
sys.exit(1)

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,21 @@
155155
"command": "documentConverter.showProjectStatus",
156156
"title": "%command.showProjectStatus.title%",
157157
"category": "DocuGenius"
158+
},
159+
{
160+
"command": "documentConverter.installRuntime",
161+
"title": "%command.installRuntime.title%",
162+
"category": "DocuGenius"
163+
},
164+
{
165+
"command": "documentConverter.repairRuntime",
166+
"title": "%command.repairRuntime.title%",
167+
"category": "DocuGenius"
168+
},
169+
{
170+
"command": "documentConverter.showRuntimeStatus",
171+
"title": "%command.showRuntimeStatus.title%",
172+
"category": "DocuGenius"
158173
}
159174
],
160175
"menus": {

package.nls.json

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"command.enableProject.title": "[DocuGenius]Enable for Current Project",
2929
"command.disableProject.title": "[DocuGenius]Disable for Current Project",
3030
"command.showProjectStatus.title": "[DocuGenius]Show Project Status",
31+
"command.installRuntime.title": "[DocuGenius]Install Shared Runtime",
32+
"command.repairRuntime.title": "[DocuGenius]Repair Shared Runtime",
33+
"command.showRuntimeStatus.title": "[DocuGenius]Show Runtime Status",
3134

3235
"message.ready": "DocuGenius is ready!",
3336
"message.projectEnabled": "Project enabled",
@@ -51,6 +54,7 @@
5154
"status.batchPartial": "{0}/{1} converted",
5255
"status.configUpdated": "Config updated",
5356
"status.skipped": "Skipped {0}",
57+
"status.runtimePreparing": "Preparing runtime...",
5458
"tooltip.ready": "DocuGenius: {0}",
5559
"tooltip.converting": "Converting {0} to Markdown",
5660
"tooltip.converted": "Successfully converted {0}",
@@ -74,5 +78,40 @@
7478
"log.watcherEnabled": "File watcher enabled for extensions: {0}",
7579
"log.watcherDisabled": "File watcher disabled",
7680
"log.fileSkipped": "Skipped {0}: {1}",
77-
"log.batchProgress": "Converting ({0}): {1}"
81+
"log.batchProgress": "Converting ({0}): {1}",
82+
"log.runtime.bootstrap": "Preparing shared runtime with bootstrap Python: {0}",
83+
"log.runtime.installPackages": "Installing shared runtime packages: {0}",
84+
"log.runtime.ready": "Shared runtime is ready: {0}",
85+
"log.runtime.failed": "Shared runtime setup failed: {0}",
86+
"runtime.action.install": "Install Runtime",
87+
"runtime.action.repair": "Repair Runtime",
88+
"runtime.action.viewDetails": "View Details",
89+
"runtime.action.notNow": "Not Now",
90+
"runtime.action.openLogs": "Open Logs",
91+
"runtime.action.openPythonDownload": "Install Python",
92+
"runtime.prompt.manualTitle": "DocuGenius needs a shared local runtime before it can convert documents on Windows.",
93+
"runtime.prompt.backgroundTitle": "DocuGenius found documents to convert, but the shared runtime is not ready yet.",
94+
"runtime.progress.installTitle": "Installing DocuGenius shared runtime...",
95+
"runtime.progress.repairTitle": "Repairing DocuGenius shared runtime...",
96+
"runtime.progress.creatingEnvironment": "Creating an isolated shared Python environment...",
97+
"runtime.progress.installingDependencies": "Installing required conversion packages into the shared runtime...",
98+
"runtime.progress.verifying": "Verifying the shared runtime...",
99+
"runtime.success.ready": "DocuGenius shared runtime is ready.",
100+
"runtime.error.installFailed": "DocuGenius could not prepare the shared runtime. Open the logs to see the full setup output.",
101+
"runtime.error.pythonMissing": "DocuGenius could not find Python 3.6+ on this machine. Install Python once to bootstrap the shared runtime.",
102+
"runtime.error.setupDeferred": "DocuGenius skipped conversion because the shared runtime is not ready yet.",
103+
"runtime.error.verifyFailed": "The shared runtime was created, but dependency verification failed.",
104+
"runtime.error.invalidRuntimePath": "Refusing to modify a runtime path outside the extension storage directory.",
105+
"runtime.error.timeout": "Command timed out after {0} seconds while preparing the shared runtime.",
106+
"runtime.detail.ready": "The shared runtime is installed and verified.",
107+
"runtime.detail.installRequired": "The shared runtime has not been installed yet. DocuGenius will create one copy for this extension and reuse it across workspaces.",
108+
"runtime.detail.repairRequired": "The shared runtime exists, but it is missing files or dependencies and needs repair.",
109+
"runtime.detail.missingPython": "Python is required once to bootstrap the shared runtime. DocuGenius will not install dependencies into each workspace.",
110+
"runtime.status.readyTitle": "DocuGenius shared runtime is ready.",
111+
"runtime.status.issueTitle": "DocuGenius shared runtime needs attention.",
112+
"runtime.status.notManagedPlatform": "This platform uses the built-in bundled converter and does not need a managed Python runtime.",
113+
"runtime.status.locationLabel": "Location",
114+
"runtime.status.versionLabel": "Runtime version",
115+
"runtime.status.bootstrapLabel": "Bootstrap Python",
116+
"runtime.status.detailLabel": "Details"
78117
}

package.nls.zh-cn.json

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"command.enableProject.title": "[DocuGenius]为当前项目启用",
2929
"command.disableProject.title": "[DocuGenius]为当前项目禁用",
3030
"command.showProjectStatus.title": "[DocuGenius]显示项目状态",
31+
"command.installRuntime.title": "[DocuGenius]安装共享运行时",
32+
"command.repairRuntime.title": "[DocuGenius]修复共享运行时",
33+
"command.showRuntimeStatus.title": "[DocuGenius]显示运行时状态",
3134

3235
"message.ready": "DocuGenius 已就绪!",
3336
"message.projectEnabled": "项目已启用",
@@ -51,6 +54,7 @@
5154
"status.batchPartial": "{0}/{1} 已转换",
5255
"status.configUpdated": "配置已更新",
5356
"status.skipped": "已跳过 {0}",
57+
"status.runtimePreparing": "正在准备运行时...",
5458
"tooltip.ready": "DocuGenius: {0}",
5559
"tooltip.converting": "正在转换 {0} ",
5660
"tooltip.converted": "成功转换 {0}",
@@ -74,5 +78,40 @@
7478
"log.watcherEnabled": "文件监控已启用,支持扩展名: {0}",
7579
"log.watcherDisabled": "文件监控已禁用",
7680
"log.fileSkipped": "已跳过 {0}: {1}",
77-
"log.batchProgress": "转换中 ({0}): {1}"
81+
"log.batchProgress": "转换中 ({0}): {1}",
82+
"log.runtime.bootstrap": "正在使用引导 Python 准备共享运行时: {0}",
83+
"log.runtime.installPackages": "正在向共享运行时安装依赖: {0}",
84+
"log.runtime.ready": "共享运行时已就绪: {0}",
85+
"log.runtime.failed": "共享运行时准备失败: {0}",
86+
"runtime.action.install": "安装运行时",
87+
"runtime.action.repair": "修复运行时",
88+
"runtime.action.viewDetails": "查看详情",
89+
"runtime.action.notNow": "稍后再说",
90+
"runtime.action.openLogs": "打开日志",
91+
"runtime.action.openPythonDownload": "安装 Python",
92+
"runtime.prompt.manualTitle": "DocuGenius 在 Windows 上转换文档前,需要先准备一套共享本地运行时。",
93+
"runtime.prompt.backgroundTitle": "DocuGenius 检测到待转换文档,但共享运行时尚未准备好。",
94+
"runtime.progress.installTitle": "正在安装 DocuGenius 共享运行时...",
95+
"runtime.progress.repairTitle": "正在修复 DocuGenius 共享运行时...",
96+
"runtime.progress.creatingEnvironment": "正在创建隔离的共享 Python 环境...",
97+
"runtime.progress.installingDependencies": "正在向共享运行时安装文档转换依赖...",
98+
"runtime.progress.verifying": "正在验证共享运行时...",
99+
"runtime.success.ready": "DocuGenius 共享运行时已就绪。",
100+
"runtime.error.installFailed": "DocuGenius 无法准备共享运行时。请打开日志查看完整安装输出。",
101+
"runtime.error.pythonMissing": "DocuGenius 未在当前机器上找到 Python 3.6+。需要先安装一次 Python,才能引导共享运行时。",
102+
"runtime.error.setupDeferred": "由于共享运行时尚未准备好,DocuGenius 已跳过本次转换。",
103+
"runtime.error.verifyFailed": "共享运行时已创建,但依赖校验失败。",
104+
"runtime.error.invalidRuntimePath": "拒绝修改扩展存储目录之外的运行时路径。",
105+
"runtime.error.timeout": "准备共享运行时时命令执行超时,已超过 {0} 秒。",
106+
"runtime.detail.ready": "共享运行时已安装并完成校验。",
107+
"runtime.detail.installRequired": "共享运行时尚未安装。DocuGenius 会为当前扩展创建一份共享运行时,并在所有工作区之间复用。",
108+
"runtime.detail.repairRequired": "共享运行时已存在,但缺少文件或依赖,需要修复。",
109+
"runtime.detail.missingPython": "共享运行时只需要用 Python 引导一次。DocuGenius 不会再向每个工作区单独安装依赖。",
110+
"runtime.status.readyTitle": "DocuGenius 共享运行时已就绪。",
111+
"runtime.status.issueTitle": "DocuGenius 共享运行时需要处理。",
112+
"runtime.status.notManagedPlatform": "当前平台使用内置打包转换器,不需要托管 Python 运行时。",
113+
"runtime.status.locationLabel": "位置",
114+
"runtime.status.versionLabel": "运行时版本",
115+
"runtime.status.bootstrapLabel": "引导 Python",
116+
"runtime.status.detailLabel": "说明"
78117
}

0 commit comments

Comments
 (0)