diff --git a/contrib/python/src/python/pants/contrib/python/checks/tasks/python_eval.py b/contrib/python/src/python/pants/contrib/python/checks/tasks/python_eval.py index a34f6a63737..a9f3ba4b56d 100644 --- a/contrib/python/src/python/pants/contrib/python/checks/tasks/python_eval.py +++ b/contrib/python/src/python/pants/contrib/python/checks/tasks/python_eval.py @@ -157,7 +157,7 @@ def _compile_target(self, vt): pex_info.entry_point = self._EXEC_NAME pex_info.pex_path = ':'.join(pex.path() for pex in (reqs_pex, srcs_pex) if pex) builder = PEXBuilder(safe_path, interpreter, pex_info=pex_info) - builder.freeze() + builder.freeze(bytecode_compile=False) pex = PEX(exec_pex_path, interpreter) diff --git a/src/python/pants/backend/python/subsystems/pex_build_util.py b/src/python/pants/backend/python/subsystems/pex_build_util.py index a60a92fd1c9..160bec54e8f 100644 --- a/src/python/pants/backend/python/subsystems/pex_build_util.py +++ b/src/python/pants/backend/python/subsystems/pex_build_util.py @@ -342,7 +342,7 @@ def freeze(self): dist = self._distributions.get('setuptools') if not dist: self.add_resolved_requirements([self._setuptools_requirement]) - self._builder.freeze() + self._builder.freeze(bytecode_compile=False) self._frozen = True def set_entry_point(self, entry_point): diff --git a/src/python/pants/backend/python/tasks/pytest_prep.py b/src/python/pants/backend/python/tasks/pytest_prep.py index d8cb7a5a0c4..98046119257 100644 --- a/src/python/pants/backend/python/tasks/pytest_prep.py +++ b/src/python/pants/backend/python/tasks/pytest_prep.py @@ -51,7 +51,7 @@ def __init__(self, interpreter, pex): pex_path = pex.path() pex_info = PexInfo.from_pex(pex_path) pex_info.merge_pex_path(pex_path) # We're now on the sys.path twice. - PEXBuilder(pex_path, interpreter=interpreter, pex_info=pex_info).freeze() + PEXBuilder(pex_path, interpreter=interpreter, pex_info=pex_info).freeze(bytecode_compile=False) self._pex = PEX(pex=pex_path, interpreter=interpreter) self._interpreter = interpreter diff --git a/src/python/pants/backend/python/tasks/python_execution_task_base.py b/src/python/pants/backend/python/tasks/python_execution_task_base.py index a16ada71c28..18bf85f96bd 100644 --- a/src/python/pants/backend/python/tasks/python_execution_task_base.py +++ b/src/python/pants/backend/python/tasks/python_execution_task_base.py @@ -165,6 +165,6 @@ def create_pex(self, pex_info=None): with self.merged_pex(path, pex_info, interpreter, pexes, constraints) as builder: for extra_file in self.extra_files(): extra_file.add_to(builder) - builder.freeze() + builder.freeze(bytecode_compile=False) return PEX(path, interpreter) diff --git a/src/python/pants/backend/python/tasks/resolve_requirements_task_base.py b/src/python/pants/backend/python/tasks/resolve_requirements_task_base.py index ce96519f61f..b97525bf062 100644 --- a/src/python/pants/backend/python/tasks/resolve_requirements_task_base.py +++ b/src/python/pants/backend/python/tasks/resolve_requirements_task_base.py @@ -141,4 +141,4 @@ def merged_pex(cls, path, pex_info, interpreter, pexes, interpeter_constraints=N def merge_pexes(cls, path, pex_info, interpreter, pexes, interpeter_constraints=None): """Generates a merged pex at path.""" with cls.merged_pex(path, pex_info, interpreter, pexes, interpeter_constraints) as builder: - builder.freeze() + builder.freeze(bytecode_compile=False) diff --git a/src/python/pants/backend/python/tasks/setup_py.py b/src/python/pants/backend/python/tasks/setup_py.py index 81eb8b7eb36..d2d7b020d58 100644 --- a/src/python/pants/backend/python/tasks/setup_py.py +++ b/src/python/pants/backend/python/tasks/setup_py.py @@ -464,7 +464,7 @@ def nsutil_pex(self): """).strip().format(declares_namespace_package_code=declares_namespace_package_code)) fp.close() builder.set_executable(filename=fp.name, env_filename='main.py') - builder.freeze() + builder.freeze(bytecode_compile=False) return PEX(pex=chroot, interpreter=interpreter) def filter_namespace_packages(self, root_target, inits): diff --git a/testprojects/src/python/unicode/compilation_failure/BUILD b/testprojects/src/python/unicode/compilation_failure/BUILD index d80ecb5983c..583aad95a20 100644 --- a/testprojects/src/python/unicode/compilation_failure/BUILD +++ b/testprojects/src/python/unicode/compilation_failure/BUILD @@ -1 +1,3 @@ -python_library() +python_binary( + source = 'main.py' +) diff --git a/testprojects/src/python/unicode/compilation_failure/main.py b/testprojects/src/python/unicode/compilation_failure/main.py index ac91b628dd1..e400713d445 100644 --- a/testprojects/src/python/unicode/compilation_failure/main.py +++ b/testprojects/src/python/unicode/compilation_failure/main.py @@ -1,4 +1,6 @@ -# This file is expected to fail to "compile", and raise a unicode error while doing so. +# This file is expected to fail to "compile" when run via `./pants run` due to a SyntaxError. # Because the error itself contains unicode, it can exercise that error handling codepaths # are unicode aware. -import sys¡ + +if __name__ == '__main__': + import sys¡ diff --git a/tests/python/pants_test/base/test_exiter_integration.py b/tests/python/pants_test/base/test_exiter_integration.py index 0237bbeabc4..23c235f9d5d 100644 --- a/tests/python/pants_test/base/test_exiter_integration.py +++ b/tests/python/pants_test/base/test_exiter_integration.py @@ -13,8 +13,7 @@ class ExiterIntegrationTest(PantsRunIntegrationTest): @ensure_daemon def test_unicode_containing_exception(self): """Test whether we can run a single target without special flags.""" - pants_run = self.run_pants(['test', 'testprojects/src/python/unicode/compilation_failure']) + pants_run = self.run_pants(['run', 'testprojects/src/python/unicode/compilation_failure']) self.assert_failure(pants_run) - self.assertIn('during bytecode compilation', pants_run.stderr_data) self.assertIn('import sys¡', pants_run.stderr_data)