mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
handle packaged pylib buildinfo.txt; drop aqt buildinfo
This commit is contained in:
parent
013d1d404a
commit
6e3f971ae1
5 changed files with 26 additions and 32 deletions
|
@ -2,13 +2,32 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
_buildinfo = {}
|
|
||||||
for line in open(os.path.join(os.path.dirname(__file__), "buildinfo.txt")).readlines():
|
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()
|
elems = line.split()
|
||||||
if len(elems) == 2:
|
if len(elems) == 2:
|
||||||
k, v = elems
|
k, v = elems
|
||||||
_buildinfo[k] = v
|
info[k] = v
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
|
_buildinfo = _get_build_info()
|
||||||
buildhash=_buildinfo["STABLE_BUILDHASH"]
|
buildhash=_buildinfo["STABLE_BUILDHASH"]
|
||||||
version=_buildinfo["STABLE_VERSION"]
|
version=_buildinfo["STABLE_VERSION"]
|
||||||
|
|
|
@ -4,12 +4,6 @@ load("@py_deps//:requirements.bzl", "requirement")
|
||||||
load("@rules_python//experimental/python:wheel.bzl", "py_package", "py_wheel")
|
load("@rules_python//experimental/python:wheel.bzl", "py_package", "py_wheel")
|
||||||
load("//:defs.bzl", "anki_version")
|
load("//:defs.bzl", "anki_version")
|
||||||
|
|
||||||
copy_file(
|
|
||||||
name = "buildinfo",
|
|
||||||
src = "//:buildinfo.txt",
|
|
||||||
out = "buildinfo.txt",
|
|
||||||
)
|
|
||||||
|
|
||||||
genrule(
|
genrule(
|
||||||
name = "hooks_gen",
|
name = "hooks_gen",
|
||||||
outs = ["hooks_gen.py"],
|
outs = ["hooks_gen.py"],
|
||||||
|
@ -37,7 +31,6 @@ aqt_srcs = glob([
|
||||||
]
|
]
|
||||||
|
|
||||||
aqt_core_data = [
|
aqt_core_data = [
|
||||||
"buildinfo.txt",
|
|
||||||
"colors.py",
|
"colors.py",
|
||||||
"py.typed",
|
"py.typed",
|
||||||
":hooks_gen",
|
":hooks_gen",
|
||||||
|
|
|
@ -12,9 +12,7 @@ import tempfile
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Any, Callable, Dict, Optional, Union
|
from typing import Any, Callable, Dict, Optional, Union
|
||||||
|
|
||||||
import anki.buildinfo
|
|
||||||
import anki.lang
|
import anki.lang
|
||||||
import aqt.buildinfo
|
|
||||||
from anki import version as _version
|
from anki import version as _version
|
||||||
from anki.consts import HELP_SITE
|
from anki.consts import HELP_SITE
|
||||||
from anki.rsbackend import RustBackend
|
from anki.rsbackend import RustBackend
|
||||||
|
@ -22,8 +20,6 @@ from anki.utils import checksum, isLin, isMac
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.utils import locale_dir
|
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
|
# 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
|
# fear of a traceback on systems with the console set to ASCII
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -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"]
|
|
|
@ -22,7 +22,7 @@ if __name__ == "__main__":
|
||||||
"black",
|
"black",
|
||||||
"-t",
|
"-t",
|
||||||
"py36",
|
"py36",
|
||||||
"--exclude=aqt/forms|buildinfo|colors",
|
"--exclude=aqt/forms|colors",
|
||||||
"aqt",
|
"aqt",
|
||||||
"tests",
|
"tests",
|
||||||
"tools",
|
"tools",
|
||||||
|
|
Loading…
Reference in a new issue