From dec3b249cdb929dc0e56de75e30a59c66920ec33 Mon Sep 17 00:00:00 2001 From: Nicolas Graves Date: Wed, 17 Sep 2025 17:56:58 +0200 Subject: [PATCH] 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 --- 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 b7ac02596393563aca533d094d649b284be5da7a..f72032f21977c294770d7e7ea6da47b56a3fa1d7 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))