diff --git a/tests/python/pants_test/backend/codegen/thrift/python/test_apache_thrift_py_gen.py b/tests/python/pants_test/backend/codegen/thrift/python/test_apache_thrift_py_gen.py index b632a7ccc4b..8f68070b159 100644 --- a/tests/python/pants_test/backend/codegen/thrift/python/test_apache_thrift_py_gen.py +++ b/tests/python/pants_test/backend/codegen/thrift/python/test_apache_thrift_py_gen.py @@ -149,7 +149,13 @@ def test_namespace_effective(self): interpreter_cache = PythonInterpreterCache(python_setup, python_repos) interpreter = interpreter_cache.select_interpreter_for_targets(targets) - pythonpath = [os.path.join(get_buildroot(), t.target_base) for t in targets] + # We need setuptools to import namespace packages (via pkg_resources), so we prime the + # PYTHONPATH with interpreter extras, which Pants always populates with setuptools and wheel. + # TODO(John Sirois): We really should be emitting setuptools in a + # `synthetic_target_extra_dependencies` override in `ApacheThriftPyGen`: + # https://github.com/pantsbuild/pants/issues/5975 + pythonpath = interpreter.extras.values() + pythonpath.extend(os.path.join(get_buildroot(), t.target_base) for t in targets) for dist in resolve(['thrift=={}'.format(self.get_thrift_version(apache_thrift_gen))], interpreter=interpreter, context=python_repos.get_network_context(),