Skip to content

Commit

Permalink
Fix the release script. (#6629)
Browse files Browse the repository at this point in the history
The latest version of wheel (0.32.1, just released) no longer writes
the metadata.json file (see pypa/wheel#195).
Instead, we must now read the version from the METADATA file.

This change also tightens up the release docs a bit.
  • Loading branch information
benjyw committed Oct 14, 2018
1 parent 7951ec0 commit 0f80c70
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
30 changes: 5 additions & 25 deletions src/docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ script fail:

- **Get your pypi account added as an `owner` for all pantsbuild.pants packages.**

You can ask any one of the [Owners](#owners) listed below to do this.
Once this is done and you've performed your 1st release, add yourself to
the [Owners](#owners) section below.
You can ask any one of the current [Owners](#owners) to do this.

- **Configure your pypi credentials locally in `~/.pypirc`**

Expand Down Expand Up @@ -194,39 +192,21 @@ if the tag for the prior release (eg: release_0.0.33)
:::bash
$ ./build-support/bin/contributors.sh -s <tag>

Listing Packages and Owners
<a name="owners"></a>Listing Packages and Owners
------

The current list of packages can be obtained via :

:::bash
$ ./build-support/bin/release.sh -l

Right now that's:

- pantsbuild.pants
- pantsbuild.pants.contrib.avro
- pantsbuild.pants.contrib.buildgen
- pantsbuild.pants.contrib.codeanalysis
- pantsbuild.pants.contrib.confluence
- pantsbuild.pants.contrib.cpp
- pantsbuild.pants.contrib.errorprone
- pantsbuild.pants.contrib.findbugs
- pantsbuild.pants.contrib.go
- pantsbuild.pants.contrib.googlejavaformat
- pantsbuild.pants.contrib.jax_ws
- pantsbuild.pants.contrib.mypy
- pantsbuild.pants.contrib.node
- pantsbuild.pants.contrib.python.checks
- pantsbuild.pants.contrib.scalajs
- pantsbuild.pants.contrib.scrooge
- pantsbuild.pants.contrib.thrifty
- pantsbuild.pants.testinfra

You can run the following to get a full ownership roster for each
package :

:::bash
$ ./build-support/bin/release.sh -o

We generally expect all packages to have the same set of owners, which you can
view [here](https://pypi.org/project/pantsbuild.pants/).

[needs-cherrypick]: https://github.com/pantsbuild/pants/pulls?q=is%3Apr+label%3Aneeds-cherrypick
22 changes: 17 additions & 5 deletions src/python/pants/releases/reversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import fnmatch
import glob
import hashlib
import json
import os
import re
import zipfile
from builtins import open, str

Expand Down Expand Up @@ -89,6 +89,11 @@ def rewrite_record_file(workspace, src_record_file, mutated_file_tuples):
safe_file_dump(os.path.join(workspace, dst_record_file), '\r\n'.join(output_records) + '\r\n', binary_mode=False)


# The wheel METADATA file will contain a line like: `Version: 1.11.0.dev3+7951ec01`.
# We don't parse the entire file because it's large (it contains the entire release notes history).
_version_re = re.compile('Version: (?P<version>\S+)')


def reversion(args):
with temporary_dir() as workspace:
# Extract the input.
Expand All @@ -100,10 +105,17 @@ def reversion(args):
dist_info_dir = locate_dist_info_dir(workspace)
record_file = os.path.join(dist_info_dir, 'RECORD')

# Load metadata for the input whl.
with open(os.path.join(workspace, dist_info_dir, 'metadata.json'), 'r') as info:
metadata = json.load(info)
input_version = metadata['version']
# Get version from the input whl's metadata.
input_version = None
metadata_file = os.path.join(workspace, dist_info_dir, 'METADATA')
with open(metadata_file, 'r') as info:
for line in info:
mo = _version_re.match(line)
if mo:
input_version = mo.group('version')
break
if not input_version:
raise Exception('Could not find `Version:` line in {}'.format(metadata_file))

# Rewrite and move all files (including the RECORD file), recording which files need to be
# re-fingerprinted due to content changes.
Expand Down

0 comments on commit 0f80c70

Please sign in to comment.