Skip to content

Commit

Permalink
Work around (?) pantsbuild#6282.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuhood committed Aug 8, 2018
1 parent 8c1b411 commit eabd8c5
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions tests/python/pants_test/backend/python/tasks/test_gather_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)

0 comments on commit eabd8c5

Please sign in to comment.