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

Windows improvements for pdm use #3414

Open
1 task done
paugier opened this issue Mar 7, 2025 · 6 comments
Open
1 task done

Windows improvements for pdm use #3414

paugier opened this issue Mar 7, 2025 · 6 comments
Labels
⭐ enhancement Improvements for existing features

Comments

@paugier
Copy link

paugier commented Mar 7, 2025

Feature Description

We are trying to use PDM for Mercurial (https://foss.heptapod.net/mercurial/mercurial-devel/-/merge_requests/1285) and we have issues on Windows.

We use pdm use "$PYTHON" --ignore-remembered --first in a Makefile target (https://foss.heptapod.net/mercurial/mercurial-devel/-/merge_requests/1285/diffs#836efb6e25a091dcb4ff8e1dbb2f0be6a5cbf14c_73_66).

Problem and Solution

Unfortunately, it does not work well on Windows:

  • pdm use 3.9 --ignore-remembered --first uses 32-bit but we need 64-bit.
  • pdm use "py -3.9" --ignore-remembered --first does not work while it seems reasonable.

Do you think PDM could be changed to allow this usage?

  • pdm use 3.9 --ignore-remembered --first using 64-bit Python
  • pdm use "py -3.9" --ignore-remembered --first delegates to py the discovery of the interpreter.

Are you willing to contribute to the development of this feature?

  • Yes, I am willing to contribute to the development of this feature.
@paugier paugier added the ⭐ enhancement Improvements for existing features label Mar 7, 2025
@paugier
Copy link
Author

paugier commented Mar 7, 2025

Note that for py on Windows, py -3.9-32 is how you explicitly invoke the 32 bit interpreter (https://docs.python.org/3/using/windows.html).

Therefore, I tend to think that it is nearly a bug that pdm use 3.9 --first picks the 32-bit version.

@frostming
Copy link
Collaborator

frostming commented Mar 10, 2025

It should be fixed in the new release of findpython(PDM's dependency), upgrade it and try again.

@paugier
Copy link
Author

paugier commented Mar 11, 2025

pdm use 3.9 --ignore-remembered --first now picks 64-bit Python, which is great.

I don't know if pdm use "py -3.9" --ignore-remembered --first is actually useful. I don't use Windows nor py and I don't know which Python is acutally picked by pdm use (Python installed from python.org if it exists or a python-build-standalone installed by PDM).

@paugier
Copy link
Author

paugier commented Mar 12, 2025

Finally, it appears that it would be useful for Mercurial to be able to run pdm use "py -3.9" which would delegate to py the finding of the Python interpreter. In practice, we need to still support make local PYTHON="py -3.9" so we could hack the Mercurial Makefile even if PDM does not support pdm use "py -3.9", but it would be even nicer if PDM could support that.

Do you think it could be possible?

In terms of implementation, it does not seem very complicated for PDM with somewhere if ???.startswith("py "): and then ask sys.executable to py -3.9. If you tell me where this should go, I could even propose a PR (but I guess this is not the blocking part for something so simple).

@frostming
Copy link
Collaborator

py -3.9

I don't see what the point of this is. py looks for the registry table to find interpreters, so does findpython. Is there any case py would find but findpython wouldn't?

@paugier
Copy link
Author

paugier commented Mar 12, 2025

If there is no point of supporting this from the point of view of PDM, we will have to support it from our code, which makes sense. I was just asking.

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

No branches or pull requests

2 participants