Skip to content

Commit

Permalink
Kill python binary path existince checking.
Browse files Browse the repository at this point in the history
Since this is now done in PythonBinary internally, we can revert to the
cleaner check. Additionally, this self-contained handling now removes
the need for PythonInterpreter cache clearing in
test_select_interpreter.py.
  • Loading branch information
jsirois committed Feb 21, 2020
1 parent 42e38a7 commit 6d4f506
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
6 changes: 0 additions & 6 deletions src/python/pants/backend/python/tasks/select_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ def _get_interpreter(self, interpreter_path_file, targets):
if os.path.exists(interpreter_path_file):
with open(interpreter_path_file, 'r') as infile:
binary = infile.read().strip()
# TODO: Remove this temporary check once we have https://github.com/pantsbuild/pex/pull/886.
if not os.path.exists(binary):
self.context.log.info('Stale interpreter reference detected: {}, removing reference and '
'selecting a new interpreter.'.format(binary))
os.remove(interpreter_path_file)
return self._select_interpreter(interpreter_path_file, targets)
try:
return PythonInterpreter.from_binary(binary)
except PythonInterpreter.Error:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from typing import Tuple

from pex.interpreter import PythonInterpreter
from pex.variables import ENV

from pants.backend.python.interpreter_cache import PythonInterpreterCache
from pants.backend.python.targets.python_library import PythonLibrary
Expand All @@ -18,7 +17,7 @@
from pants.option.ranked_value import RankedValue
from pants.python.python_setup import PythonSetup
from pants.testutil.task_test_base import TaskTestBase
from pants.util.dirutil import chmod_plus_x, safe_mkdtemp, safe_rmtree
from pants.util.dirutil import chmod_plus_x, safe_mkdtemp


class SelectInterpreterTest(TaskTestBase):
Expand All @@ -33,9 +32,6 @@ def setUp(self):
# only one value no matter what arguments, environment or input stream it has attached. That
# value is the interpreter identity which is a JSON dict with exactly the following keys:
# binary, python_tag, abi_tag, platform_tag, version, supported_tags, env_markers.

# <impl> <abi> <impl_version> <major> <minor> <patch>

def fake_interpreter(python_tag: str, abi_tag: str, version: Tuple[int, int, int]):
interpreter_dir = safe_mkdtemp()
binary = os.path.join(interpreter_dir, 'python')
Expand Down Expand Up @@ -90,11 +86,6 @@ def _fake_target(self, spec, compatibility=None, sources=None, dependencies=None
dependencies=dependencies, compatibility=compatibility)

def _select_interpreter(self, target_roots, should_invalidate=None):
# TODO: Call PythonInterpreter.clear_cache() instead, when
# https://github.com/pantsbuild/pex/pull/885 is available.
interpreter_cache_dir = os.path.join(ENV.PEX_ROOT, 'interpreters')
safe_rmtree(interpreter_cache_dir)

context = self.context(target_roots=target_roots)

task = self.create_task(context)
Expand Down

0 comments on commit 6d4f506

Please sign in to comment.