@@ -344,9 +344,7 @@ def _whl_library_impl(rctx):
344344 # build deps from PyPI (e.g. `flit_core`) if they are missing.
345345 extra_pip_args .extend (["--find-links" , "." ])
346346
347- # also enable pipstar for any whls that are downloaded without `pip`
348- enable_pipstar = (rp_config .enable_pipstar or whl_path ) and rctx .attr .config_load
349- enable_pipstar_extract = enable_pipstar and rp_config .bazel_8_or_later
347+ enable_pipstar_extract = rp_config .bazel_8_or_later
350348
351349 # When pipstar is enabled, Python isn't used, so there's no need
352350 # to setup env vars to run Python, unless we need to build an sdist
@@ -428,65 +426,34 @@ def _whl_library_impl(rctx):
428426 logger = logger ,
429427 )
430428
431- # NOTE @aignas 2025-09-28: if someone has an old vendored file that does not have the
432- # dep_template set or the packages is not set either, we should still not break, best to
433- # disable pipstar for that particular case.
434- #
435- # Remove non-pipstar and config_load check when we release rules_python 2.
436- if enable_pipstar :
437- install_dir_path = whl_path .dirname .get_child ("site-packages" )
438- metadata = whl_metadata (
439- install_dir = install_dir_path ,
440- read_fn = rctx .read ,
441- logger = logger ,
442- )
443- namespace_package_files = pypi_repo_utils .find_namespace_package_files (rctx , install_dir_path )
444-
445- build_file_contents = generate_whl_library_build_bazel (
446- name = whl_path .basename ,
447- sdist_filename = sdist_filename ,
448- dep_template = rctx .attr .dep_template or "@{}{{name}}//:{{target}}" .format (
449- rctx .attr .repo_prefix ,
450- ),
451- config_load = rctx .attr .config_load ,
452- metadata_name = metadata .name ,
453- metadata_version = metadata .version ,
454- requires_dist = metadata .requires_dist ,
455- # TODO @aignas 2025-05-17: maybe have a build flag for this instead
456- enable_implicit_namespace_pkgs = rctx .attr .enable_implicit_namespace_pkgs ,
457- # TODO @aignas 2025-04-14: load through the hub:
458- annotation = None if not rctx .attr .annotation else struct (** json .decode (rctx .read (rctx .attr .annotation ))),
459- data_exclude = rctx .attr .pip_data_exclude ,
460- group_deps = rctx .attr .group_deps ,
461- group_name = rctx .attr .group_name ,
462- namespace_package_files = namespace_package_files ,
463- extras = requirement (rctx .attr .requirement ).extras ,
464- )
465- else :
466- metadata = json .decode (rctx .read ("metadata.json" ))
467- rctx .delete ("metadata.json" )
468-
469- namespace_package_files = pypi_repo_utils .find_namespace_package_files (rctx , rctx .path ("site-packages" ))
470-
471- build_file_contents = generate_whl_library_build_bazel (
472- name = whl_path .basename ,
473- sdist_filename = sdist_filename ,
474- dep_template = rctx .attr .dep_template or "@{}{{name}}//:{{target}}" .format (rctx .attr .repo_prefix ),
475- # TODO @aignas 2025-05-17: maybe have a build flag for this instead
476- enable_implicit_namespace_pkgs = rctx .attr .enable_implicit_namespace_pkgs ,
477- # TODO @aignas 2025-04-14: load through the hub:
478- dependencies = metadata ["deps" ],
479- dependencies_by_platform = metadata ["deps_by_platform" ],
480- annotation = None if not rctx .attr .annotation else struct (** json .decode (rctx .read (rctx .attr .annotation ))),
481- data_exclude = rctx .attr .pip_data_exclude ,
482- group_deps = rctx .attr .group_deps ,
483- group_name = rctx .attr .group_name ,
484- tags = [
485- "pypi_name={}" .format (metadata ["name" ]),
486- "pypi_version={}" .format (metadata ["version" ]),
487- ],
488- namespace_package_files = namespace_package_files ,
489- )
429+ install_dir_path = whl_path .dirname .get_child ("site-packages" )
430+ metadata = whl_metadata (
431+ install_dir = install_dir_path ,
432+ read_fn = rctx .read ,
433+ logger = logger ,
434+ )
435+ namespace_package_files = pypi_repo_utils .find_namespace_package_files (rctx , install_dir_path )
436+
437+ build_file_contents = generate_whl_library_build_bazel (
438+ name = whl_path .basename ,
439+ sdist_filename = sdist_filename ,
440+ dep_template = rctx .attr .dep_template or "@{}{{name}}//:{{target}}" .format (
441+ rctx .attr .repo_prefix ,
442+ ),
443+ config_load = rctx .attr .config_load ,
444+ metadata_name = metadata .name ,
445+ metadata_version = metadata .version ,
446+ requires_dist = metadata .requires_dist ,
447+ # TODO @aignas 2025-05-17: maybe have a build flag for this instead
448+ enable_implicit_namespace_pkgs = rctx .attr .enable_implicit_namespace_pkgs ,
449+ # TODO @aignas 2025-04-14: load through the hub:
450+ annotation = None if not rctx .attr .annotation else struct (** json .decode (rctx .read (rctx .attr .annotation ))),
451+ data_exclude = rctx .attr .pip_data_exclude ,
452+ group_deps = rctx .attr .group_deps ,
453+ group_name = rctx .attr .group_name ,
454+ namespace_package_files = namespace_package_files ,
455+ extras = requirement (rctx .attr .requirement ).extras ,
456+ )
490457
491458 # Delete these in case the wheel had them. They generally don't cause
492459 # a problem, but let's avoid the chance of that happening.
@@ -509,7 +476,7 @@ def _whl_library_impl(rctx):
509476
510477 rctx .file ("BUILD.bazel" , build_file_contents )
511478
512- if enable_pipstar and enable_pipstar_extract :
479+ if enable_pipstar_extract :
513480 if hasattr (rctx , "repo_metadata" ):
514481 return rctx .repo_metadata (reproducible = True )
515482
0 commit comments