Skip to content

Commit d560adf

Browse files
authored
Merge pull request #298 from openvax/readme-github-alert
README: GitHub [!IMPORTANT] alert, kept PyPI-clean via setup.py
2 parents bfab93a + 4e3d081 commit d560adf

3 files changed

Lines changed: 30 additions & 12 deletions

File tree

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@ Have a bugfix or other contribution? We would love your help. See our [contribut
1919

2020
## 2.3.0 release candidate
2121

22-
2.3.0 is currently a **release candidate** (`2.3.0rc3`), not yet a final
23-
release. It keeps the same API and pre-trained models as 2.2.x. Install it by
24-
pinning the version:
25-
26-
pip install mhcflurry==2.3.0rc3
27-
28-
For now, `pip install --upgrade mhcflurry` still installs the latest stable
29-
release (2.2.x), because pip skips pre-releases unless you pin the version or
30-
pass `--pre`. Once 2.3.0 is released, `pip install --upgrade mhcflurry` will
31-
upgrade to it as usual.
22+
> [!IMPORTANT]
23+
> 2.3.0 is currently a release candidate (`2.3.0rc3`), not yet a final release.
24+
> It keeps the same public API and pre-trained models as 2.2.x. Install it with
25+
> `pip install --pre mhcflurry`, or pin the version with
26+
> `pip install mhcflurry==2.3.0rc3`. A plain `pip install --upgrade mhcflurry`
27+
> stays on the latest stable release (2.2.x) until 2.3.0 is final, since pip
28+
> skips pre-releases.
3229
3330
2.3.0 adds speed and tooling for people who train their own models or run large
3431
prediction jobs:

mhcflurry/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.3.0rc3"
1+
__version__ = "2.3.0rc4"

setup.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@
2727
readme = ""
2828

2929

30+
def readme_for_pypi(text):
31+
# PyPI's Markdown renderer (cmark-gfm) does not support GitHub's
32+
# "> [!IMPORTANT]" alert syntax and would display the literal "[!IMPORTANT]"
33+
# token. Convert each alert marker line to a bold label so the PyPI
34+
# long_description renders as a clean blockquote. GitHub keeps the colored
35+
# callout because README.md on disk is unchanged.
36+
import re
37+
labels = {
38+
"NOTE": "Note",
39+
"TIP": "Tip",
40+
"IMPORTANT": "Important",
41+
"WARNING": "Warning",
42+
"CAUTION": "Caution",
43+
}
44+
return re.sub(
45+
r"(?m)^(\s*>\s*)\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\][ \t]*$",
46+
lambda m: "%s**%s**" % (m.group(1), labels[m.group(2)]),
47+
text,
48+
)
49+
50+
3051
with open("mhcflurry/version.py", "r") as f:
3152
version = re.search(
3253
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE
@@ -96,7 +117,7 @@
96117
"mhcflurry": ["downloads.yml"],
97118
},
98119
install_requires=required_packages,
99-
long_description=readme,
120+
long_description=readme_for_pypi(readme),
100121
long_description_content_type="text/markdown",
101122
packages=find_packages(include=["mhcflurry", "mhcflurry.*"]),
102123
)

0 commit comments

Comments
 (0)