Refactor wheel.move_wheel_files to use updated distlib by chrahunt · Pull Request #6763 · pypa/pip (original) (raw)

With the recent update to distlib, we can rid ourselves of some workarounds in wheel.py.

Now we rely on the script template in distlib here.

The script template is essentially the same as the one that was in wheel.py before, with the exception of the regular expression here. For reference, our original regular expression was (-script\.pyw?|\.exe)?$ and the new one is (-script\.pyw?|\.exe)?$. In our case since distlib itself is generating the wrapper and only generates wrappers with names as-is (for Unix) and with .exe (for Windows), the -script.pyw will never be applicable, ? not withstanding. This is further elaborated on here around the time of the original issue being raised.

In a followup PR I should be able to extract and unit test the generation of the script spec generation.

Notes:

  1. The removed comment "fix the fact that the default script swallows every single stack trace" is related to the discussion here. Essentially: The previous default template in distlib was catching exceptions and printing a simple error message
  2. The removed comment "Simplify the script" is related to the discussion here (thanks @takluyver for following up!)