16
16
from pants .backend .python .python_requirement import PythonRequirement
17
17
from pants .backend .python .targets .python_distribution import PythonDistribution
18
18
from pants .backend .python .targets .python_requirement_library import PythonRequirementLibrary
19
- from pants .backend .python .tasks .setup_py import SetupPyRunner
19
+ from pants .backend .python .tasks .setup_py import SetupPyInvocationEnvironment , SetupPyRunner
20
20
from pants .base .build_environment import get_buildroot
21
21
from pants .base .exceptions import TargetDefinitionException , TaskError
22
22
from pants .base .fingerprint_strategy import DefaultFingerprintStrategy
23
23
from pants .build_graph .address import Address
24
24
from pants .task .task import Task
25
- from pants .util .contextutil import environment_as , get_joined_path
25
+ from pants .util .contextutil import environment_as
26
26
from pants .util .dirutil import safe_mkdir
27
27
from pants .util .memo import memoized_method
28
28
@@ -103,6 +103,11 @@ def _copy_sources(self, dist_tgt, dist_target_dir):
103
103
src_relative_to_target_base )
104
104
shutil .copyfile (abs_src_path , src_rel_to_results_dir )
105
105
106
+ def _request_single (self , product , subject ):
107
+ # This is not supposed to be exposed to Tasks yet -- see #4769 to track the
108
+ # status of exposing v2 products in v1 tasks.
109
+ return self .context ._scheduler .product_request (product , [subject ])[0 ]
110
+
106
111
# FIXME(cosmicexplorer): We should be isolating the path to just our provided
107
112
# toolchain, but this causes errors in Travis because distutils looks for
108
113
# "x86_64-linux-gnu-gcc" when linking native extensions. We almost definitely
@@ -111,11 +116,9 @@ def _copy_sources(self, dist_tgt, dist_target_dir):
111
116
# compiler installed. Right now we just put our tools at the end of the PATH.
112
117
@contextmanager
113
118
def _setup_py_invocation_environment (self ):
114
- native_toolchain = self ._native_toolchain_instance ()
115
- native_toolchain_path_entries = native_toolchain .path_entries ()
116
- appended_native_toolchain_path = get_joined_path (
117
- native_toolchain_path_entries , os .environ .copy ())
118
- with environment_as (PATH = appended_native_toolchain_path ):
119
+ setup_py_env = self ._request_single (
120
+ SetupPyInvocationEnvironment , self ._native_toolchain_instance ())
121
+ with environment_as (** setup_py_env .as_env_dict ()):
119
122
yield
120
123
121
124
def _create_dist (self , dist_tgt , dist_target_dir , interpreter ):
0 commit comments