use paths relative to source / build dir and add md5sum into build info
This commit is contained in:
parent
4e7ea6fd14
commit
785eb6923f
4 changed files with 19 additions and 3 deletions
|
@ -92,7 +92,7 @@ def build(
|
|||
for file in files:
|
||||
if last_build_info:
|
||||
last_build_info_for_this_file =\
|
||||
list(filter(lambda i: i['source file'] == file.name, last_build_info['tex_sources']))
|
||||
list(filter(lambda i: i['source file'] == str(file.relative_to(src_dir)), last_build_info['tex_sources']))
|
||||
else:
|
||||
last_build_info_for_this_file = []
|
||||
sources_to_build.append(
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from .build_information import BuildInfo
|
||||
from .pytex_file import TexFileToFormat
|
||||
from .pytex_msg import pytex_msg
|
||||
from .checksum import md5
|
||||
|
||||
__all__ = [
|
||||
'BuildInfo',
|
||||
'TexFileToFormat',
|
||||
'pytex_msg'
|
||||
'pytex_msg',
|
||||
'md5'
|
||||
]
|
||||
|
|
12
build/utils/checksum.py
Normal file
12
build/utils/checksum.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
import hashlib
|
||||
from pathlib import Path
|
||||
|
||||
# https://stackoverflow.com/a/3431838/16371376
|
||||
|
||||
|
||||
def md5(file: Path):
|
||||
hash_md5 = hashlib.md5()
|
||||
with open(file, "rb") as f:
|
||||
for block in iter(lambda: f.read(4096), b""):
|
||||
hash_md5.update(block)
|
||||
return hash_md5.hexdigest()
|
|
@ -5,6 +5,7 @@ from PyTeX.build.git_hook import is_recent, get_latest_commit
|
|||
from PyTeX import PackageFormatter, ClassFormatter, DictionaryFormatter
|
||||
from PyTeX.errors import *
|
||||
from .pytex_msg import pytex_msg
|
||||
from .checksum import md5
|
||||
|
||||
from .build_information import BuildInfo
|
||||
|
||||
|
@ -133,12 +134,13 @@ class TexFileToFormat:
|
|||
for written_file in written_files:
|
||||
info = {
|
||||
'name': str(self.src_path.parent.relative_to(self.src_root)) + "/" + written_file,
|
||||
'source file': self.src_path.name,
|
||||
'source file': str(self.src_path.relative_to(self.src_root)),
|
||||
'build time': self.current_build_info.build_time,
|
||||
'source version': self.current_build_info.packages_version,
|
||||
'source commit hash': self.current_build_info.packages_hash,
|
||||
'pytex version': self.current_build_info.pytex_version,
|
||||
'pytex commit hash': self.current_build_info.pytex_hash,
|
||||
'md5sum': md5(self.build_root / self.src_path.parent.relative_to(self.src_root) / written_file),
|
||||
'dirty': self.dirty
|
||||
}
|
||||
build_infos.append(info)
|
||||
|
|
Loading…
Reference in a new issue