@@ -394,53 +394,59 @@ def _whl_library_impl(rctx):
394394 )
395395 entry_points [entry_point_without_py ] = entry_point_script_name
396396
397- # TODO @aignas 2025-02-24: move this to pkg_aliases layer to have this in
398- # the analysis phase. This means that we need to get the target platform abi
399- # from the python version/versions we are setting the package up for. We can
400- # potentially get this from the python toolchain interpreter.
397+ # TODO @aignas 2025-04-04: move this to whl_library_targets.bzl to have
398+ # this in the analysis phase.
399+ #
400+ # This means that whl_library_targets will have to accept the following args:
401+ # * name - the name of the package in the METADATA.
402+ # * requires_dist - the list of METADATA RequiresDist.
403+ # * platforms - the list of target platforms. The target_platforms
404+ # should come from the hub repo via a 'load' statement so that they don't
405+ # need to be passed as an argument to `whl_library`.
406+ # * extras - the list of required extras. This comes from the
407+ # `rctx.attr.requirement` for now. In the future the required extras could
408+ # stay in the hub repo, where we calculate the extra aliases that we need
409+ # to create automatically and this way expose the targets for the specific
410+ # extras. The first step will be to generate a target per extra for the
411+ # `py_library` and `filegroup`. Maybe we need to have a special provider
412+ # or an output group so that we can return the `whl` file from the
413+ # `py_library` target? filegroup can use output groups to expose files.
414+ # * host_python_version/versons - the list of python versions to support
415+ # should come from the hub, similar to how the target platforms are specified.
416+ #
417+ # Extra things that we should move at the same time:
418+ # * group_name, group_deps - this info can stay in the hub repository so that
419+ # it is piped at the analysis time and changing the requirement groups does
420+ # cause to re-fetch the deps.
401421 package_deps = deps (
402- # TODO @aignas 2025-02-24: get the data here by parsing the METADATA
403- # file manually without involving python interpreter at all.
422+ # TODO @aignas 2025-04-04: get the following from manually parsing
423+ # METADATA to avoid Python dependency:
424+ # * name of the package
425+ # * version of the package
426+ # * RequiresDist
427+ # * ProvidesExtras
404428 name = metadata ["name" ],
405429 requires_dist = metadata ["requires_dist" ],
406- # target the host platform if the target platform is not specified in the rule.
407- # TODO @aignas 2025-03-23: we should materialize this inside the
408- # hub_repository `requirements.bzl` file as `TARGET_PLATFORMS` with a
409- # note, that this is internal and will be only for usage of the
410- # `whl_library`
411430 platforms = target_platforms or [
412431 "{}_{}" .format (metadata ["abi" ], host_platform (rctx )),
413432 ],
414- # TODO @aignas 2025-03-23: we should expose the requested extras via a
415- # dict in `requirements.bzl` `EXTRAS` where the key is the package name
416- # and the value is the list of requested extras. like the above, for
417- # internal usage only.
418433 extras = metadata ["extras" ],
419- # TODO @aignas 2025-03-23: we should expose full python version via the
420- # TARGET_PYTHON_VERSIONS list so that we can correctly calculate the
421- # deps. This would be again, internal only stuff.
422434 host_python_version = metadata ["python_version" ],
423435 )
424436
425437 build_file_contents = generate_whl_library_build_bazel (
426438 name = whl_path .basename ,
427- # TODO @aignas 2025-03-23: load the dep_template from the hub repository
428439 dep_template = rctx .attr .dep_template or "@{}{{name}}//:{{target}}" .format (rctx .attr .repo_prefix ),
429- # TODO @aignas 2025-03-23: replace `dependencies` and
430- # `dependencies_by_platform` with `requires_dist`.
431440 dependencies = package_deps .deps ,
432441 dependencies_by_platform = package_deps .deps_select ,
433- # TODO @aignas 2025-03-23: store the `group_name` per package in the hub repo
434442 group_name = rctx .attr .group_name ,
435443 group_deps = rctx .attr .group_deps ,
436- # TODO @aignas 2025-03-23: store the pip_data_exclude in the hub repo.
437444 data_exclude = rctx .attr .pip_data_exclude ,
438445 tags = [
439446 "pypi_name=" + metadata ["name" ],
440447 "pypi_version=" + metadata ["version" ],
441448 ],
442449 entry_points = entry_points ,
443- # TODO @aignas 2025-03-23: store the annotation in the hub repo.
444450 annotation = None if not rctx .attr .annotation else struct (** json .decode (rctx .read (rctx .attr .annotation ))),
445451 )
446452 rctx .file ("BUILD.bazel" , build_file_contents )
0 commit comments