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

Command pdm py path printing the path towards a Python #3389

Open
1 task done
paugier opened this issue Feb 7, 2025 · 4 comments
Open
1 task done

Command pdm py path printing the path towards a Python #3389

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

Comments

@paugier
Copy link

paugier commented Feb 7, 2025

Feature Description

Some tools can accept as argument the path towards a Python interpreter. For example with Nox, one can write:

pdm py install 3.12
pdm py list
nox -s build -P ~/.local/share/pdm/python/[email protected]/bin/python

Problem and Solution

It seems to me it would be useful (and very simple) to be able to print the path towards a Python executable with pdm py path 3.12, so that I could write:

nox -s build -P $(pdm py path 3.12)

Additional Context

No response

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 Feb 7, 2025
@klmcwhirter
Copy link

Since both nox and tox have the capability to create venv's to enable testing against multiple versions of Python, wouldn't it be better to use plugins like tox-pdm and nox-pdm instead ?

In addition to those, there is a GitHub Action available pdm-project/setup-pdm@v4.

Although I do like the idea of getting more info about installed version(s) from pdm py list, is that what you really need?

@frostming
Copy link
Collaborator

The problem is pdm py path 3.12 is ambiguous on what python it refers to. There may be more than one python version that matches "3.12"

@klmcwhirter
Copy link

klmcwhirter commented Feb 13, 2025

The command line might need to be pdm py path [email protected] for example to make it match the output of pdm py list. The idea is still good.

I get frustrated having to hard code paths like that myself. For example, on my host the path is like /var/home/klmcw/.local/share/pdm/... but in a distrobox it is /home/klmcw/.local/share/pdm. I would rather not have to write the script that would use it twice. Or have to manage two env vars.

But as I mentioned some of the existing packages might serve his purposes better.

Let's see where @paugier lands.

@paugier
Copy link
Author

paugier commented Mar 7, 2025

Personally, I would use it also for other things than Nox and Tox, for example, simple benchmarks and Mercurial testing, so for me pdm py path [email protected] would be useful.

Also, for me, the nicest behavior for pdm py path 3.12 would be to choose a reasonable interpreter from the data "3.12" (something like the latest CPython I guess), but it's a detail.

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

3 participants