8000 Automatically bump the README version (#224) · python/release-tools@e2e4113 · GitHub
[go: up one dir, main page]

Skip to content

Commit e2e4113

Browse files
hugovkezio-melotti
andauthored
Automatically bump the README version (#224)
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
1 parent 4437a18 commit e2e4113

File tree

4 files changed

+339
-1
lines changed

4 files changed

+339
-1
lines changed

release.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,18 @@ def nickname(self) -> str:
190190
def gitname(self) -> str:
191191
return "v" + self.text
192192

193+
@property
194+
def long_name(self) -> str:
195+
if self.is_final:
196+
return self.text
197+
198+
level = {
199+
"a": "alpha",
200+
"b": "beta",
201+
"rc": "release candidate",
202+
}[self.level]
203+
return f"{self.normalized()} {level} {self.serial}"
204+
193205
def next_minor_release(self) -> Self:
194206
return self.__class__(f"{self.major}.{int(self.minor)+1}.0a0")
195207

@@ -419,13 +431,30 @@ def tweak_patchlevel(
419431
print("done")
420432

421433

434+
def tweak_readme(tag: Tag, filename: str = "README.rst") -> None:
435+
print(f"Updating {filename}...", end=" ")
436+
readme = Path(filename)
437+
438+
# Update first line: "This is Python version 3.14.0 alpha 7"
439+
# and update length of underline in second line to match.
440+
lines = readme.read_text().splitlines()
441+
this_is = f"This is Python version {tag.long_name}"
442+
underline = "=" * len(this_is)
443+
lines[0] = this_is
444+
lines[1] = underline
445+
446+
readme.write_text("\n".join(lines))
447+
print("done")
448+
449+
422450
def bump(tag: Tag) -> None:
423451
print(f"Bumping version to {tag}")
424452

425453
tweak_patchlevel(tag)
454+
tweak_readme(tag)
426455

427456
extra_work = False
428-
other_files = ["README.rst"]
457+
other_files = []
429458
if tag.patch == 0 and tag.level == "a" and tag.serial == 0:
430459
extra_work = True
431460
other_files += [

tests/README.rst

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
This is Python version 3.14.0 alpha 3
2+
=====================================
3+
4+
.. image:: https://github.com/python/cpython/actions/workflows/build.yml/badge.svg?branch=main&event=push
5+
:alt: CPython build status on GitHub Actions
6+
:target: https://github.com/python/cpython/actions
7+
8+
.. image:: https://dev.azure.com/python/cpython/_apis/build/status/Azure%20Pipelines%20CI?branchName=main
9+
:alt: CPython build status on Azure DevOps
10+
:target: https://dev.azure.com/python/cpython/_build/latest?definitionId=4&branchName=main
11+
12+
.. image:: https://img.shields.io/badge/discourse-join_chat-brightgreen.svg
13+
:alt: Python Discourse chat
14+
:target: https://discuss.python.org/
15+
16+
17+
Copyright © 2001 Python Software Foundation. All rights reserved.
18+
19+
See the end of this file for further copyright and license information.
20+
21+
.. contents::
22+
23+
General Information
24+
-------------------
25+
26+
- Website: https://www.python.org
27+
- Source code: https://github.com/python/cpython
28+
- Issue tracker: https://github.com/python/cpython/issues
29+
- Documentation: https://docs.python.org
30+
- Developer's Guide: https://devguide.python.org/
31+
32+
Contributing to CPython
33+
-----------------------
34+
35+
For more complete instructions on contributing to CPython development,
36+
see the `Developer Guide`_.
37+
38+
.. _Developer Guide: https://devguide.python.org/
39+
40+
Using Python
41+
------------
42+
43+
Installable Python kits, and information about using Python, are available at
44+
`python.org`_.
45+
46+
.. _python.org: https://www.python.org/
47+
48+
Build Instructions
49+
------------------
50+
51+
On Unix, Linux, BSD, macOS, and Cygwin::
52+
53+
./configure
54+
make
55+
make test
56+
sudo make install
57+
58+
This will install Python as ``python3``.
59+
60+
You can pass many options to the configure script; run ``./configure --help``
61+
to find out more. On macOS case-insensitive file systems and on Cygwin,
62+
the executable is called ``python.exe``; elsewhere it's just ``python``.
63+
64+
Building a complete Python installation requires the use of various
65+
additional third-party libraries, depending on your build platform and
66+
configure options. Not all standard library modules are buildable or
67+
usable on all platforms. Refer to the
68+
`Install dependencies <https://devguide.python.org/getting-started/setup-building.html#build-dependencies>`_
69+
section of the `Developer Guide`_ for current detailed information on
70+
dependencies for various Linux distributions and macOS.
71+
72+
On macOS, there are additional configure and build options related
73+
to macOS framework and universal builds. Refer to `Mac/README.rst
74+
<https://github.com/python/cpython/blob/main/Mac/README.rst>`_.
75+
76+
On Windows, see `PCbuild/readme.txt
77+
<https://github.com/python/cpython/blob/main/PCbuild/readme.txt>`_.
78+
79+
To build Windows installer, see `Tools/msi/README.txt
80+
<https://github.com/python/cpython/blob/main/Tools/msi/README.txt>`_.
81+
82+
If you wish, you can create a subdirectory and invoke configure from there.
83+
For example::
84+
85+
mkdir debug
86+
cd debug
87+
../configure --with-pydebug
88+
make
89+
make test
90+
91+
(This will fail if you *also* built at the top-level directory. You should do
92+
a ``make clean`` at the top-level first.)
93+
94+
To get an optimized build of Python, ``configure --enable-optimizations``
95+
before you run ``make``. This sets the default make targets up to enable
96+
Profile Guided Optimization (PGO) and may be used to auto-enable Link Time
97+
Optimization (LTO) on some platforms. For more details, see the sections
98+
below.
99+
100+
Profile Guided Optimization
101+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
102+
103+
PGO takes advantage of recent versions of the GCC or Clang compilers. If used,
104+
either via ``configure --enable-optimizations`` or by manually running
105+
``make profile-opt`` regardless of configure flags, the optimized build
106+
process will perform the following steps:
107+
108+
The entire Python directory is cleaned of temporary files that may have
109+
resulted from a previous compilation.
110+
111+
An instrumented version of the interpreter is built, using suitable compiler
112+
flags for each flavor. Note that this is just an intermediary step. The
113+
binary resulting from this step is not good for real-life workloads as it has
114+
profiling instructions embedded inside.
115+
116+
After the instrumented interpreter is built, the Makefile will run a training
117+
workload. This is necessary in order to profile the interpreter's execution.
118+
Note also that any output, both stdout and stderr, that may appear at this step
119+
is suppressed.
120+
121+
The final step is to build the actual interpreter, using the information
122+
collected from the instrumented one. The end result will be a Python binary
123+
that is optimized; suitable for distribution or production installation.
124+
125+
126+
Link Time Optimization
127+
^^^^^^^^^^^^^^^^^^^^^^
128+
129+
Enabled via configure's ``--with-lto`` flag. LTO takes advantage of the
130+
ability of recent compiler toolchains to optimize across the otherwise
131+
arbitrary ``.o`` file boundary when building final executables or shared
132+
libraries for additional performance gains.
133+
134+
135+
What's New
136+
----------
137+
138+
We have a comprehensive overview of the changes in the `What's New in Python
139+
3.14 <https://docs.python.org/3.14/whatsnew/3.14.html>`_ document. For a more
140+
detailed change log, read `Misc/NEWS
141+
<https://github.com/python/cpython/tree/main/Misc/NEWS.d>`_, but a full
142+
accounting of changes can only be gleaned from the `commit history
143+
<https://github.com/python/cpython/commits/main>`_.
144+
145+
If you want to install multiple versions of Python, see the section below
146+
entitled "Installing multiple versions".
147+
148+
149+
Documentation
150+
-------------
151+
152+
`Documentation for Python 3.14 <https://docs.python.org/3.14/>`_ is online,
153+
updated daily.
154+
155+
It can also be downloaded in many formats for faster access. The documentation
156+
is downloadable in HTML, PDF, and reStructuredText formats; the latter version
157+
is primarily for documentation authors, translators, and people with special
158+
formatting requirements.
159+
160+
For information about building Python's documentation, refer to `Doc/README.rst
161+
<https://github.com/python/cpython/blob/main/Doc/README.rst>`_.
162+
163+
164+
Testing
165+
-------
166+
167+
To test the interpreter, type ``make test`` in the top-level directory. The
168+
test set produces some output. You can generally ignore the messages about
169+
skipped tests due to optional features which can't be imported. If a message
170+
is printed about a failed test or a traceback or core dump is produced,
171+
something is wrong.
172+
173+
By default, tests are prevented from overusing resources like disk space and
174+
memory. To enable these tests, run ``make buildbottest``.
175+
176+
If any tests fail, you can re-run the failing test(s) in verbose mode. For
177+
example, if ``test_os`` and ``test_gdb`` failed, you can run::
178+
179+
make test TESTOPTS="-v test_os test_gdb"
180+
181+
If the failure persists and appears to be a problem with Python rather than
182+
your environment, you can `file a bug report
183+
<https://github.com/python/cpython/issues>`_ and include relevant output from
184+
that command to show the issue.
185+
186+
See `Running & Writing Tests <https://devguide.python.org/testing/run-write-tests.html>`_
187+
for more on running tests.
188+
189+
Installing multiple versions
190+
----------------------------
191+
192+
On Unix and Mac systems if you intend to install multiple versions of Python
193+
using the same installation prefix (``--prefix`` argument to the configure
194+
script) you must take care that your primary python executable is not
195+
overwritten by the installation of a different version. All files and
196+
directories installed using ``make altinstall`` contain the major and minor
197+
version and can thus live side-by-side. ``make install`` also creates
198+
``${prefix}/bin/python3`` which refers to ``${prefix}/bin/python3.X``. If you
199+
intend to install multiple versions using the same prefix you must decide which
200+
version (if any) is your "primary" version. Install that version using
201+
``make install``. Install all other versions using ``make altinstall``.
202+
203+
For example, if you want to install Python 2.7, 3.6, and 3.14 with 3.14 being the
204+
primary version, you would execute ``make install`` in your 3.14 build directory
205+
and ``make altinstall`` in the others.
206+
207+
208+
Release Schedule
209+
----------------
210+
211+
See `PEP 745 <https://peps.python.org/pep-0745/>`__ for Python 3.14 release details.
212+
213+
214+
Copyright and License Information
215+
---------------------------------
216+
217+
218+
Copyright © 2001 Python Software Foundation. All rights reserved.
219+
220+
Copyright © 2000 BeOpen.com. All rights reserved.
221+
222+
Copyright © 1995-2001 Corporation for National Research Initiatives. All
223+
rights reserved.
224+
225+
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.
226+
227+
See the `LICENSE <https://github.com/python/cpython/blob/main/LICENSE>`_ for
228+
information on the history of this software, terms & conditions for usage, and a
229+
DISCLAIMER OF ALL WARRANTIES.
230+
231+
This Python distribution contains *no* GNU General Public License (GPL) code,
232+
so it may be used in proprietary projects. There are interfaces to some GNU
233+
code but these are entirely optional.
234+
235+
All trademarks referenced herein are property of their respective holders.

tests/test_release.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,50 @@ def test_tweak_patchlevel(tmp_path: Path) -> None:
6868
'#define PY_VERSION "3.14.0b2"',
6969
):
7070
assert expected in new_contents
71+
72+
73+
@pytest.mark.parametrize(
74+
["test_tag", "expected_version", "expected_underline"],
75+
[
76+
(
77+
"3.14.0a6",
78+
"This is Python version 3.14.0 alpha 6",
79+
"=====================================",
80+
),
81+
(
82+
"3.14.0b2",
83+
"This is Python version 3.14.0 beta 2",
84+
"====================================",
85+
),
86+
(
87+
"3.14.0rc2",
88+
"This is Python version 3.14.0 release candidate 2",
89+
"=================================================",
90+
),
91+
(
92+
"3.14.1",
93+
"This is Python version 3.14.1",
94+
"=============================",
95+
),
96+
],
97+
)
98+
def test_tweak_readme(
99+
tmp_path: Path, test_tag: str, expected_version: str, expected_underline: str
100+
) -> None:
101+
# Arrange
102+
tag = release.Tag(test_tag)
103+
104+
original_readme_file = Path(__file__).parent / "README.rst"
105+
original_contents = original_readme_file.read_text()
106+
readme_file = tmp_path / "README.rst"
107+
readme_file.write_text(original_contents)
108+
109+
# Act
110+
release.tweak_readme(tag, filename=str(readme_file))
111+
112+
# Assert
113+
original_lines = original_contents.splitlines()
114+
new_lines = readme_file.read_text().splitlines()
115+
assert new_lines[0] == expected_version
116+
assert new_lines[1] == expected_underline
117+
assert new_lines[2:] == original_lines[2:]

tests/test_release_tag.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def test_tag() -> None:
1919
assert tag.as_tuple() == (3, 12, 2, "f", 0)
2020
assert tag.branch == "3.12"
2121
assert tag.gitname == "v3.12.2"
22+
assert tag.long_name == "3.12.2"
2223
assert tag.is_alpha_release is False
2324
assert tag.is_feature_freeze_release is False
2425
assert tag.is_release_candidate is False
@@ -32,23 +33,33 @@ def test_tag_phase() -> None:
3233
beta1 = release.Tag("3.13.0b1")
3334
beta4 = release.Tag("3.13.0b4")
3435
rc = release.Tag("3.13.0rc3")
36+
final = release.Tag("3.13.0")
3537

3638
# Act / Assert
3739
assert alpha.is_alpha_release is True
3840
assert alpha.is_feature_freeze_release is False
3941
assert alpha.is_release_candidate is False
42+
assert alpha.is_final is False
4043

4144
assert beta1.is_alpha_release is False
4245
assert beta1.is_feature_freeze_release is True
4346
assert beta1.is_release_candidate is False
47+
assert beta1.is_final is False
4448

4549
assert beta4.is_alpha_release is False
4650
assert beta4.is_feature_freeze_release is False
4751
assert beta4.is_release_candidate is False
52+
assert beta4.is_final is False
4853

4954
assert rc.is_alpha_release is False
5055
assert rc.is_feature_freeze_release is False
5156
assert rc.is_release_candidate is True
57+
assert rc.is_final is False
58+
59+
assert final.is_alpha_release is False
60+
assert final.is_feature_freeze_release is False
61+
assert final.is_release_candidate is False
62+
assert final.is_final is True
5263

5364

5465
def test_tag_committed_at_not_found() -> None:
@@ -113,3 +124,19 @@ def test_tag_docs_attributes() -> None:
113124
assert rc.doc_version == "3.13"
114125
assert final_zero.doc_version == "3.13"
115126
assert final_3.doc_version == "3.13.3"
127+
128+
129+
def test_tag_long_name() -> None:
130+
# Arrange
131+
alpha = release.Tag("3.13.0a7")
132+
beta = release.Tag("3.13.0b1")
133+
rc = release.Tag("3.13.0rc3")
134+
final_zero = release.Tag("3.13.0")
135+
final_3 = release.Tag("3.13.3")
136+
137+
# Act / Assert
138+
assert alpha.long_name == "3.13.0 alpha 7"
139+
assert beta.long_name == "3.13.0 beta 1"
140+
assert rc.long_name == "3.13.0 release candidate 3"
141+
assert final_zero.long_name == "3.13.0"
142+
assert final_3.long_name == "3.13.3"

0 commit comments

Comments
 (0)
0