@@ -24,6 +24,7 @@ load(":generate_whl_library_build_bazel.bzl", "generate_whl_library_build_bazel"
2424load (":parse_requirements.bzl" , "host_platform" )
2525load (":parse_whl_name.bzl" , "parse_whl_name" )
2626load (":patch_whl.bzl" , "patch_whl" )
27+ load (":pep508_env.bzl" , "deps" )
2728load (":pypi_repo_utils.bzl" , "pypi_repo_utils" )
2829load (":whl_target_platforms.bzl" , "whl_target_platforms" )
2930
@@ -353,22 +354,13 @@ def _whl_library_impl(rctx):
353354 )
354355 entry_points [entry_point_without_py ] = entry_point_script_name
355356
356- build_file_contents = generate_whl_library_build_bazel (
357- whl_name = whl_path .basename ,
358- # TODO @aignas 2025-03-23: load the dep_template from the hub repository
359- dep_template = rctx .attr .dep_template or "@{}{{name}}//:{{target}}" .format (rctx .attr .repo_prefix ),
360- # TODO @aignas 2025-03-23: store the `group_name` per package in the hub repo
361- group_name = rctx .attr .group_name ,
362- group_deps = rctx .attr .group_deps ,
363- # TODO @aignas 2025-03-23: store the pip_data_exclude in the hub repo.
364- data_exclude = rctx .attr .pip_data_exclude ,
365- tags = [
366- "pypi_name=" + metadata ["name" ],
367- "pypi_version=" + metadata ["version" ],
368- ],
369- entry_points = entry_points ,
370- # TODO @aignas 2025-03-23: store the annotation in the hub repo.
371- annotation = None if not rctx .attr .annotation else struct (** json .decode (rctx .read (rctx .attr .annotation ))),
357+ # TODO @aignas 2025-02-24: move this to pkg_aliases layer to have this in
358+ # the analysis phase. This means that we need to get the target platform abi
359+ # from the python version/versions we are setting the package up for. We can
360+ # potentially get this from the python toolchain interpreter.
361+ package_deps = deps (
362+ # TODO @aignas 2025-02-24: get the data here by parsing the METADATA
363+ # file manually without involving python interpreter at all.
372364 name = metadata ["name" ],
373365 requires_dist = metadata ["requires_dist" ],
374366 # target the host platform if the target platform is not specified in the rule.
@@ -389,6 +381,28 @@ def _whl_library_impl(rctx):
389381 # deps. This would be again, internal only stuff.
390382 host_python_version = metadata ["python_version" ],
391383 )
384+
385+ build_file_contents = generate_whl_library_build_bazel (
386+ name = whl_path .basename ,
387+ # TODO @aignas 2025-03-23: load the dep_template from the hub repository
388+ dep_template = rctx .attr .dep_template or "@{}{{name}}//:{{target}}" .format (rctx .attr .repo_prefix ),
389+ # TODO @aignas 2025-03-23: replace `dependencies` and
390+ # `dependencies_by_platform` with `requires_dist`.
391+ dependencies = package_deps .deps ,
392+ dependencies_by_platform = package_deps .deps_select ,
393+ # TODO @aignas 2025-03-23: store the `group_name` per package in the hub repo
394+ group_name = rctx .attr .group_name ,
395+ group_deps = rctx .attr .group_deps ,
396+ # TODO @aignas 2025-03-23: store the pip_data_exclude in the hub repo.
397+ data_exclude = rctx .attr .pip_data_exclude ,
398+ tags = [
399+ "pypi_name=" + metadata ["name" ],
400+ "pypi_version=" + metadata ["version" ],
401+ ],
402+ entry_points = entry_points ,
403+ # TODO @aignas 2025-03-23: store the annotation in the hub repo.
404+ annotation = None if not rctx .attr .annotation else struct (** json .decode (rctx .read (rctx .attr .annotation ))),
405+ )
392406 rctx .file ("BUILD.bazel" , build_file_contents )
393407
394408 return
0 commit comments