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

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

Open
Holt59 opened this issue Jun 13, 2024 · 5 comments

Comments

@Holt59
Copy link

Holt59 commented Jun 13, 2024

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 pypa/setuptools#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

  • Windows 11 Pro, 23H2, 22631.3672
  • pip 24.0
@vsajip
Copy link
Collaborator

vsajip commented Jun 14, 2024

Why this should be required behaviour?

@Holt59
Copy link
Author

Holt59 commented Jun 14, 2024

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
Copy link
Collaborator

vsajip commented Jun 14, 2024

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
Copy link
Author

Holt59 commented Jun 14, 2024

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
Copy link
Collaborator

vsajip commented Jun 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants