Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScriptMaker without enquoting executable path makes wrong scripts #387

Closed
1 task done
linw1995 opened this issue Apr 13, 2021 · 0 comments · Fixed by #388
Closed
1 task done

ScriptMaker without enquoting executable path makes wrong scripts #387

linw1995 opened this issue Apr 13, 2021 · 0 comments · Fixed by #388
Labels
🐛 bug Something isn't working

Comments

@linw1995
Copy link
Member

  • I have searched the issue tracker and believe that this is not a duplicate.

I discover this problem by using PDM with pdm-venv on MacOS. The default virtualenvs directory on MacOS is ~/Library/Application Support/pdm/venvs. And this reveals the bug under the installer code of PDM.

def install_wheel(self, wheel: Wheel) -> None:
paths = self.environment.get_paths()
maker = distlib.scripts.ScriptMaker(None, None)
maker.variants = set(("",))
maker.executable = self.environment.interpreter.executable
wheel.install(paths, maker)

The ScriptMaker._get_shebang assumes the executable path is taken care of by the caller. So the path is not enquoted.

https://github.com/vsajip/distlib/blob/4f54a3117db58f6bb00c69ab9a892170b91acd3b/distlib/scripts.py#L160-L162

I will create a pull request for resolving this issue via passing the enquoted executable path to ScriptMaker.

Steps to reproduce

  1. install pdm and pdm-venv
  2. configure the path with whitespace as venvs dir
  3. use pdm to install a package with scripts. like pytest
  4. run it

Actual behavior

fail to run due to the corrupted script generated by the un-enquoted exetuable path.

Expected behavior

run success

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:        1.5.0b1
Python Interpreter: /Users/linw1995/Library/Application Support/pdm/venvs/pdm-Tbf7Oqsf-3.9/bin/python (3.9)
Project Root:       /private/tmp/pdm
Project Packages:   None
{
  "implementation_name": "cpython",
  "implementation_version": "3.9.2",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "20.3.0",
  "platform_system": "Darwin",
  "platform_version": "Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64",
  "python_full_version": "3.9.2",
  "platform_python_implementation": "CPython",
  "python_version": "3.9",
  "sys_platform": "darwin"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant