diff --git a/release_notes.md b/release_notes.md index b5f1d77cd..c10a83759 100644 --- a/release_notes.md +++ b/release_notes.md @@ -15,3 +15,4 @@ prompt the user to select which target framework to use for the Dockerfile. - Enhanced dotnet installation discovery by adopting the same `Muxer` logic used by the .NET SDK itself (#4732) - Update .NET templates package version to 4.0.5337 (#4728) +- Fix `func pack --build-native-deps` failure on Windows for Python 3.13+ (#4742) diff --git a/src/Cli/func/Helpers/PythonHelpers.cs b/src/Cli/func/Helpers/PythonHelpers.cs index 7e379e471..ec5880a1e 100644 --- a/src/Cli/func/Helpers/PythonHelpers.cs +++ b/src/Cli/func/Helpers/PythonHelpers.cs @@ -564,10 +564,11 @@ private static async Task ChoosePythonBuildEnvImage() { // Setup image tag and content string imageContent = image; - image = $"azure-functions/python:4-python{workerInfo.Major}.{workerInfo.Minor}-buildenv"; + string dockerfileName = $"4-python{workerInfo.Major}{workerInfo.Minor}-buildenv"; + image = $"azure-functions/python:{dockerfileName}"; // Prepare temporary directory for docker build context - string tempDockerfileDirecotry = Path.Combine(Path.GetTempPath(), $"{image}-docker"); + string tempDockerfileDirecotry = Path.Combine(Path.GetTempPath(), $"{dockerfileName}"); FileSystemHelpers.EnsureDirectory(tempDockerfileDirecotry); string tempDockerfile = Path.Combine(tempDockerfileDirecotry, "Dockerfile"); diff --git a/test/Cli/Func.UnitTests/HelperTests/PythonHelperTests.cs b/test/Cli/Func.UnitTests/HelperTests/PythonHelperTests.cs index 0d49631de..9e603f453 100644 --- a/test/Cli/Func.UnitTests/HelperTests/PythonHelperTests.cs +++ b/test/Cli/Func.UnitTests/HelperTests/PythonHelperTests.cs @@ -91,6 +91,29 @@ public void AssertPythonVersion(string pythonVersion, bool expectException) Assert.Throws(() => PythonHelpers.AssertPythonVersion(worker)); } } + + [Theory] + [InlineData(3, 10)] + [InlineData(3, 11)] + [InlineData(3, 12)] + [InlineData(3, 13)] + [InlineData(3, 14)] + public void DockerfileNameShouldNotContainInvalidCharacters(int major, int minor) + { + // Verify the dockerfile name format matches what's used in ChoosePythonBuildEnvImage + // The format should be "4-python{major}{minor}-buildenv" with no colons or other invalid chars + string dockerfileName = $"4-python{major}{minor}-buildenv"; + + // Ensure no colons (invalid on Windows file paths) + Assert.DoesNotContain(":", dockerfileName); + + // Ensure no other invalid Windows path characters + char[] invalidChars = Path.GetInvalidFileNameChars(); + Assert.DoesNotContain(dockerfileName, c => invalidChars.Contains(c)); + + // Verify expected format + Assert.Matches(@"^4-python\d+-buildenv$", dockerfileName); + } } public sealed class SkipIfPythonNonExistFact : FactAttribute