Prepare EPS graphics and BibTeX references for desktop previews
This commit is contained in:
1 parent
715ad81bcf
commit
b38e39416e
8 files changed
+787
-7
No files matched your search
@@ -13,6 +13,13 @@ Texrra 桌面程序。在项目库导入包含主 .tex 文件的 ZIP,打开项
|
||||
项目存放在该目录下的 texrra-desktop/projects。窗口关闭时,桌面端停止
|
||||
自己启动的后台引擎。
|
||||
|
||||
0.1.2 在私有工作副本中转换缺少配套 PDF 的 EPS 图。转换使用包内
|
||||
Fedora Ghostscript 及 bubblewrap,随后由原生引擎读取生成的 PDF。
|
||||
现有 EPS 和已提供的转换 PDF 保留。标准 BibTeX 模板打开时从 TeX
|
||||
生成的辅助文件构建参考文献,改动已引用的数据库或样式文件时更新。
|
||||
WSL 中需要已有的 TeX Live bibtex 和 kpsewhich。模板中新增的引文及
|
||||
更换引用样式命令在重新打开保存的源项目时读取。
|
||||
|
||||
## 构建
|
||||
|
||||
在引擎仓库根目录使用已经完成定向回归的原生 release 构建回执,准备
|
||||
@@ -25,6 +32,10 @@ python3 desktop/build-backend.py prepare desktop/src-tauri/backend \
|
||||
--commit full-engine-git-commit
|
||||
```
|
||||
|
||||
包含 EPS 转换功能的安装包在上述准备命令中提供
|
||||
--eps-tools path/to/eps-tools.tar。该归档是可相对路径解包的 Fedora 工具树,
|
||||
包含 usr/bin/bwrap、usr/bin/gs、运行资源及许可证和上游源包清单。
|
||||
|
||||
在 Windows 上使用 Tauri 的 MSVC 工具链构建。在 Fedora WSL 上使用
|
||||
cargo-xwin、Windows SDK、LLVM 和 NSIS。
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
|
||||
|
||||
@@ -21,6 +22,7 @@ WEB_FILES = ("index.html", "styles.css", "favicon.svg", "app.js")
|
||||
NATIVE_FILES = ("latex.tfx", "format-resources.json")
|
||||
EDITOR = "bin/native_editor"
|
||||
RECEIPT = "desktop-bundle.json"
|
||||
EPS_TOOLS = "eps-tools.tar"
|
||||
PAYLOAD = (
|
||||
EDITOR, *NATIVE_FILES, "bundle.json", "native-beta.py", "wsl-launch.py",
|
||||
*(f"web/{name}" for name in WEB_FILES),
|
||||
@@ -54,7 +56,10 @@ def package_receipt(directory):
|
||||
data = (directory / RECEIPT).read_bytes()
|
||||
receipt = json.loads(data)
|
||||
files = receipt.get("sha256", {})
|
||||
require(receipt.get("schema") == 1 and set(files) == set(PAYLOAD), "Invalid desktop bundle receipt")
|
||||
expected = set(PAYLOAD)
|
||||
if EPS_TOOLS in files:
|
||||
expected.add(EPS_TOOLS)
|
||||
require(receipt.get("schema") == 1 and set(files) == expected, "Invalid desktop bundle receipt")
|
||||
require(all(is_sha(value) for value in files.values()), "Invalid desktop bundle hashes")
|
||||
return data, files
|
||||
|
||||
@@ -116,6 +121,9 @@ def prepare(args, repo):
|
||||
write_json(bundle / "bundle.json", manifest)
|
||||
hashes = {EDITOR: editor_sha, **native_sha}
|
||||
hashes.update({name: digest(bundle / name) for name in PAYLOAD if name not in hashes})
|
||||
if args.eps_tools:
|
||||
shutil.copyfile(args.eps_tools.resolve(strict=True), bundle / EPS_TOOLS)
|
||||
hashes[EPS_TOOLS] = digest(bundle / EPS_TOOLS)
|
||||
write_json(bundle / RECEIPT, {
|
||||
"schema": 1, "native_commit": args.commit, "web_commit": WEB_COMMIT, "sha256": hashes,
|
||||
})
|
||||
@@ -151,12 +159,26 @@ def install(package, home):
|
||||
shutil.copyfile(package / name, path)
|
||||
check_file(path, expected)
|
||||
(bundle / EDITOR).chmod(0o700)
|
||||
if EPS_TOOLS in files:
|
||||
root = bundle / "eps-tools"
|
||||
root.mkdir(mode=0o700)
|
||||
with tarfile.open(bundle / EPS_TOOLS) as archive:
|
||||
archive.extractall(root, filter="data")
|
||||
eps_environment(root)
|
||||
(bundle / RECEIPT).write_bytes(receipt)
|
||||
(bundle / "state").symlink_to(home / "state", target_is_directory=True)
|
||||
bundle.rename(destination)
|
||||
return destination
|
||||
|
||||
|
||||
def eps_environment(root):
|
||||
bubblewrap = root / "usr/bin/bwrap"
|
||||
ghostscript = root / "usr/bin/gs"
|
||||
require(all(tool.is_file() and os.access(tool, os.X_OK) for tool in (bubblewrap, ghostscript)),
|
||||
"Desktop EPS converter is missing or incomplete")
|
||||
return {"TEXRRA_EPS_BWRAP": str(bubblewrap), "TEXRRA_EPS_GS_ROOT": str(root)}
|
||||
|
||||
|
||||
def launch_error(message):
|
||||
detail = " ".join(str(message).splitlines())
|
||||
print(f"Texrra desktop error {detail}", flush=True)
|
||||
@@ -187,8 +209,10 @@ def launch(args):
|
||||
sys.executable, bundle / "native-beta.py", "web", "--web-dir", bundle / "web",
|
||||
"--projects-dir", home / "projects", "--port", "0",
|
||||
]
|
||||
with subprocess.Popen(command, stdin=subprocess.DEVNULL,
|
||||
env=dict(os.environ, **{INSTANCE_ENV: args.instance})) as child:
|
||||
env = dict(os.environ, **{INSTANCE_ENV: args.instance})
|
||||
if (bundle / EPS_TOOLS).is_file():
|
||||
env.update(eps_environment(bundle / "eps-tools"))
|
||||
with subprocess.Popen(command, stdin=subprocess.DEVNULL, env=env) as child:
|
||||
try:
|
||||
print(f"Texrra desktop PID {child.pid}", flush=True)
|
||||
while child.poll() is None:
|
||||
@@ -238,6 +262,7 @@ def main():
|
||||
stage.add_argument("output", type=Path)
|
||||
stage.add_argument("--artifact-dir", type=Path, required=True)
|
||||
stage.add_argument("--commit", required=True)
|
||||
stage.add_argument("--eps-tools", type=Path, help="optional Fedora EPS converter tar archive")
|
||||
stage.add_argument("--reference-bundle", type=Path,
|
||||
default=repo / "target/p4-a4-child-release/browser-bundle")
|
||||
stage.add_argument("--web-repo", type=Path, default=repo.parent / "texrra-web")
|
||||
|
||||
Generated
+1
-1
@@ -3237,7 +3237,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "texrra-desktop"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"serde_json",
|
||||
"tauri",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "texrra-desktop"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2024"
|
||||
rust-version = "1.92"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Texrra",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"identifier": "org.texrra.desktop",
|
||||
"build": {
|
||||
"frontendDist": "../startup"
|
||||
|
||||
Reference in new issue
Block a user