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
I have searched the issue tracker and believe that this is not a duplicate.
Steps to reproduce
# setup
mkdir pdm-ruff-repro
cd pdm-ruff-repro
cat >pyproject.toml <<EOF[project]name = ""version = ""description = ""authors = [ {name = "Hi PDM", email = "hi@pdm.com"},]dependencies = [ "ruff>=0.0.274",]requires-python = ">=3.7"license = {text = "MIT"}EOF
touch test.py
pdm config --local python.use_venv false
pdm install
# assert that it initially works:
pdm run ruff check test.py # OK
cp __pypackages__/3.7/bin/ruff ruff37 # backup executable# now switch Python version and back:
pdm use -f python3.8
pdm use -f python3.7
# assert executable was changed
diff __pypackages__/3.7/bin/ruff ruff37
# Binary files __pypackages__/3.7/bin/ruff and ruff37 differ# assert ruff does not work anymore
pdm run ruff check test.py # no output, failure
__pypackages__/3.7/bin/ruff check test.py
# [1] 178079 segmentation fault (core dumped) __pypackages__/3.7/bin/ruff check test.py
Actual behavior
PDM corrupts binary executable scripts, probably when trying to replace the shebang.
Expected behavior
Would it make sense to only try replacing the shebang on non-binary files?
Maybe by trying to open the file as text (utf8) and if it fails, do nothing? Otherwise continue with the regex replace?
Environment Information
# Paste the output of `pdm info && pdm info --env` below:
PDM version:
2.7.4
Python Interpreter:
/home/pawamoy/.basher-packages/pyenv/pyenv/versions/3.7.15/bin/python3.7 (3.7)
Project Root:
/home/pawamoy/pdm-ruff-repro
Local Packages:
/home/pawamoy/pdm-ruff-repro/__pypackages__/3.7
{
"implementation_name": "cpython",
"implementation_version": "3.7.15",
"os_name": "posix",
"platform_machine": "x86_64",
"platform_release": "6.3.8-arch1-1",
"platform_system": "Linux",
"platform_version": "#1 SMP PREEMPT_DYNAMIC Wed, 14 Jun 2023 20:10:31 +0000",
"python_full_version": "3.7.15",
"platform_python_implementation": "CPython",
"python_version": "3.7",
"sys_platform": "linux"
}
The text was updated successfully, but these errors were encountered:
Thank you for reviewing my PR, finding a better solution and implementing it! Greatly appreciated 🚀
I've installed and tested PDM's main branch, and it works perfectly 🎉
Steps to reproduce
Actual behavior
PDM corrupts binary executable scripts, probably when trying to replace the shebang.
Expected behavior
Would it make sense to only try replacing the shebang on non-binary files?
Maybe by trying to open the file as text (utf8) and if it fails, do nothing? Otherwise continue with the regex replace?
Environment Information
The text was updated successfully, but these errors were encountered: