2020-09-19 22:28:34 +00:00
|
|
|
import datetime
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
2020-12-24 16:18:15 +00:00
|
|
|
# set paths
|
|
|
|
_PATH_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
|
|
|
_PATH_INIT = os.path.join(_PATH_ROOT, 'pytorch_lightning', '__init__.py')
|
2020-09-19 22:28:34 +00:00
|
|
|
|
|
|
|
# get today date
|
|
|
|
now = datetime.datetime.now()
|
|
|
|
now_date = now.strftime("%Y%m%d")
|
2020-12-24 16:18:15 +00:00
|
|
|
|
|
|
|
print(f"prepare init '{_PATH_INIT}' - replace version by {now_date}")
|
|
|
|
with open(_PATH_INIT, 'r') as fp:
|
2020-09-19 22:28:34 +00:00
|
|
|
init = fp.read()
|
2020-12-24 16:18:15 +00:00
|
|
|
init = re.sub(r'__version__ = [\d\.\w\'"]+', f'__version__ = "{now_date}"', init)
|
|
|
|
with open(_PATH_INIT, 'w') as fp:
|
2020-09-19 22:28:34 +00:00
|
|
|
fp.write(init)
|