You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Apple testbed fails to build when its path contains a space #162034
The iOS testbed fails to build when it is cloned to a path that contains a space. Its "Process Python libraries" build phase runs source $PROJECT_DIR/Python.xcframework/build/utils.sh without quotes, so the shell splits the path at the space. The tvOS, visionOS and watchOS projects have the same line, and so does the iOS project on the 3.14 and 3.15 branches.
$ python Platforms/Apple/testbed clone --framework Python.xcframework "<dir>/with space/tb"
$ python "<dir>/with space/tb" run -- platform
...
<dir>/with space/tb/DerivedData/.../Script-607A66552B0F061D0010BFC8.sh: line 3: <dir>/with: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code
** TEST BUILD FAILED **
The same clone under <dir>/with-hyphen/tb builds and its test passes. This was on Xcode 27.2 with the iOS 27.2 simulator, using a 3.14.10 iOS XCframework.
The unquoted path is also glob-expanded. Run on its own with PROJECT_DIR=<dir>/run[x], the build phase sourced <dir>/runx/Python.xcframework/build/utils.sh, which existed next to it, instead of its own.
The example build phase in Doc/using/ios.rst and in the utils.sh header comment is unquoted too, and names the file build_utils.sh, which the XCframework does not contain.
Running shellcheck finds a couple more errors, 1 warning, and a bunch of info findings.
Any worth fixing?
❯ shellcheck Platforms/Apple/testbed/Python.xcframework/build/utils.shIn Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 1:
# Utility methods forusein an Xcode project.^-- SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 102: MODULE_NAME=$(echo $EXT | cut -d "." -f 1) ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: MODULE_NAME=$(echo "$EXT" | cut -d "." -f 1)In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 104: RELATIVE_EXT=${FULL_EXT#$CODESIGNING_FOLDER_PATH/} ^----------------------^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.Did you mean: RELATIVE_EXT=${FULL_EXT#"$CODESIGNING_FOLDER_PATH"/}In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 108: FULL_MODULE_NAME=$(echo $PYTHON_EXT | cut -d "." -f 1 | tr "/" "."); ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: FULL_MODULE_NAME=$(echo "$PYTHON_EXT" | cut -d "." -f 1 | tr "/" ".");In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 110: FRAMEWORK_BUNDLE_ID=$(echo $PRODUCT_BUNDLE_IDENTIFIER.$FULL_MODULE_NAME | tr "_" "-") ^------------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---------------^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: FRAMEWORK_BUNDLE_ID=$(echo "$PRODUCT_BUNDLE_IDENTIFIER"."$FULL_MODULE_NAME" | tr "_" "-")In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 126: echo "$FRAMEWORK_FOLDER/$FULL_MODULE_NAME" > ${FULL_EXT%.so}.fwork ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: echo "$FRAMEWORK_FOLDER/$FULL_MODULE_NAME" > "${FULL_EXT%.so}".fworkIn Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 141: /usr/bin/codesign --force --sign "$EXPANDED_CODE_SIGN_IDENTITY" ${OTHER_CODE_SIGN_FLAGS:-} -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER" ^------------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: /usr/bin/codesign --force --sign "$EXPANDED_CODE_SIGN_IDENTITY" "${OTHER_CODE_SIGN_FLAGS:-}" -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER"In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 155: find "$CODESIGNING_FOLDER_PATH/$LIB_PATH" -name "*.so" | while read FULL_EXT; do ^--^ SC2162 (info): read without -r will mangle backslashes.In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 156: install_dylib $PYTHON_XCFRAMEWORK_PATH "$LIB_PATH/" "$FULL_EXT" ^----------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: install_dylib "$PYTHON_XCFRAMEWORK_PATH" "$LIB_PATH/" "$FULL_EXT"In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 171: install_stdlib $PYTHON_XCFRAMEWORK_PATH ^----------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: install_stdlib "$PYTHON_XCFRAMEWORK_PATH"In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 172: PYTHON_VER=$(ls -1 "$CODESIGNING_FOLDER_PATH/python/lib" | grep -E "^python3\.\d+[a-z]*$") ^-- SC2010 (warning): Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 174: process_dylibs $PYTHON_XCFRAMEWORK_PATH python/lib/$PYTHON_VER/lib-dynload ^----------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: process_dylibs "$PYTHON_XCFRAMEWORK_PATH" python/lib/"$PYTHON_VER"/lib-dynloadIn Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 176: for package_path in $@; do ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.In Platforms/Apple/testbed/Python.xcframework/build/utils.sh line 178: process_dylibs $PYTHON_XCFRAMEWORK_PATH $package_path ^----------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.Did you mean: process_dylibs "$PYTHON_XCFRAMEWORK_PATH" "$package_path"For more information: https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ... https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y... https://www.shellcheck.net/wiki/SC2010 -- Don't use ls | grep. Use a glob o...
Four are worth fixing; the rest look harmless. The unquoted $@ and $package_path on lines 176-178 split a package path with a space, leaving its extension modules unconverted. A [x] in the build path breaks the prefix match on line 104, so all modules land in one misnamed framework. An xcframework path with a space, unquoted on lines 156-178, fails the build. read without -r on line 155 drops a backslash in the build path, so mv fails. Under /bin/sh with a stub codesign, the first two still exit 0 (script). Line 141 must stay unquoted, since OTHER_CODE_SIGN_FLAGS can hold several flags. I'll open a follow-up PR. Thanks!
Agreed - many of these are misfires because they can't contain spaces (e.g., $EXT is used to capture the .so/.dylib extension) or have spaces by design (e.g., $OTHER_CODE_SIGN_FLAGS). The others are unlikely to be a problem - but it certainly can't hurt to protect against people having unusual project layouts.
Activity
gh-162034: Quote the utils.sh path in the Apple testbed build phase (#…
[3.14] gh-162034: Quote the utils.sh path in the Apple testbed build …
hugovk commentedon Nov 16, 2026
Running shellcheck finds a couple more errors, 1 warning, and a bunch of info findings.
Any worth fixing?
[3.15] gh-162034: Quote the utils.sh path in the Apple testbed build …
fametrano commentedon Nov 17, 2026
Four are worth fixing; the rest look harmless. The unquoted
$@and$package_pathon lines 176-178 split a package path with a space, leaving its extension modules unconverted. A[x]in the build path breaks the prefix match on line 104, so all modules land in one misnamed framework. An xcframework path with a space, unquoted on lines 156-178, fails the build.readwithout-ron line 155 drops a backslash in the build path, somvfails. Under /bin/sh with a stub codesign, the first two still exit 0 (script). Line 141 must stay unquoted, sinceOTHER_CODE_SIGN_FLAGScan hold several flags. I'll open a follow-up PR. Thanks!freakboy3742 commentedon Nov 17, 2026
Agreed - many of these are misfires because they can't contain spaces (e.g.,
$EXTis used to capture the.so/.dylibextension) or have spaces by design (e.g.,$OTHER_CODE_SIGN_FLAGS). The others are unlikely to be a problem - but it certainly can't hurt to protect against people having unusual project layouts.gh-162034: Quote paths in the Apple testbed's utils.sh (#162161)