@@ -30,7 +30,6 @@ load(":whl_target_platforms.bzl", "whl_target_platforms")
3030
3131_CPPFLAGS = "CPPFLAGS"
3232_COMMAND_LINE_TOOLS_PATH_SLUG = "commandlinetools"
33- _WHEEL_ENTRY_POINT_PREFIX = "rules_python_wheel_entry_point"
3433
3534def _get_xcode_location_cflags (rctx , logger = None ):
3635 """Query the xcode sdk location to update cflags
@@ -399,38 +398,14 @@ def _whl_library_impl(rctx):
399398 logger = logger ,
400399 )
401400
402- # NOTE @aignas 2024-06-22: this has to live on until we stop supporting
403- # passing `twine` as a `:pkg` library via the `WORKSPACE` builds.
404- #
405- # See ../../packaging.bzl line 190
406- entry_points = {}
407- for item in metadata .entry_points :
408- name = item .name
409- module = item .module
410- attribute = item .attribute
411-
412- # There is an extreme edge-case with entry_points that end with `.py`
413- # See: https://github.com/bazelbuild/bazel/blob/09c621e4cf5b968f4c6cdf905ab142d5961f9ddc/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java#L174
414- entry_point_without_py = name [:- 3 ] + "_py" if name .endswith (".py" ) else name
415- entry_point_target_name = (
416- _WHEEL_ENTRY_POINT_PREFIX + "_" + entry_point_without_py
417- )
418- entry_point_script_name = entry_point_target_name + ".py"
419-
420- rctx .file (
421- entry_point_script_name ,
422- _generate_entry_point_contents (module , attribute ),
423- )
424- entry_points [entry_point_without_py ] = entry_point_script_name
425-
426401 build_file_contents = generate_whl_library_build_bazel (
427402 name = whl_path .basename ,
428403 sdist_filename = sdist_filename ,
429404 dep_template = rctx .attr .dep_template or "@{}{{name}}//:{{target}}" .format (
430405 rctx .attr .repo_prefix ,
431406 ),
432407 config_load = rctx .attr .config_load ,
433- entry_points = entry_points ,
408+ entry_points = [ e . name for e in metadata . entry_points ] ,
434409 metadata_name = metadata .name ,
435410 metadata_version = metadata .version ,
436411 requires_dist = metadata .requires_dist ,
@@ -476,35 +451,11 @@ def _whl_library_impl(rctx):
476451 metadata = json .decode (rctx .read ("metadata.json" ))
477452 rctx .delete ("metadata.json" )
478453
479- # NOTE @aignas 2024-06-22: this has to live on until we stop supporting
480- # passing `twine` as a `:pkg` library via the `WORKSPACE` builds.
481- #
482- # See ../../packaging.bzl line 190
483- entry_points = {}
484- for item in metadata ["entry_points" ]:
485- name = item ["name" ]
486- module = item ["module" ]
487- attribute = item ["attribute" ]
488-
489- # There is an extreme edge-case with entry_points that end with `.py`
490- # See: https://github.com/bazelbuild/bazel/blob/09c621e4cf5b968f4c6cdf905ab142d5961f9ddc/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java#L174
491- entry_point_without_py = name [:- 3 ] + "_py" if name .endswith (".py" ) else name
492- entry_point_target_name = (
493- _WHEEL_ENTRY_POINT_PREFIX + "_" + entry_point_without_py
494- )
495- entry_point_script_name = entry_point_target_name + ".py"
496-
497- rctx .file (
498- entry_point_script_name ,
499- _generate_entry_point_contents (module , attribute ),
500- )
501- entry_points [entry_point_without_py ] = entry_point_script_name
502-
503454 build_file_contents = generate_whl_library_build_bazel (
504455 name = whl_path .basename ,
505456 sdist_filename = sdist_filename ,
506457 dep_template = rctx .attr .dep_template or "@{}{{name}}//:{{target}}" .format (rctx .attr .repo_prefix ),
507- entry_points = entry_points ,
458+ entry_points = [ e [ "name" ] for e in metadata [ " entry_points" ]] ,
508459 # TODO @aignas 2025-05-17: maybe have a build flag for this instead
509460 enable_implicit_namespace_pkgs = rctx .attr .enable_implicit_namespace_pkgs ,
510461 # TODO @aignas 2025-04-14: load through the hub:
@@ -542,34 +493,6 @@ def _whl_library_impl(rctx):
542493 rctx .file ("BUILD.bazel" , build_file_contents )
543494 return
544495
545- def _generate_entry_point_contents (
546- module ,
547- attribute ,
548- shebang = "#!/usr/bin/env python3" ):
549- """Generate the contents of an entry point script.
550-
551- Args:
552- module (str): The name of the module to use.
553- attribute (str): The name of the attribute to call.
554- shebang (str, optional): The shebang to use for the entry point python
555- file.
556-
557- Returns:
558- str: A string of python code.
559- """
560- contents = """\
561- {shebang}
562- import sys
563- from {module} import {attribute}
564- if __name__ == "__main__":
565- sys.exit({attribute}())
566- """ .format (
567- shebang = shebang ,
568- module = module ,
569- attribute = attribute ,
570- )
571- return contents
572-
573496# NOTE @aignas 2024-03-21: The usage of dict({}, **common) ensures that all args to `dict` are unique
574497whl_library_attrs = dict ({
575498 "annotation" : attr .label (
0 commit comments