mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04: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
f3e81c8a95
commit
99cb6c616e
1 changed files with 4 additions and 8 deletions
|
@ -9,8 +9,10 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
(protoc, mypy_protobuf, outdir, *protos) = sys.argv[1:]
|
(protoc, mypy_protobuf, outdir, *protos) = sys.argv[1:]
|
||||||
|
outpath = Path(outdir).parent
|
||||||
|
|
||||||
if protos[0].startswith("external"):
|
if protos[0].startswith("external"):
|
||||||
prefix = "external/ankidesktop/proto/"
|
prefix = "external/ankidesktop/proto/"
|
||||||
|
@ -22,8 +24,8 @@ subprocess.run(
|
||||||
[
|
[
|
||||||
protoc,
|
protoc,
|
||||||
f"--plugin=protoc-gen-mypy={mypy_protobuf}",
|
f"--plugin=protoc-gen-mypy={mypy_protobuf}",
|
||||||
"--python_out=.",
|
f"--python_out={outpath}",
|
||||||
"--mypy_out=.",
|
f"--mypy_out={outpath}",
|
||||||
f"-I{prefix}",
|
f"-I{prefix}",
|
||||||
f"-Iexternal/ankidesktop/{prefix}",
|
f"-Iexternal/ankidesktop/{prefix}",
|
||||||
*protos,
|
*protos,
|
||||||
|
@ -32,9 +34,3 @@ subprocess.run(
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
check=True,
|
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