mirror of
https://github.com/ankitects/anki.git
synced 2026-01-13 22:13:58 -05:00
Fix intermittent anki/backend_pb2.py build error on Windows
The _pb2 files are built for both the host and target architectures (which seems superfluous - we may be able to fix that in the future). Our script wrote the files into the build folder and then moved them into the correct place, but because builds are not sandboxed on Windows, the two actions were racy, and could cause each other to fail. Solved by writing the files directly into their target locations.
This commit is contained in:
parent
1939f2bfd5
commit
5d09232ae3
1 changed files with 4 additions and 8 deletions
|
|
@ -9,8 +9,10 @@ import os
|
|||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
(protoc, mypy_protobuf, outdir, *protos) = sys.argv[1:]
|
||||
outpath = Path(outdir).parent
|
||||
|
||||
if protos[0].startswith("external"):
|
||||
prefix = "external/ankidesktop/proto/"
|
||||
|
|
@ -22,8 +24,8 @@ subprocess.run(
|
|||
[
|
||||
protoc,
|
||||
f"--plugin=protoc-gen-mypy={mypy_protobuf}",
|
||||
"--python_out=.",
|
||||
"--mypy_out=.",
|
||||
f"--python_out={outpath}",
|
||||
f"--mypy_out={outpath}",
|
||||
f"-I{prefix}",
|
||||
f"-Iexternal/ankidesktop/{prefix}",
|
||||
*protos,
|
||||
|
|
@ -32,9 +34,3 @@ subprocess.run(
|
|||
stderr=subprocess.DEVNULL,
|
||||
check=True,
|
||||
)
|
||||
|
||||
for proto in protos:
|
||||
without_prefix_and_ext, _ = os.path.splitext(proto[len(prefix) :])
|
||||
for ext in "_pb2.py", "_pb2.pyi":
|
||||
path = without_prefix_and_ext + ext
|
||||
shutil.move(path, os.path.join(outdir, os.path.basename(path)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue