Skip to content

Commit 3c66e9a

Browse files
Bordalexierule
authored andcommitted
meta pkg: set version as today (#13906)
(cherry picked from commit c136ef5)
1 parent 716c433 commit 3c66e9a

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

.actions/setup_tools.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import tarfile
2121
import tempfile
2222
import urllib.request
23+
from datetime import datetime
2324
from importlib.util import module_from_spec, spec_from_file_location
2425
from itertools import groupby
2526
from types import ModuleType
@@ -360,6 +361,20 @@ class implementations by cross-imports to the true package.
360361
fp.writelines(lines)
361362

362363

364+
def set_version_today(fpath: str) -> None:
365+
"""Replace the template date with today."""
366+
with open(fpath) as fp:
367+
lines = fp.readlines()
368+
369+
def _replace_today(ln):
370+
today = datetime.now()
371+
return ln.replace("YYYY.-M.-D", f"{today.year}.{today.month}.{today.day}")
372+
373+
lines = list(map(_replace_today, lines))
374+
with open(fpath, "w") as fp:
375+
fp.writelines(lines)
376+
377+
363378
def _download_frontend(root: str = _PROJECT_ROOT):
364379
"""Downloads an archive file for a specific release of the Lightning frontend and extracts it to the correct
365380
directory."""

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
# https://packaging.python.org/guides/single-sourcing-package-version/
6060
# http://blog.ionelmc.ro/2014/05/25/python-packaging/
6161
_PATH_ROOT = os.path.dirname(__file__)
62-
_PATH_SETUP = os.path.join(_PATH_ROOT, "src", _REAL_PKG_NAME or "lightning", "__setup__.py")
62+
_PATH_SRC = os.path.join(_PATH_ROOT, "src")
63+
_PATH_SETUP = os.path.join(_PATH_SRC, _REAL_PKG_NAME or "lightning", "__setup__.py")
6364

6465

6566
# Hardcode the env variable from time of package creation, otherwise it fails during installation
@@ -88,6 +89,7 @@ def _load_py_module(name: str, location: str) -> ModuleType:
8889
# engineer specific practices
8990
if __name__ == "__main__":
9091
_SETUP_TOOLS = _load_py_module(name="setup_tools", location=os.path.join(".actions", "setup_tools.py"))
92+
_SETUP_TOOLS.set_version_today(os.path.join(_PATH_SRC, "lightning", "__version__.py"))
9193
for lit_name, pkg_name in _PACKAGE_MAPPING.items():
9294
# fixme: if we run creation of meta pkg against stable we shall pull the source
9395
_SETUP_TOOLS.create_meta_package(os.path.join(_PATH_ROOT, "src"), pkg_name, lit_name)

src/lightning/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "2022.7.25"
1+
version = "YYYY.-M.-D"

0 commit comments

Comments
 (0)