@@ -183,7 +183,8 @@ def _parse_optional_attrs(rctx, args, extra_pip_args = None):
183183 if rctx .attr .add_libdir_to_library_search_path :
184184 if "LDFLAGS" in env :
185185 fail ("Can't set both environment LDFLAGS and add_libdir_to_library_search_path" )
186- command = [pypi_repo_utils .resolve_python_interpreter (rctx ), "-c" , "import sys ; sys.stdout.write('{}/lib'.format(sys.exec_prefix))" ]
186+ command = [
187+ pypi_repo_utils .resolve_python_interpreter (rctx ), "-c" , "import sys ; sys.stdout.write('{}/lib'.format(sys.exec_prefix))" ]
187188 result = rctx .execute (command )
188189 if result .return_code != 0 :
189190 fail ("Failed to get LDFLAGS path: command: {}, exit code: {}, stdout: {}, stderr: {}" .format (command , result .return_code , result .stdout , result .stderr ))
@@ -292,22 +293,11 @@ def _extract_whl_py(rctx, *, python_interpreter, args, whl_path, environment, lo
292293
293294def _whl_library_impl (rctx ):
294295 logger = repo_utils .logger (rctx )
295- python_interpreter = pypi_repo_utils .resolve_python_interpreter (
296- rctx ,
297- python_interpreter = rctx .attr .python_interpreter ,
298- python_interpreter_target = rctx .attr .python_interpreter_target ,
299- )
300- args = [
301- "-m" ,
302- "python.private.pypi.whl_installer.wheel_installer" ,
303- "--requirement" ,
304- rctx .attr .requirement ,
305- ]
306- extra_pip_args = []
307- extra_pip_args .extend (rctx .attr .extra_pip_args )
308296
309297 whl_path = None
310298 sdist_filename = None
299+ extra_pip_args = []
300+ extra_pip_args .extend (rctx .attr .extra_pip_args )
311301 if rctx .attr .whl_file :
312302 rctx .watch (rctx .attr .whl_file )
313303 whl_path = rctx .path (rctx .attr .whl_file )
@@ -352,8 +342,6 @@ def _whl_library_impl(rctx):
352342 # build deps from PyPI (e.g. `flit_core`) if they are missing.
353343 extra_pip_args .extend (["--find-links" , "." ])
354344
355- args = _parse_optional_attrs (rctx , args , extra_pip_args )
356-
357345 # also enable pipstar for any whls that are downloaded without `pip`
358346 enable_pipstar = (rp_config .enable_pipstar or whl_path ) and rctx .attr .config_load
359347 enable_pipstar_extract = enable_pipstar and rp_config .bazel_8_or_later
@@ -362,7 +350,21 @@ def _whl_library_impl(rctx):
362350 # to setup env vars to run Python, unless we need to build an sdist
363351 if enable_pipstar_extract and whl_path :
364352 environment = {}
353+ args = []
354+ python_interpreter = None
365355 else :
356+ python_interpreter = pypi_repo_utils .resolve_python_interpreter (
357+ rctx ,
358+ python_interpreter = rctx .attr .python_interpreter ,
359+ python_interpreter_target = rctx .attr .python_interpreter_target ,
360+ )
361+ args = [
362+ "-m" ,
363+ "python.private.pypi.whl_installer.wheel_installer" ,
364+ "--requirement" ,
365+ rctx .attr .requirement ,
366+ ]
367+ args = _parse_optional_attrs (rctx , args , extra_pip_args )
366368 # Manually construct the PYTHONPATH since we cannot use the toolchain here
367369 environment = _create_repository_execution_environment (rctx , python_interpreter , logger = logger )
368370
0 commit comments