handle packaged pylib buildinfo.txt; drop aqt buildinfo

This commit is contained in:
Damien Elmes 2020-11-10 13:50:59 +10:00
parent 013d1d404a
commit 6e3f971ae1
5 changed files with 26 additions and 32 deletions

View file

@ -2,13 +2,32 @@
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os
import sys
from typing import Dict
_buildinfo = {}
for line in open(os.path.join(os.path.dirname(__file__), "buildinfo.txt")).readlines():
elems = line.split()
if len(elems) == 2:
k, v = elems
_buildinfo[k] = v
def _build_info_path() -> str:
path = os.path.join(os.path.dirname(__file__), "buildinfo.txt")
# running in place?
if os.path.exists(path):
return path
# packaged build?
path = os.path.join(sys.prefix, "buildinfo.txt")
if os.path.exists(path):
return path
raise Exception("missing buildinfo.txt")
def _get_build_info() -> Dict[str, str]:
info = {}
for line in open(_build_info_path()).readlines():
elems = line.split()
if len(elems) == 2:
k, v = elems
info[k] = v
return info
_buildinfo = _get_build_info()
buildhash=_buildinfo["STABLE_BUILDHASH"]
version=_buildinfo["STABLE_VERSION"]

View file

@ -4,12 +4,6 @@ load("@py_deps//:requirements.bzl", "requirement")
load("@rules_python//experimental/python:wheel.bzl", "py_package", "py_wheel")
load("//:defs.bzl", "anki_version")
copy_file(
name = "buildinfo",
src = "//:buildinfo.txt",
out = "buildinfo.txt",
)
genrule(
name = "hooks_gen",
outs = ["hooks_gen.py"],
@ -37,7 +31,6 @@ aqt_srcs = glob([
]
aqt_core_data = [
"buildinfo.txt",
"colors.py",
"py.typed",
":hooks_gen",

View file

@ -12,9 +12,7 @@ import tempfile
import traceback
from typing import Any, Callable, Dict, Optional, Union
import anki.buildinfo
import anki.lang
import aqt.buildinfo
from anki import version as _version
from anki.consts import HELP_SITE
from anki.rsbackend import RustBackend
@ -22,8 +20,6 @@ from anki.utils import checksum, isLin, isMac
from aqt.qt import *
from aqt.utils import locale_dir
assert anki.buildinfo.buildhash == aqt.buildinfo.buildhash
# we want to be able to print unicode debug info to console without
# fear of a traceback on systems with the console set to ASCII
try:

View file

@ -1,14 +0,0 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os
_buildinfo = {}
for line in open(os.path.join(os.path.dirname(__file__), "buildinfo.txt")).readlines():
elems = line.split()
if len(elems) == 2:
k, v = elems
_buildinfo[k] = v
buildhash=_buildinfo["STABLE_BUILDHASH"]
version=_buildinfo["STABLE_VERSION"]

View file

@ -22,7 +22,7 @@ if __name__ == "__main__":
"black",
"-t",
"py36",
"--exclude=aqt/forms|buildinfo|colors",
"--exclude=aqt/forms|colors",
"aqt",
"tests",
"tools",