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

pdm show --version no longer prints actual version number when version is dynamic #1753

Closed
1 task done
MasterNayru opened this issue Mar 6, 2023 · 4 comments
Closed
1 task done
Labels
🐛 bug Something isn't working

Comments

@MasterNayru
Copy link

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

Use a dynamic field and attempt to retrieve its computed value using pdm show. For example, have the following set in pyproject.toml:

[project]
dynamic = ["version"]

...

[tool.pdm.version]
source = "file"
path = "src/__version__.py"

Then run pdm show --version. I have been using this command to pull out the version stored in version.py in a CI setup, so breaking this behaviour is currently causing me to be unable to obtain the version number from the project, which I was able to do using that command up until v2.4.7 was released.

Actual behavior

Prints DYNAMIC

Expected behavior

The command looks to have been intentionally changed to show this string in v2.4.7 but showed what it used to show in v2.4.6.
I mean, with all due respect, what it's showing in v2.4.7 may well be the expected behaviour from a big picture standpoint but what I really expect is that this behaviour would not change in a patch release. I can't see any reference to this project following SemVer strictly in the README but it's just leaving a really bad taste in my mouth.

Ideally, the behaviour would be reverted, at least within this minor release but I do understand the motivation to have the command print out what the actual defined metadata of the project is. If this were the existing behaviour, I would probably expect to have a flag that could produce the dynamic values for the project. Given that the block that defines where to pull the version number from is a pdm tool block, I would expect pdm to at least have a command that could make use of this config block to pull the version number out.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.4.7
Python Interpreter:
  /home/username/work/project-dir/.venv/bin/python (3.10)
Project Root:
  /home/username/work/project-dir
Project Packages:
  None
{
  "implementation_name": "cpython",
  "implementation_version": "3.10.10",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.1.11-200.fc37.x86_64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Thu Feb  9 19:20:24 UTC 2023",
  "python_full_version": "3.10.10",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "linux"
}
@MasterNayru MasterNayru added the 🐛 bug Something isn't working label Mar 6, 2023
@frostming
Copy link
Collaborator

frostming commented Mar 7, 2023

It was changed to read the [project] table only because PDM is a backend-agnostic manager that doesn't know anything about the backend(any dynamic field needs to be determined by the backend), even if it is pdm-pep517. All it can do is run the build backend to generate the metadata for the project, which I thought is a bit heavy for a show command. However, I agree this behavior change is not suitable for a patch release.

@MasterNayru
Copy link
Author

Would it be possible to have a flag on the show command to allow the user to choose to see the dynamic values that would be computed? I kinda understand the desire to keep the responsibilities of each piece of the system clear . It's just super useful to be able to see what version number PDM would use for a build without actually having to run a full build of a wheel to see what value comes out. Obviously I could have behaviour in a plugin, but it just seems like the sort of thing that would be really useful to have by default, at least as an option.

@frostming
Copy link
Collaborator

@MasterNayru A possible solution is to get the metadata from the installed copy in the current environment, which also doesn't need a build. However, the metadata may be outdated until you run pdm install to reinstall.

@MasterNayru
Copy link
Author

Looks like I am able to get the information I want by just specifying the name of the package that I am building in the show command like: pdm show --version <package name>. That's calling the from_distribution function which was giving me the desired behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants