From eabd8c5a699590cb28cac40da81db8e00fab91da Mon Sep 17 00:00:00 2001 From: Stu Hood Date: Tue, 7 Aug 2018 17:31:34 -0700 Subject: [PATCH] Work around (?) #6282. --- .../python/tasks/test_gather_sources.py | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/tests/python/pants_test/backend/python/tasks/test_gather_sources.py b/tests/python/pants_test/backend/python/tasks/test_gather_sources.py index db9a0f975187..b95d0bb648a6 100644 --- a/tests/python/pants_test/backend/python/tasks/test_gather_sources.py +++ b/tests/python/pants_test/backend/python/tasks/test_gather_sources.py @@ -17,6 +17,7 @@ from pants.build_graph.files import Files from pants.build_graph.resources import Resources from pants.source.source_root import SourceRootConfig +from pants.util.contextutil import temporary_dir from pants_test.task_test_base import TaskTestBase @@ -106,19 +107,22 @@ def test_gather_files(self): self._assert_content_not_in_pex(pex, self.resources) def _gather_sources(self, target_roots): - context = self.context(target_roots=target_roots, for_subsystems=[PythonSetup, PythonRepos]) - - # We must get an interpreter via the cache, instead of using PythonInterpreter.get() directly, - # to ensure that the interpreter has setuptools and wheel support. - interpreter = PythonInterpreter.get() - interpreter_cache = PythonInterpreterCache(PythonSetup.global_instance(), - PythonRepos.global_instance(), - logger=context.log.debug) - interpreters = interpreter_cache.setup(paths=[os.path.dirname(interpreter.binary)], - filters=[str(interpreter.identity.requirement)]) - context.products.get_data(PythonInterpreter, lambda: interpreters[0]) - - task = self.create_task(context) - task.execute() - - return context.products.get_data(GatherSources.PYTHON_SOURCES) + with temporary_dir() as cache_dir: + context = self.context(target_roots=target_roots, + for_subsystems=[PythonSetup, PythonRepos], + options={PythonSetup.options_scope: {'interpreter_cache_dir': cache_dir}}) + + # We must get an interpreter via the cache, instead of using PythonInterpreter.get() directly, + # to ensure that the interpreter has setuptools and wheel support. + interpreter = PythonInterpreter.get() + interpreter_cache = PythonInterpreterCache(PythonSetup.global_instance(), + PythonRepos.global_instance(), + logger=context.log.debug) + interpreters = interpreter_cache.setup(paths=[os.path.dirname(interpreter.binary)], + filters=[str(interpreter.identity.requirement)]) + context.products.get_data(PythonInterpreter, lambda: interpreters[0]) + + task = self.create_task(context) + task.execute() + + return context.products.get_data(GatherSources.PYTHON_SOURCES)