guix_mirror_bot pushed a commit to branch python-team
in repository guix.
commit 0ee922442b37e1b70bd96915488f12796983b18e
Author: Nicolas Graves <[email protected]>
AuthorDate: Wed Sep 17 17:56:58 2025 +0200
build-system: pyproject: Handle multiprocessing in the entry point.
Fixes guix/guix#1089.
According to the multiprocessing documentation, the entry point should
be protected by using `if __name__ == '__main__':`, see
https://docs.python.org/3/library/multiprocessing.html#multiprocessing-programming
Note that this is not the standard implementation highlighted in
https://packaging.python.org/en/latest/specifications/entry-points/#use-for-scripts
but it will fix scripts using the standard lib multiprocessing and it
should not harm any other script.
guix/build/pyproject-build-system (create-entrypoints)
[create-script]: Wrap execution line with `if __name__ == '__main__':`
Change-Id: I450eb380cc4f613468395afd4b4eb52673d2ab1a
Signed-off-by: Sharlatan Hellseher <[email protected]>
---
guix/build/pyproject-build-system.scm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/guix/build/pyproject-build-system.scm
b/guix/build/pyproject-build-system.scm
index b7ac025963..f72032f219 100644
--- a/guix/build/pyproject-build-system.scm
+++ b/guix/build/pyproject-build-system.scm
@@ -350,7 +350,8 @@ and return write it to PATH/NAME."
# Auto-generated entry point script.
import sys
from ~a import ~a
-sys.exit(~a())~%" interpreter module function function)))
+if __name__ == '__main__':
+ sys.exit(~a())~%" interpreter module function function)))
(chmod file-path #o755)))
(let* ((site-dir (site-packages inputs outputs))