Skip to content

Commit

Permalink
Better release metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Jul 2, 2019
1 parent d24c36e commit 4bdcc89
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 19 deletions.
6 changes: 6 additions & 0 deletions hypothesis-python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def local_file(name):
package_dir={"": SOURCE},
package_data={"hypothesis": ["py.typed"]},
url="https://github.com/HypothesisWorks/hypothesis/tree/master/hypothesis-python",
project_urls={
"Website": "https://hypothesis.works",
"Documentation": "https://hypothesis.readthedocs.io",
"Issues": "https://github.com/HypothesisWorks/hypothesis/issues",
},
license="MPL v2",
description="A library for property based testing",
zip_safe=False,
Expand Down Expand Up @@ -115,5 +120,6 @@ def local_file(name):
],
entry_points={"pytest11": ["hypothesispytest = hypothesis.extra.pytestplugin"]},
long_description=open(README).read(),
long_description_content_type="text/x-rst",
keywords="python testing fuzzing property-based-testing",
)
15 changes: 1 addition & 14 deletions tooling/src/hypothesistooling/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,20 +347,7 @@ def documentation():
try:
if hp.has_release():
hp.update_changelog_and_version()
pip_tool(
# See https://www.sphinx-doc.org/en/stable/man/sphinx-build.html
"sphinx-build",
"-n",
"-W",
"--keep-going",
"-T",
"-E",
"-b",
"html",
"docs",
"docs/_build/html",
cwd=hp.HYPOTHESIS_PYTHON,
)
hp.build_docs()
finally:
subprocess.check_call(
["git", "checkout", "docs/changes.rst", "src/hypothesis/version.py"],
Expand Down
48 changes: 43 additions & 5 deletions tooling/src/hypothesistooling/projects/hypothesispython.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ def has_source_changes():
return tools.has_changes([PYTHON_SRC])


def build_docs(builder="html"):
# See https://www.sphinx-doc.org/en/stable/man/sphinx-build.html
# (unfortunately most options only have the short flag version)
tools.scripts.pip_tool(
"sphinx-build",
"-n",
"-W",
"--keep-going",
"-T",
"-E",
"-b",
builder,
"docs",
"docs/_build/" + builder,
cwd=HYPOTHESIS_PYTHON,
)


CHANGELOG_ANCHOR = re.compile(r"^\.\. _v\d+\.\d+\.\d+:$")
CHANGELOG_BORDER = re.compile(r"^-+$")
CHANGELOG_HEADER = re.compile(r"^\d+\.\d+\.\d+ - \d\d\d\d-\d\d-\d\d$")
Expand Down Expand Up @@ -159,29 +177,49 @@ def upload_distribution():
"-m",
"twine",
"upload",
"--skip-existing",
"--config-file",
tools.PYPIRC,
os.path.join(DIST, "*"),
]
)

# Construct plain-text + markdown version of this changelog entry,
# with link to canonical source.
build_docs(builder="text")
textfile = os.path.join(HYPOTHESIS_PYTHON, "docs", "_build", "text", "changes.txt")
with open(textfile) as f:
lines = f.readlines()
entries = [i for i, l in enumerate(lines) if CHANGELOG_HEADER.match(l)]
changelog_body = "".join(lines[entries[0] + 2 : entries[1]]).strip() + (
"\n\n*[The canonical version of these notes (with links) is on readthedocs.]"
"(https://hypothesis.readthedocs.io/en/latest/changes.html#v%s).*"
% (current_version().replace(".", "-"),)
)

# Create a GitHub release, to trigger Zenodo DOI minting. See
# https://developer.github.com/v3/repos/releases/#create-a-release
requests.post(
"https://api.github.com/repos/HypothesisWorks/hypothesis/releases",
json=dict(
tag_name=tag_name(),
name="Hypothesis for Python - version " + current_version(),
body=(
"You can [read the changelog for this release here]("
"https://hypothesis.readthedocs.io/en/latest/changes.html#v"
"%s)." % (current_version().replace(".", "-"),)
),
body=changelog_body,
),
timeout=120, # seconds
# Scoped personal access token, stored in Travis environ variable
auth=("Zac-HD", os.environ["Zac_release_token"]),
).raise_for_status()

# Post the release notes to Tidelift too - see https://tidelift.com/docs/api
requests.post(
"https://api.tidelift.com/external-api/lifting/pypi/hypothesis/release-notes/"
+ current_version(),
json={"body": changelog_body},
headers={"Authorization": "Bearer {}".format(os.environ["TIDELIFT_API_TOKEN"])},
timeout=120, # seconds
).raise_for_status()


def current_version():
return __version__
Expand Down

0 comments on commit 4bdcc89

Please sign in to comment.