File tree 1 file changed +29
-1
lines changed 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -386,13 +386,41 @@ def _whl_library_impl(rctx):
386
386
"pypi_name=" + metadata ["name" ],
387
387
"pypi_version=" + metadata ["version" ],
388
388
],
389
- entry_points = {} ,
389
+ entry_points = entry_points ,
390
390
annotation = None if not rctx .attr .annotation else struct (** json .decode (rctx .read (rctx .attr .annotation ))),
391
391
)
392
392
rctx .file ("BUILD.bazel" , build_file_contents )
393
393
394
394
return
395
395
396
+ def _generate_entry_point_contents (
397
+ module ,
398
+ attribute ,
399
+ shebang = "#!/usr/bin/env python3" ):
400
+ """Generate the contents of an entry point script.
401
+
402
+ Args:
403
+ module (str): The name of the module to use.
404
+ attribute (str): The name of the attribute to call.
405
+ shebang (str, optional): The shebang to use for the entry point python
406
+ file.
407
+
408
+ Returns:
409
+ str: A string of python code.
410
+ """
411
+ contents = """\
412
+ {shebang}
413
+ import sys
414
+ from {module} import {attribute}
415
+ if __name__ == "__main__":
416
+ sys.exit({attribute}())
417
+ """ .format (
418
+ shebang = shebang ,
419
+ module = module ,
420
+ attribute = attribute ,
421
+ )
422
+ return contents
423
+
396
424
# NOTE @aignas 2024-03-21: The usage of dict({}, **common) ensures that all args to `dict` are unique
397
425
whl_library_attrs = dict ({
398
426
"annotation" : attr .label (
You can’t perform that action at this time.
0 commit comments