From c136ef5b9a963e3c509b65a160867726e435bd56 Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Fri, 29 Jul 2022 14:37:33 +0200 Subject: [PATCH] meta pkg: set version as today (#13906) --- .actions/setup_tools.py | 15 +++++++++++++++ setup.py | 4 +++- src/lightning/__version__.py | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.actions/setup_tools.py b/.actions/setup_tools.py index 2aff3bdf9a..3e6a0ee0cb 100644 --- a/.actions/setup_tools.py +++ b/.actions/setup_tools.py @@ -20,6 +20,7 @@ import shutil import tarfile import tempfile import urllib.request +from datetime import datetime from importlib.util import module_from_spec, spec_from_file_location from itertools import groupby from types import ModuleType @@ -360,6 +361,20 @@ def create_meta_package(src_folder: str, pkg_name: str = "pytorch_lightning", li fp.writelines(lines) +def set_version_today(fpath: str) -> None: + """Replace the template date with today.""" + with open(fpath) as fp: + lines = fp.readlines() + + def _replace_today(ln): + today = datetime.now() + return ln.replace("YYYY.-M.-D", f"{today.year}.{today.month}.{today.day}") + + lines = list(map(_replace_today, lines)) + with open(fpath, "w") as fp: + fp.writelines(lines) + + def _download_frontend(root: str = _PROJECT_ROOT): """Downloads an archive file for a specific release of the Lightning frontend and extracts it to the correct directory.""" diff --git a/setup.py b/setup.py index a542b3c1e0..013729af02 100755 --- a/setup.py +++ b/setup.py @@ -59,7 +59,8 @@ _REAL_PKG_NAME = _PACKAGE_MAPPING.get(_PACKAGE_NAME, _PACKAGE_NAME) # https://packaging.python.org/guides/single-sourcing-package-version/ # http://blog.ionelmc.ro/2014/05/25/python-packaging/ _PATH_ROOT = os.path.dirname(__file__) -_PATH_SETUP = os.path.join(_PATH_ROOT, "src", _REAL_PKG_NAME or "lightning", "__setup__.py") +_PATH_SRC = os.path.join(_PATH_ROOT, "src") +_PATH_SETUP = os.path.join(_PATH_SRC, _REAL_PKG_NAME or "lightning", "__setup__.py") # 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: # engineer specific practices if __name__ == "__main__": _SETUP_TOOLS = _load_py_module(name="setup_tools", location=os.path.join(".actions", "setup_tools.py")) + _SETUP_TOOLS.set_version_today(os.path.join(_PATH_SRC, "lightning", "__version__.py")) for lit_name, pkg_name in _PACKAGE_MAPPING.items(): # fixme: if we run creation of meta pkg against stable we shall pull the source _SETUP_TOOLS.create_meta_package(os.path.join(_PATH_ROOT, "src"), pkg_name, lit_name) diff --git a/src/lightning/__version__.py b/src/lightning/__version__.py index 8f2d7b1403..1a929693c0 100644 --- a/src/lightning/__version__.py +++ b/src/lightning/__version__.py @@ -1 +1 @@ -version = "2022.7.18" +version = "YYYY.-M.-D"