pypa / distlib

A low-level library which implements some Python packaging standards (PEPs) and which could be used by third-party packaging tools to achieve interoperability.
http://distlib.readthedocs.io/
Other
49 stars 38 forks source link

Script wrappers generated from Python debug executable do not point to the right executable #218

Open Holt59 opened 3 months ago

Holt59 commented 3 months ago

Describe the bug

When installing a package containing script wrappers from setuptools using a debug installation of Python on Windows, the script wrappers do not point to the right python_d.exe.

This is a follow-up from https://github.com/pypa/setuptools/issues/4418

To Reproduce

  1. Build Python in debug mode on Windows.
  2. Install a package containing scripts via python_d.exe -m pip install XXX. Below is non-working package:
# setup.py
from setuptools import setup

setup(
    name="package",
    version="0.0.1",
    entry_points={"console_scripts": ["test_python_debug_main = package.main:main"]},
)
# pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
  1. Try to run the generated test_python_debug_main.exe.
  2. The exe will throw the following error (paths removed):
Fatal error in launcher: Unable to create process using '"python.exe"  "Scripts\test_python_debug_main.exe" ': The system cannot find the file specified.

Expected behavior

The script wrappers should use the right executable, i.e., python_d.exe.

Environment

vsajip commented 3 months ago

Why this should be required behaviour?

Holt59 commented 3 months ago

Why this should be required behaviour?

Because otherwise the script wrappers do not work? What would be the alternative?

Currently it is simply impossible to install script wrappers via pip using a Python debug build, which I do not think is ideal.

This would also make the behavior consistent with setuptools since python setup.py install does generate wrappers using python_d.exe.

vsajip commented 3 months ago

Because otherwise the script wrappers do not work

Well I understand that, but why is there a need to support scripts to be run under debug builds of Python? Obviously you can't ship such scripts. Can you give a more detailed explanation of the actual use case?

Holt59 commented 3 months ago

Because otherwise the script wrappers do not work

Well I understand that, but why is there a need to support scripts to be run under debug builds of Python? Obviously you can't ship such scripts. Can you give a more detailed explanation of the actual use case?

You cannot ship such scripts, but I do not see a reason not to be able to run such scripts. AFAIK, you cannot ship the scripts installed (through pip install) with a standard Python installation since it tries to use the absolute path from the executable (at least that was I guess from the error).

Aside from the required work to implement such feature, what would justify not having the scripts use python_d.exe instead of python.exe?

My actual use-case is to build PyQt using sip and related tools. Building those in debug mode requires a Python debug installation, and it makes use of scripts generated by the sip package (sip-install, sip-module, ...). These scripts work fine if installed through the old deprecated setuptools method (python setup.py install) but not through pip, hence the issue.

vsajip commented 3 months ago

I consider this a niche use case, but I'm willing to review a PR around this which meets your requirement while using a simple approach.