Skip to content

Commit 3357571

Browse files
committed
fix #759 : added script to merge changelog files from all projects related to larray
1 parent d4766c3 commit 3357571

File tree

4 files changed

+92
-18
lines changed

4 files changed

+92
-18
lines changed

doc/source/changes/template.rst.inc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
.. py:currentmodule:: larray
22

3+
34
Syntax changes
4-
--------------
5+
^^^^^^^^^^^^^^
56

67
* renamed ``LArray.old_method_name()`` to :py:obj:`LArray.new_method_name()` (closes :issue:`1`).
78

89
* renamed ``old_argument_name`` argument of :py:obj:`LArray.method_name()` to ``new_argument_name``.
910

1011

1112
Backward incompatible changes
12-
-----------------------------
13+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1314

1415
* other backward incompatible changes
1516

1617

1718
New features
18-
------------
19+
^^^^^^^^^^^^
1920

2021
* added a feature (see the :ref:`miscellaneous section <misc>` for details). It works on :ref:`api-axis` and
2122
:ref:`api-group` objects.
@@ -46,12 +47,12 @@ New features
4647
.. _misc:
4748

4849
Miscellaneous improvements
49-
--------------------------
50+
^^^^^^^^^^^^^^^^^^^^^^^^^^
5051

5152
* improved something.
5253

5354

5455
Fixes
55-
-----
56+
^^^^^
5657

5758
* fixed something (closes :issue:`1`).

doc/source/changes/version_0_30.rst.inc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
.. py:currentmodule:: larray
22

3+
34
Syntax changes
4-
--------------
5+
^^^^^^^^^^^^^^
56

67
* new syntax
78

89

910
Backward incompatible changes
10-
-----------------------------
11+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1112

1213
* :py:obj:`LArray.equals()` now returns True for arrays even when axes are in a different order or some axes are
1314
missing on either side (but the data is constant over that axis on the other side). To get back the old behavior, use
@@ -98,7 +99,7 @@ Backward incompatible changes
9899

99100

100101
New features
101-
------------
102+
^^^^^^^^^^^^
102103

103104
* added :py:obj:`LArray.isin()` method to check whether each element of an array is contained in a list (or array) of
104105
values.
@@ -127,7 +128,7 @@ New features
127128

128129

129130
Miscellaneous improvements
130-
--------------------------
131+
^^^^^^^^^^^^^^^^^^^^^^^^^^
131132

132133
* implemented a simpler pattern language in :py:obj:`Axis.matching()` and :py:obj:`Group.matching()`. In addition to
133134
regular expressions (which now require using the ``regexp`` argument), the two methods support the following simpler
@@ -277,7 +278,7 @@ Miscellaneous improvements
277278

278279

279280
Fixes
280-
-----
281+
^^^^^
281282

282283
* fixed :py:obj:`LArray.divnot0()` being slow when the divisor has many axes and many zeros (closes :issue:`705`).
283284

doc/source/merge_changelogs.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
Append release notes from other projects of the larray-project constellation to the current changelog
5+
"""
6+
7+
import os
8+
import requests
9+
10+
from releaser import relname2fname
11+
12+
13+
# TODO: add Eurostat project
14+
LARRAY_GITHUB_REP = "https://github.com/larray-project/larray"
15+
EDITOR_GITHUB_REP = "https://github.com/larray-project/larray-editor"
16+
17+
18+
def include_changelogs(section_name, release_name, github_rep, rel_changes_dir='/doc/source/changes',
19+
branch='master', reset=False):
20+
changelog_file = relname2fname(release_name)
21+
22+
# get changelog file content from github repository
23+
url = github_rep.replace('github.com', 'raw.githubusercontent.com') \
24+
+ '/{}/{}/'.format(branch, rel_changes_dir) + changelog_file
25+
req = requests.get(url)
26+
if req.status_code != requests.codes.ok:
27+
raise ValueError("Content at URL {} could not been found.".format(url))
28+
github_changelog = req.text
29+
30+
# append to local changelog file
31+
changelog_file = os.path.abspath(os.path.join('.', 'changes', changelog_file))
32+
with open(changelog_file) as f:
33+
content = f.read() if not reset else ''
34+
with open(changelog_file, 'w', encoding="utf-8") as f:
35+
new_section = """
36+
37+
{section_name}
38+
{underline}
39+
40+
""".format(section_name=section_name.upper(), underline='-' * len(section_name))
41+
content += new_section
42+
content += github_changelog
43+
f.write(content)
44+
45+
46+
def merge_changelogs(release_name):
47+
include_changelogs('CORE', release_name, LARRAY_GITHUB_REP, reset=True)
48+
include_changelogs('EDITOR', release_name, EDITOR_GITHUB_REP)
49+
50+
51+
if __name__ == '__main__':
52+
import sys
53+
54+
argv = sys.argv
55+
if len(argv) < 2:
56+
print("Usage: {} release_name".format(argv[0]))
57+
sys.exit()
58+
59+
release_name = argv[1]
60+
merge_changelogs(release_name)

make_release.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88

99
import sys
1010
from os.path import abspath, dirname, join
11-
1211
from subprocess import check_call
13-
from releaser import make_release, update_feedstock, short, no, chdir, doechocall, set_config
12+
13+
from releaser import make_release, update_feedstock, short, no, chdir, set_config, insert_step_func
1414
from releaser.make_release import steps_funcs as make_release_steps
1515
from releaser.update_feedstock import steps_funcs as update_feedstock_steps
1616

17-
1817
TMP_PATH = r"c:\tmp\larray_new_release"
1918
TMP_PATH_CONDA = r"c:\tmp\larray_conda_new_release"
2019
PACKAGE_NAME = "larray"
@@ -45,6 +44,19 @@ def fill(s):
4544
'qtconsole', 'matplotlib', 'pyqt', 'qtpy', 'pytables', 'xlsxwriter', 'xlrd', 'openpyxl', 'xlwings'])
4645

4746

47+
def merge_changelogs(config):
48+
if config['src_documentation'] is not None:
49+
chdir(join(config['build_dir'], config['src_documentation']))
50+
51+
if not config['public_release']:
52+
return
53+
54+
check_call(['python', 'merge_changelogs.py', config['release_name']])
55+
56+
57+
insert_step_func(merge_changelogs, msg='append changelogs from larray-editor project', before='update_changelog')
58+
59+
4860
# TODO : move to larrayenv project
4961
def announce_new_release(release_name):
5062
import win32com.client as win32
@@ -78,14 +90,14 @@ def announce_new_release(release_name):
7890
print("update conda-forge feedstock steps:", ', '.join(f.__name__ for f, _ in update_feedstock_steps))
7991
print("or")
8092
print("Usage: {} -a|--announce release_name".format(argv[0]))
81-
print("Usage: {} -m release_name".format(argv[0]))
93+
print("Usage: {} -m|--meta release_name".format(argv[0]))
8294
sys.exit()
8395

8496
local_repository = abspath(dirname(__file__))
85-
if argv[1] == '-m':
86-
config = set_config(local_repository, PACKAGE_NAME, SRC_CODE, argv[2], branch='master',
87-
src_documentation=SRC_DOC, tmp_dir=TMP_PATH)
88-
update_metapackage(config)
97+
if argv[1] == '-m' or argv[1] == '--meta':
98+
local_config = set_config(local_repository, PACKAGE_NAME, SRC_CODE, argv[2], branch='master',
99+
src_documentation=SRC_DOC, tmp_dir=TMP_PATH)
100+
update_metapackage(local_config)
89101
elif argv[1] == '-a' or argv[1] == '--announce':
90102
no("Is metapackage larrayenv updated?")
91103
announce_new_release(argv[2])

0 commit comments

Comments
 (0)