Skip to content

Commit

Permalink
Prepare the 1.16.0.dev2 release. (#7603)
Browse files Browse the repository at this point in the history

Perform 1.16.0.dev2 deprecations.

This includes nuking a custom Conan requirements option as well as
taking care of safe_file_dump / maybe_read_file / read_file params.

Fixes #7121
  • Loading branch information
jsirois authored Apr 22, 2019
1 parent 216440d commit 09c5c09
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 74 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Created by running `./build-support/bin/contributors.sh`.
+ Pall Valmundsson
+ Pankaj Gupta
+ Patrick Lawson
+ Patrick Liu
+ Paul Groudas
+ Paul Yau
+ Peiyu Wang
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.16.0.dev1
1.16.0.dev2
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def _find_logs(self, compile_workunit):

def _find_missing_deps(self, compile_logs, target):
with self.context.new_workunit('missing-deps-suggest', labels=[WorkUnitLabel.COMPILER]):
compile_failure_log = '\n'.join(read_file(log).decode('utf-8') for log in compile_logs)
compile_failure_log = '\n'.join(read_file(log) for log in compile_logs)

missing_dep_suggestions, no_suggestions = self._missing_deps_finder.find(
compile_failure_log, target)
Expand Down
17 changes: 0 additions & 17 deletions src/python/pants/backend/native/subsystems/conan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,3 @@ class Conan(PythonToolBase):
]
default_entry_point = 'conans.conan'
default_interpreter_constraints = ['CPython>=2.7,<4']

@classmethod
def register_options(cls, register):
super(Conan, cls).register_options(register)
register('--conan-requirements', type=list,
default=Conan.default_requirements,
advanced=True, fingerprint=True,
help='The requirements used to build the conan client pex.',
removal_version='1.16.0.dev2',
removal_hint='Use --requirements instead.')

# TODO: Delete this method when the deprecated options are removed.
def get_requirement_specs(self):
opts = self.get_options()
if opts.is_default('conan_requirements'):
return super(Conan, self).get_requirement_specs()
return opts.conan_requirements
130 changes: 130 additions & 0 deletions src/python/pants/notes/master.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,136 @@ Master Pre-Releases
This document describes development releases which occur weekly from master, and which have
not undergone the vetting associated with ``stable`` releases.

1.16.0.dev2 (4/22/2019)
-----------------------

New features
~~~~~~~~~~~~

* Add support for v2-only goals, and replace list with a @console_rule (#6880)
`PR #6880 <https://github.com/pantsbuild/pants/pull/6880>`_

* make deprecations respect warnings filters and add --ignore-pants-warnings option (#7496)
`PR #7496 <https://github.com/pantsbuild/pants/pull/7496>`_

Bugfixes
~~~~~~~~

* Rerun `select-interpreter` if global Python interpreter constraints have changed (#7586)
`PR #7586 <https://github.com/pantsbuild/pants/pull/7586>`_

* Fix help info output for option choices (#7569)
`PR #7569 <https://github.com/pantsbuild/pants/pull/7569>`_

* Directory materialization is visible to others. (#7562)
`PR #7562 <https://github.com/pantsbuild/pants/pull/7562>`_

* Coerce argv for JavacCompile to text_type. (#7560)
`PR #7560 <https://github.com/pantsbuild/pants/pull/7560>`_

* Fix doc generation rendering byte literals with Python 3 (#7556)
`PR #7556 <https://github.com/pantsbuild/pants/pull/7556>`_

* fix go test flags bug and add integration test (#7539)
`PR #7539 <https://github.com/pantsbuild/pants/pull/7539>`_

Documentation
~~~~~~~~~~~~~

* Fix link for common_task/target_aggregate (#7574)
`PR #7574 <https://github.com/pantsbuild/pants/pull/7574>`_

* Update install guide to use `./pants generate-pants-ini` and `pants_runtime_python_version` (#7453)
`PR #7453 <https://github.com/pantsbuild/pants/pull/7453>`_

Refactoring, Improvements, and Tooling
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Hotfix #7591 breaking OSX Rust tests shard due to Pyenv global issue (#7602)
`PR #7602 <https://github.com/pantsbuild/pants/pull/7602>`_
`PR #7591 <https://github.com/pantsbuild/pants/pull/7591>`_

* Pin OSX wheel release shards to pyenv. (#7591)
`PR #7591 <https://github.com/pantsbuild/pants/pull/7591>`_

* Replace the `goals` goal with a `help` plugin which supports both v1 and v2 (#7598)
`PR #7598 <https://github.com/pantsbuild/pants/pull/7598>`_

* Remove unused migrations folder (#7592)
`PR #7592 <https://github.com/pantsbuild/pants/pull/7592>`_

* Collection subclasses correctly coerce to bools (#7584)
`PR #7584 <https://github.com/pantsbuild/pants/pull/7584>`_

* Use ci.sh instead of travis-ci.sh (#7582)
`PR #7582 <https://github.com/pantsbuild/pants/pull/7582>`_

* Cleanup run_python_test rule. (#7577)
`PR #7577 <https://github.com/pantsbuild/pants/pull/7577>`_

* Improve `--pantsd-invalidation-globs` using Snapshot fingerprints (#7531)
`Issue #5567 <https://github.com/pantsbuild/pants/issues/5567>`_
`PR #7531 <https://github.com/pantsbuild/pants/pull/7531>`_

* Restore support for pantsbuild.pants wheel using Python 3.7+ by removing abi3 workaround (#7578)
`Issue #7459 <https://github.com/pantsbuild/pants/issues/7459>`_
`PR #7578 <https://github.com/pantsbuild/pants/pull/7578>`_

* Bootstrap py36 in cron as well (#7579)
`PR #7579 <https://github.com/pantsbuild/pants/pull/7579>`_

* protobuf gen triggers less often (#7565)
`PR #7565 <https://github.com/pantsbuild/pants/pull/7565>`_

* Skip more flaky tests in TestPantsDaemonIntegration. (#7575)
`PR #7575 <https://github.com/pantsbuild/pants/pull/7575>`_

* Allow 3rdparty rust crate logging to be hidden (#7530)
`PR #7530 <https://github.com/pantsbuild/pants/pull/7530>`_

* Add debug_log macro for one-off debugging (#7566)
`PR #7566 <https://github.com/pantsbuild/pants/pull/7566>`_

* Enable pantsd in Travis (#7440)
`PR #7440 <https://github.com/pantsbuild/pants/pull/7440>`_

* Skip flaky tests in TestPantsDaemonIntegration. (#7558)
`PR #7558 <https://github.com/pantsbuild/pants/pull/7558>`_

* Don't assume a local `master` branch point. (#7557)
`PR #7557 <https://github.com/pantsbuild/pants/pull/7557>`_

* Kill unused env vars in our pre-commit hook. (#7555)
`PR #7555 <https://github.com/pantsbuild/pants/pull/7555>`_

* Remove un-needed `travis-ci.sh` ci wrapper. (#7548)
`PR #7548 <https://github.com/pantsbuild/pants/pull/7548>`_

* Build pexes that work on all Python patch versions. (#7550)
`PR #7550 <https://github.com/pantsbuild/pants/pull/7550>`_

* Fix abi3 pex check to allow abi3 wheels. (#7549)
`PR #7549 <https://github.com/pantsbuild/pants/pull/7549>`_

* Only add the CI skipping label on initial commit. (#7545)
`PR #7545 <https://github.com/pantsbuild/pants/pull/7545>`_

* Prepare 1.15.0 (#7544)
`PR #7544 <https://github.com/pantsbuild/pants/pull/7544>`_

* Don't run CI for doc-only changes. (#7537)
`PR #7537 <https://github.com/pantsbuild/pants/pull/7537>`_

Version updates
~~~~~~~~~~~~~~~

* Update to rust 1.34.0 (#7541)
`PR #7541 <https://github.com/pantsbuild/pants/pull/7541>`_

* Upgrade to pex 1.6.6. (#7186)
`PR #7186 <https://github.com/pantsbuild/pants/pull/7186>`_


1.16.0.dev1 (4/12/2019)
-----------------------

Expand Down
8 changes: 5 additions & 3 deletions src/python/pants/releases/reversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ def replace_in_file(workspace, src_file_path, from_str, to_str):
"""
from_bytes = from_str.encode('ascii')
to_bytes = to_str.encode('ascii')
data = read_file(os.path.join(workspace, src_file_path))
data = read_file(os.path.join(workspace, src_file_path), binary_mode=True)
if from_bytes not in data and from_str not in src_file_path:
return None

dst_file_path = src_file_path.replace(from_str, to_str)
safe_file_dump(os.path.join(workspace, dst_file_path), data.replace(from_bytes, to_bytes), mode='wb')
safe_file_dump(os.path.join(workspace, dst_file_path),
data.replace(from_bytes, to_bytes),
mode='wb')
if src_file_path != dst_file_path:
os.unlink(os.path.join(workspace, src_file_path))
return dst_file_path
Expand All @@ -55,7 +57,7 @@ def fingerprint_file(workspace, filename):
Returns a tuple of fingerprint string and size string.
"""
content = read_file(os.path.join(workspace, filename))
content = read_file(os.path.join(workspace, filename), binary_mode=True)
fingerprint = hashlib.sha256(content)
b64_encoded = base64.b64encode(fingerprint.digest())
return 'sha256={}'.format(b64_encoded.decode('utf-8')), str(len(content))
Expand Down
49 changes: 5 additions & 44 deletions src/python/pants/util/dirutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from collections import defaultdict
from contextlib import contextmanager

from pants.base.deprecated import deprecated_conditional
from pants.util.strutil import ensure_text


Expand Down Expand Up @@ -104,7 +103,7 @@ def safe_mkdir_for_all(paths):
# TODO(#6742): payload should be Union[str, bytes] in type hint syntax, but from
# https://pythonhosted.org/an_example_pypi_project/sphinx.html#full-code-example it doesn't appear
# that is possible to represent in docstring type syntax.
def safe_file_dump(filename, payload='', binary_mode=None, mode=None):
def safe_file_dump(filename, payload='', mode='w'):
"""Write a string to a file.
This method is "safe" to the extent that `safe_open` is "safe". See the explanation on the method
Expand All @@ -115,73 +114,35 @@ def safe_file_dump(filename, payload='', binary_mode=None, mode=None):
:param string filename: The filename of the file to write to.
:param string payload: The string to write to the file.
:param bool binary_mode: Write to file as bytes or unicode. Mutually exclusive with mode.
:param string mode: A mode argument for the python `open` builtin. Mutually exclusive with
binary_mode.
:param string mode: A mode argument for the python `open` builtin which should be a write mode
variant. Defaults to 'w'.
"""
deprecated_conditional(
lambda: binary_mode is not None,
removal_version='1.16.0.dev2',
entity_description='The binary_mode argument in safe_file_dump()',
hint_message='Use the mode argument instead!')
if binary_mode is not None and mode is not None:
raise AssertionError('Only one of `binary_mode` and `mode` may be specified.')

deprecated_conditional(
lambda: mode is None,
removal_version='1.16.0.dev2',
entity_description='Not specifying mode explicitly in safe_file_dump()',
hint_message="Function will default to unicode ('w') when pants migrates to python 3!")
if mode is None:
if binary_mode is False:
mode = 'w'
else:
mode = 'wb'

with safe_open(filename, mode=mode) as f:
f.write(payload)


def maybe_read_file(filename, binary_mode=None):
def maybe_read_file(filename, binary_mode=False):
"""Read and return the contents of a file in a single file.read().
:param string filename: The filename of the file to read.
:param bool binary_mode: Read from file as bytes or unicode.
:returns: The contents of the file, or opening the file fails for any reason
:rtype: string
"""
# TODO(#7121): Default binary_mode=False after the python 3 switchover!
deprecated_conditional(
lambda: binary_mode is None,
removal_version='1.16.0.dev2',
entity_description='Not specifying binary_mode explicitly in maybe_read_file()',
hint_message='Function will default to unicode when pants migrates to python 3!')
if binary_mode is None:
binary_mode = True

try:
return read_file(filename, binary_mode=binary_mode)
except IOError:
return None


def read_file(filename, binary_mode=None):
def read_file(filename, binary_mode=False):
"""Read and return the contents of a file in a single file.read().
:param string filename: The filename of the file to read.
:param bool binary_mode: Read from file as bytes or unicode.
:returns: The contents of the file.
:rtype: string
"""
# TODO(#7121): Default binary_mode=False after the python 3 switchover!
deprecated_conditional(
lambda: binary_mode is None,
removal_version='1.16.0.dev2',
entity_description='Not specifying binary_mode explicitly in read_file()',
hint_message='Function will default to unicode when pants migrates to python 3!')
if binary_mode is None:
binary_mode = True

mode = 'rb' if binary_mode else 'r'
with open(filename, mode) as f:
return f.read()
Expand Down
8 changes: 0 additions & 8 deletions tests/python/pants_test/util/test_dirutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,24 +396,16 @@ def test_rm_rf_no_such_file_not_an_error(self, file_name='./vanishing_file'):
def assert_dump_and_read(self, test_content, dump_kwargs, read_kwargs):
with temporary_dir() as td:
test_filename = os.path.join(td, 'test.out')
# TODO(#7121): remove all deprecated usages of `binary_mode` and `mode` arguments to
# safe_file_dump() in this file when the deprecation period is over!
safe_file_dump(test_filename, test_content, **dump_kwargs)
self.assertEqual(read_file(test_filename, **read_kwargs), test_content)

def test_readwrite_file_binary(self):
self.assert_dump_and_read(b'333', {'binary_mode': True}, {'binary_mode': True})
self.assert_dump_and_read(b'333', {'mode': 'wb'}, {'binary_mode': True})
with self.assertRaises(Exception):
# File is not opened as binary.
self.assert_dump_and_read(b'333', {'mode': 'w'}, {'binary_mode': True})
with self.assertRaises(AssertionError):
# Both `binary_mode` and `mode` specified.
# TODO(#6543): Should be removed along with https://github.com/pantsbuild/pants/issues/6543
self.assert_dump_and_read(b'333', {'binary_mode': True, 'mode': 'wb'}, {'binary_mode': True})

def test_readwrite_file_unicode(self):
self.assert_dump_and_read('✓', {'binary_mode': False}, {'binary_mode': False})
self.assert_dump_and_read('✓', {'mode': 'w'}, {'binary_mode': False})
with self.assertRaises(Exception):
# File is opened as binary.
Expand Down

0 comments on commit 09c5c09

Please sign in to comment.