I’m working on improving Mercurial packaging and use modern Python packaging methods.
Currently, we have an issue on Windows with pipx and UV because Mercurial uses a script (hg · branch/default · mercurial / mercurial-devel · GitLab) and no [project.scripts]
and that scripts are not well supported.
Moreover, there is in Mercurial setup.py some code to build a .exe wrapper from a file exewrapper.c. IIUC, the .exe wrapper should not be build when the wheel is created (by the pep 517 backend) but at install time (by the frontend). Is it correct? If it is correct, we should not have special exewrapper.c and let pip, pipx or uv do that for us.
However, there are two things which seem to be important for Mercurial and that I don’t know how to do with a console_scripts entry point:
-
PYTHONLEGACYWINDOWSSTDIO=1
has to be activated (mercurial/exewrapper.c · branch/default · mercurial / mercurial-devel · GitLab). I don’t know if we could do that from Python in the function entrypoint. -
hg.exe
contains a Windows manifest (setup.py · branch/default · mercurial / mercurial-devel · GitLab) and I don’t see how to have that with a console-script entry point.
However, I have to admit that I don’t know anything about Windows manifest. The first point (PYTHONLEGACYWINDOWSSTDIO
) seems more critical.