Skip to content

Commit

Permalink
Include build date in artifact metadata (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
elprans authored Dec 14, 2023
1 parent c94d30a commit 22d6588
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions metapkg/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import cast

import collections
import datetime
import graphlib
import importlib
import os
Expand Down Expand Up @@ -142,6 +143,7 @@ def handle(self) -> int:
outputdir=destination,
build_source=build_source,
build_debug=build_debug,
build_date=datetime.datetime.now(tz=datetime.timezone.utc),
revision=revision or "1",
subdist=subdist,
extra_opt=extra_opt,
Expand Down
1 change: 1 addition & 0 deletions metapkg/packages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ def get_artifact_metadata(self, build: targets.Build) -> dict[str, Any]:
"version": pep440_to_semver(self.version),
"version_details": self.get_version_details(),
"revision": build.revision,
"build_date": build.build_date.isoformat(),
"target": build.target.triple,
"architecture": build.target.machine_architecture,
"dist": build.target.ident,
Expand Down
9 changes: 9 additions & 0 deletions metapkg/targets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
)

import collections
import datetime
import hashlib
import os
import pathlib
Expand Down Expand Up @@ -48,6 +49,7 @@ class BuildRequest(NamedTuple):
outputdir: str | pathlib.Path = ""
build_source: bool = False
build_debug: bool = False
build_date: datetime.datetime | None = None
revision: str = "1"
subdist: str | None = None
extra_opt: bool = False
Expand Down Expand Up @@ -668,6 +670,9 @@ def __init__(
self._build_deps = request.build_deps
self._build_source = request.build_source
self._build_debug = request.build_debug
self._build_date = request.build_date or datetime.datetime.now(
tz=datetime.timezone.utc
)
self._revision = request.revision
self._subdist = request.subdist
self._extra_opt = request.extra_opt
Expand Down Expand Up @@ -710,6 +715,10 @@ def channel(self) -> str:
def revision(self) -> str:
return self._revision

@property
def build_date(self) -> datetime.datetime:
return self._build_date

def get_source_abspath(self) -> pathlib.Path:
raise NotImplementedError

Expand Down

0 comments on commit 22d6588

Please sign in to comment.