pdm-project / pdm-backend

The build backend used by PDM that supports latest packaging standards.
https://backend.pdm-project.org
MIT License
69 stars 33 forks source link

How to specify explicit version for pdm-backend #260

Closed gunmaden closed 1 hour ago

gunmaden commented 2 hours ago

Hi, Is there any possibility to specify version explicitly for pdm-backend in pyproject.toml?

Changes such as retrieving license files from 2.3.3 -> 2.4.0 could be breaking so I want to update backend version by myself manually

[build-system]
requires = ["pdm-backend = 2.3.3"]
build-backend = "pdm.backend"

This option causing error

  ╰─> This package has an invalid `build-system.requires` key in pyproject.toml.
      It contains an invalid requirement: 'pdm-backend = 2.3.3'

Another variations such as ["pdm-backend <= 2.3.3"] or ["pdm-backend == 2.3.3"] leads to downloaded pdm-backend v2.4.0

frostming commented 2 hours ago
[build-system]
requires = ["pdm-backend<2.4"]
build-backend = "pdm.backend"

Another variations such as ["pdm-backend <= 2.3.3"] or ["pdm-backend == 2.3.3"] leads to downloaded pdm-backend v2.4.0

It's false, and they should work, unless you are doing things wrong

gunmaden commented 1 hour ago

No matter which option I use I'm getting the same error

[build-system]
requires = ["pdm-backend<2.4"]
build-backend = "pdm.backend"
[build-system]
requires = ["pdm-backend<=2.3.3"]
build-backend = "pdm.backend"
pdm.backend._vendor.pyproject_metadata.ConfigurationError: Field "project.license-files" has an invalid type, expecting a list of strings (got "{'paths': ['LICENSE.txt']}")
frostming commented 1 hour ago

How do you build the project? an example project and steps to run would be helpful.

BTW, you should update the license-files field to follow PEP 639 since the old spec has been obsoleted.

gunmaden commented 1 hour ago

I'm trying to restore packages

Steps as follows:

  1. Create new venv
  2. Run .venv/bin/python -m pip install .

pyproject.toml

[project]
name = "sample-name"
description = "some description"
dynamic = ["version"]
readme = "README.md"
requires-python = ">=3.12"
license-files = { paths = ["LICENSE.txt"] }
dependencies = [
    "build==1.0.3",
    "pdm==2.18.2",
    "pytest==7.4.3"
]

[tool.pdm.version]
source = "call"
getter = "get_version:run"

[tool.pdm.scripts]
test = "pytest"

[[tool.pdm.source]]
url = "https://some-internal-proget-feed"
verify_ssl = true
name = "external"

[[tool.pdm.source]]
url = "https://other-internal-proget-feed"
verify_ssl = true
name = "internal"

[build-system]
requires = ["pdm-backend<=2.3.3"]
build-backend = "pdm.backend"

BTW, you should update the license-files field to follow PEP 639 since the old spec has been obsoleted.

Thanks. Planned soon

frostming commented 1 hour ago

Can't reproduce, pip install runs successfully with the version bound and fails if I remove the limit. The version specifier is obviously working. Can you show the verbose output for why the wrong version of pdm-backend is pulled?

Is it related to the dependencies? I test without any dependencies

frostming commented 1 hour ago

Anyway, it is not related to pdm-backend project. Closing it now.

gunmaden commented 1 hour ago

Is it related to the dependencies? I test without any dependencies

seems like it occurs if dependencies does not have correct build-system block

removed our package dependency and it's works

Thanks a lot!