From 43c6cac59db85a3dc5badf57cdd7b0c848fbb837 Mon Sep 17 00:00:00 2001 From: Jake Runzer Date: Wed, 7 Sep 2022 02:42:56 -0400 Subject: [PATCH] Set `PYTHONUNBUFFERED=1` for the Python provider (#510) * Set `PYTHONUNBUFFERED=1` for the Python provider * update snapshot tests --- src/providers/python.rs | 5 +++++ tests/snapshots/generate_plan_tests__python.snap | 3 ++- tests/snapshots/generate_plan_tests__python_2.snap | 3 ++- tests/snapshots/generate_plan_tests__python_2_runtime.snap | 3 ++- tests/snapshots/generate_plan_tests__python_django.snap | 3 ++- .../snapshots/generate_plan_tests__python_django_mysql.snap | 3 ++- tests/snapshots/generate_plan_tests__python_numpy.snap | 3 ++- tests/snapshots/generate_plan_tests__python_poetry.snap | 3 ++- tests/snapshots/generate_plan_tests__python_procfile.snap | 3 ++- tests/snapshots/generate_plan_tests__python_setuptools.snap | 3 ++- 10 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/providers/python.rs b/src/providers/python.rs index 7cd87ee43..12ae528ea 100644 --- a/src/providers/python.rs +++ b/src/providers/python.rs @@ -61,6 +61,11 @@ impl Provider for PythonProvider { plan.set_start_phase(start); } + plan.add_variables(EnvironmentVariables::from([( + "PYTHONUNBUFFERED".to_owned(), + "1".to_owned(), + )])); + if app.includes_file("poetry.lock") { plan.add_variables(EnvironmentVariables::from([( "NIXPACKS_POETRY_VERSION".to_string(), diff --git a/tests/snapshots/generate_plan_tests__python.snap b/tests/snapshots/generate_plan_tests__python.snap index cc553dd5d..c8109088f 100644 --- a/tests/snapshots/generate_plan_tests__python.snap +++ b/tests/snapshots/generate_plan_tests__python.snap @@ -6,7 +6,8 @@ expression: plan "nixpacksVersion": "[version]", "buildImage": "[build_image]", "variables": { - "NIXPACKS_METADATA": "python" + "NIXPACKS_METADATA": "python", + "PYTHONUNBUFFERED": "1" }, "phases": [ { diff --git a/tests/snapshots/generate_plan_tests__python_2.snap b/tests/snapshots/generate_plan_tests__python_2.snap index 87ca7c962..3d47001c8 100644 --- a/tests/snapshots/generate_plan_tests__python_2.snap +++ b/tests/snapshots/generate_plan_tests__python_2.snap @@ -6,7 +6,8 @@ expression: plan "nixpacksVersion": "[version]", "buildImage": "[build_image]", "variables": { - "NIXPACKS_METADATA": "python" + "NIXPACKS_METADATA": "python", + "PYTHONUNBUFFERED": "1" }, "phases": [ { diff --git a/tests/snapshots/generate_plan_tests__python_2_runtime.snap b/tests/snapshots/generate_plan_tests__python_2_runtime.snap index 87ca7c962..3d47001c8 100644 --- a/tests/snapshots/generate_plan_tests__python_2_runtime.snap +++ b/tests/snapshots/generate_plan_tests__python_2_runtime.snap @@ -6,7 +6,8 @@ expression: plan "nixpacksVersion": "[version]", "buildImage": "[build_image]", "variables": { - "NIXPACKS_METADATA": "python" + "NIXPACKS_METADATA": "python", + "PYTHONUNBUFFERED": "1" }, "phases": [ { diff --git a/tests/snapshots/generate_plan_tests__python_django.snap b/tests/snapshots/generate_plan_tests__python_django.snap index aeb2a4256..282114b5f 100644 --- a/tests/snapshots/generate_plan_tests__python_django.snap +++ b/tests/snapshots/generate_plan_tests__python_django.snap @@ -6,7 +6,8 @@ expression: plan "nixpacksVersion": "[version]", "buildImage": "[build_image]", "variables": { - "NIXPACKS_METADATA": "python,django,postgres" + "NIXPACKS_METADATA": "python,django,postgres", + "PYTHONUNBUFFERED": "1" }, "phases": [ { diff --git a/tests/snapshots/generate_plan_tests__python_django_mysql.snap b/tests/snapshots/generate_plan_tests__python_django_mysql.snap index e380b742c..8ef6fa5dc 100644 --- a/tests/snapshots/generate_plan_tests__python_django_mysql.snap +++ b/tests/snapshots/generate_plan_tests__python_django_mysql.snap @@ -6,7 +6,8 @@ expression: plan "nixpacksVersion": "[version]", "buildImage": "[build_image]", "variables": { - "NIXPACKS_METADATA": "python,django" + "NIXPACKS_METADATA": "python,django", + "PYTHONUNBUFFERED": "1" }, "phases": [ { diff --git a/tests/snapshots/generate_plan_tests__python_numpy.snap b/tests/snapshots/generate_plan_tests__python_numpy.snap index cc553dd5d..c8109088f 100644 --- a/tests/snapshots/generate_plan_tests__python_numpy.snap +++ b/tests/snapshots/generate_plan_tests__python_numpy.snap @@ -6,7 +6,8 @@ expression: plan "nixpacksVersion": "[version]", "buildImage": "[build_image]", "variables": { - "NIXPACKS_METADATA": "python" + "NIXPACKS_METADATA": "python", + "PYTHONUNBUFFERED": "1" }, "phases": [ { diff --git a/tests/snapshots/generate_plan_tests__python_poetry.snap b/tests/snapshots/generate_plan_tests__python_poetry.snap index 0d1379e43..3318e3caa 100644 --- a/tests/snapshots/generate_plan_tests__python_poetry.snap +++ b/tests/snapshots/generate_plan_tests__python_poetry.snap @@ -7,7 +7,8 @@ expression: plan "buildImage": "[build_image]", "variables": { "NIXPACKS_METADATA": "python,poetry", - "NIXPACKS_POETRY_VERSION": "1.1.13" + "NIXPACKS_POETRY_VERSION": "1.1.13", + "PYTHONUNBUFFERED": "1" }, "phases": [ { diff --git a/tests/snapshots/generate_plan_tests__python_procfile.snap b/tests/snapshots/generate_plan_tests__python_procfile.snap index f7641b123..f46415791 100644 --- a/tests/snapshots/generate_plan_tests__python_procfile.snap +++ b/tests/snapshots/generate_plan_tests__python_procfile.snap @@ -6,7 +6,8 @@ expression: plan "nixpacksVersion": "[version]", "buildImage": "[build_image]", "variables": { - "NIXPACKS_METADATA": "python" + "NIXPACKS_METADATA": "python", + "PYTHONUNBUFFERED": "1" }, "phases": [ { diff --git a/tests/snapshots/generate_plan_tests__python_setuptools.snap b/tests/snapshots/generate_plan_tests__python_setuptools.snap index 1fe1b7f92..23a0fa4b4 100644 --- a/tests/snapshots/generate_plan_tests__python_setuptools.snap +++ b/tests/snapshots/generate_plan_tests__python_setuptools.snap @@ -6,7 +6,8 @@ expression: plan "nixpacksVersion": "[version]", "buildImage": "[build_image]", "variables": { - "NIXPACKS_METADATA": "python" + "NIXPACKS_METADATA": "python", + "PYTHONUNBUFFERED": "1" }, "phases": [ {