diff --git a/relenv/common.py b/relenv/common.py index c91a509c..b044d76b 100644 --- a/relenv/common.py +++ b/relenv/common.py @@ -105,7 +105,7 @@ def format_shebang(python, tpl=SHEBANG_TPL): """ Return a formatted shebang. """ - return tpl.format(python).strip() + return tpl.format(python).strip() + "\n" def build_arch(): diff --git a/tests/test_common.py b/tests/test_common.py index df5d93b0..60be74e7 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -179,6 +179,10 @@ def test_shebang_tpl_macos(): assert proc.returncode == 0 +def test_format_shebang_newline(): + assert format_shebang("python3", SHEBANG_TPL_LINUX).endswith("\n") + + def test_relative_interpreter_default_location(): assert relative_interpreter( "/tmp/relenv", "/tmp/relenv/bin", "/tmp/relenv/bin/python3" diff --git a/tests/test_verify_build.py b/tests/test_verify_build.py index ad3681b8..4995c56c 100644 --- a/tests/test_verify_build.py +++ b/tests/test_verify_build.py @@ -1224,6 +1224,40 @@ def test_install_with_target_shebang(pipexec, build, minor_version): ) +@pytest.mark.skip_unless_on_linux +def test_install_shebang_pip_24_2(pipexec, build, minor_version): + subprocess.run( + [str(pipexec), "install", "--upgrade", "pip==24.2"], + check=True, + ) + subprocess.run( + [str(pipexec), "install", "cowsay"], + check=True, + ) + ret = subprocess.run( + [str(build / "bin" / "cowsay"), "-t", "moo"], + check=False, + ) + assert ret.returncode == 0 + + +@pytest.mark.skip_unless_on_linux +def test_install_shebang_pip_25_2(pipexec, build, minor_version): + subprocess.run( + [str(pipexec), "install", "--upgrade", "pip==25.2"], + check=True, + ) + subprocess.run( + [str(pipexec), "install", "cowsay"], + check=True, + ) + ret = subprocess.run( + [str(build / "bin" / "cowsay"), "-t", "moo"], + check=False, + ) + assert ret.returncode == 0 + + @pytest.mark.skip_unless_on_linux def test_install_with_target_uninstall(pipexec, build): env = os.environ.copy()