meta pkg: set version as today (#13906)
This commit is contained in:
parent
c019fc633d
commit
c136ef5b9a
|
@ -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."""
|
||||
|
|
4
setup.py
4
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)
|
||||
|
|
|
@ -1 +1 @@
|
|||
version = "2022.7.18"
|
||||
version = "YYYY.-M.-D"
|
||||
|
|
Loading…
Reference in New Issue