Repository: pdm-project/pdm

Issue:
requires-python of installed library causes `pdm add` or `pdm sync` to fail
- [V] 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
`pdm add pylint==2.5.3`
<!--Describe the minimized example of how to reproduce the bug-->

## Actual behavior
```Adding packages to default dependencies: pylint==2.5.3
🔒 Lock failed.
ERROR: Unable to find a resolution for pylint
Please make sure the package name is correct.
See /Users/liran/Library/Logs/pdm/pdm-lock-wiaa1mk7.log for detailed debug log.
[ResolutionImpossible]: Unable to find a resolution
WARNING: Add '-v' to see the detailed traceback
```
<!--A clear and concise description the result of the above steps-->

## Expected behavior
Install and sync the required package
to my understanding, the `requires-python` that is presented in `pylint==2.5.3` Is deprecated but should still work, so I expected a warning but not an error

<!--A clear and concise description of what you expected to happen.-->

## Environment Information
`pdm add` full error:
```cat /Users/liran/Library/Logs/pdm/pdm-lock-wiaa1mk7.log                                                   
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   pylint==2.5.3
pdm.termui:   Adding requirement pylint==2.5.3
unearth.collector: Collecting links from https://pypi.org/simple/pylint/
unearth.evaluator: Skipping link <Link https://pypi.org/simple/pylint/ (from None)>: Not a file: 
unearth.auth: Found index url https://pypi.org/simple/
unearth.collector: Fetching HTML page https://pypi.org/simple/pylint/
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/36/3b/fa4025a424adafd85c6195001b1c130ecb8d8b30784a1c4cb68e7b5e5ae7/pylint-1.9.5-py2.py3-none-any.whl (from https://pypi.org/simple/pylint/)>: The package requires-python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <3.7 is not compatible with the target ==3.9.*.
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/3f/0b/4e7eeab1abf594b447385a340593c1a4244cdf8e54a78edcae1e2756d6fb/pylint-1.9.5.tar.gz (from https://pypi.org/simple/pylint/)>: The package requires-python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <3.7 is not compatible with the target ==3.9.*.
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/a9/c8/773f3fb10f436a1ac5bf55b1705280edc0185fe0d5d419b4c6ad09e54f48/pylint-2.0.0.dev0-py2.py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/ac/80/9b257ea15042d950ba4a30c54eb1a5dd1357e7d4173c29f89ae71fa65db0/pylint-2.0.0.dev0.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/dd/a2/b1b3346596a267941fd001c7f662b14549a85aed2110455ad5e3c62f593d/pylint-2.0.0.dev1-py2.py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/13/18/f85ea5012ad8c8581ea3cbc9d4ede59f7826fad8499637a7b69ba80b3e73/pylint-2.0.0.dev1.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/66/25/c639b07b1e46670ab634cab5f9c6d676cdf812095da42dee279d1299f375/pylint-2.0.0.dev2-py2.py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/ee/88/6eac32812f9c0539f98d7882554fc255e29de41e8928ddbb3f5daaf07849/pylint-2.0.0.dev2.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/87/ef/7d20e99471e4779583812be3d768818c0fca89ffad6f19ffbc1f167ebe07/pylint-2.0.0-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/9b/22/becc5a976c2b25c01f5d054b970a1da5803e61aa342d3729b6cc8d762f71/pylint-2.0.0.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/e0/a5/98a6b753c9f8d6f6da53a1ae9814c9b1be3f37a2a32327f4fc81e687eb30/pylint-2.0.1-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/54/4c/21f25feb52914bafc863b1c3eeaec9ea049dfe03d3f0613cf6886b05ddb4/pylint-2.0.1.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/b2/b5/8861166c94bebc808093c5387c119155ec5209da97abbc066ae109f12be4/pylint-2.1.0-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/38/2a/c55cbca6d1f9b34d6bad25e68d7093493fd34fa2945a8a09322897fee530/pylint-2.1.0.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/6e/c2/1e97c238877b6a86562d32297eb33a6670b6220e8ec0ca85f67b66dc893f/pylint-2.1.1-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/04/1f/1d3929051b45c3e4015178c5fe5bbee735fb4e362e0fc4f0fbf3f68647ad/pylint-2.1.1.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/75/09/3afe8323b2223d2ae1d2c76ee80c570ba5055659f362bc9966d91a505623/pylint-2.2.0-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/a9/2d/be897f09bba66595c91824950e38ea3288b2db6fb1e847851177a650c681/pylint-2.2.0.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/8a/26/7bd08cba2226c088f427370b3cfcbce288be4944bea3b33a706f0c038542/pylint-2.2.1-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/8e/b8/2fb3a0aee86252f736d394eeba758138283887cd1eb9fccdaf167ad78a4e/pylint-2.2.1.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/a5/06/ecef826f319055e6b231716730d7f9047dd7524ffda224b521d989f085b6/pylint-2.2.2-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/92/8e/e86eb8dbc10ee845b1c04ed9eaeafb981331f6db5dc05ba21555fcbe7595/pylint-2.2.2.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/67/61/8a9ddc5b03bd55a383b1080a7b47b58c2ca9a88ccb08c0039dbfd644e875/pylint-2.2.3-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/9d/6c/8344d3c7a50bdfef1c60866100ef67bcbd99c73b0539436847b66dec7700/pylint-2.2.3.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/1d/f5/255cd0d555812a335b45489be1aaca347fc7fa441ff22bf616c86c24bdfd/pylint-2.3.0.dev0-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/46/e8/39a16020dd0cdcfae4f5b219edc4d30b070123ceb38919cd57b679e30c54/pylint-2.3.0.dev0.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/4c/b4/d25b7b9a47433062234933bcd68cca6f92612bb334438a39f9ed80e76fad/pylint-2.3.0.dev1-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/51/12/005432f0c70abd4a7c11d4efc4ade2a541a4fd28562f455603f91735ec98/pylint-2.3.0.dev1.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/85/32/81d43e29db5e0eb5aecc7d5752fffd6d4277826c9b55084c45b0e799fcd5/pylint-2.3.0.dev2-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/1e/fa/fb3bb9658a6ad65e7818ff8b37213b289dd06659300b88eef5baa9c438c5/pylint-2.3.0.dev2.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/53/cc/c85a8ed4d2f5e69dff4d9c2a1d69cc3f069e1321a2e2dc67f57e02fa2179/pylint-2.3.0-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/76/05/9cec99650c4da518e4214db5fd57e5a052e7019bc460d7af149d4da54bfc/pylint-2.3.0.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/60/c2/b3f73f4ac008bef6e75bca4992f3963b3f85942e0277237721ef1c151f0d/pylint-2.3.1-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/01/8b/538911c0ebc2529f15004f4cb07e3ca562bb9aacea5df89cc25b62e01891/pylint-2.3.1.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.4.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/a8/ec/ba5583663a7149a3e3da1aa0cf2e392bd5c6a8990470d484691928581601/pylint-2.4.0-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/a5/ce/f498277d85be9e499ded68b1f198ee98222cdb0482d94de68e314306dc08/pylint-2.4.0.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/ff/6f/faf9c586af455175b72186b9831cbf63e2222b17dde74d5eebff829e8ea5/pylint-2.4.1-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/0c/e3/35abd516131c3dbf129cc9589e25877d1c73a835c659346a33a69b76818e/pylint-2.4.1.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/ef/ed/1cb8e7b85a31807aa0bff8b3e60935370bed7e141df8b530aac6352bddff/pylint-2.4.2-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/ca/dc/6b85a88376ec32fc72e598e6ff20cd6d7741e4cb9a3dda173739e5459d7d/pylint-2.4.2.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/ea/f1/758de486e46ea2b8717992704b0fdd968b7cbc2bc790b976fae4a35a212c/pylint-2.4.3-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/be/d8/334c1a5228bd300638147e62dce9c6966656fbee812b97cd0472b3eac09d/pylint-2.4.3.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/e9/59/43fc36c5ee316bb9aeb7cf5329cdbdca89e5749c34d5602753827c0aa2dc/pylint-2.4.4-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/93/eb/851ab1d1ca6b37babd326dfa517b432963c54eda26c730353306aa0cdf4d/pylint-2.4.4.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/64/9a/1c975d26b6148eb8dba4e50127382e37f9dfc2b18dafeb07e230901cbd38/pylint-2.5.0-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/ff/ea/f4dada656f59cb60a223a5f4e83718f41ec82770f7f96b4b54140a4e5df9/pylint-2.5.0.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/ba/88/44e9f88034da83648d3349fc7e33816e836a425560789e7cd6be76562731/pylint-2.5.1-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/2b/df/fc675ee91de47416ca3e57404c2a7f8ae0ca411d0565ffb0238f63b2e0b6/pylint-2.5.1.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/37/6e/36419ec1bd2208e157dff7fc3e565b185394c0dc4901e9e2f983cb1d4b7f/pylint-2.5.2-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/b4/2d/c209a539c32e2d9c7396e69bab95ad4332b73cdc360bbc89495d7e49d332/pylint-2.5.2.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/e8/fb/734960c55474c8f74e6ad4c8588fc44073fb9d69e223269d26a3c2435d16/pylint-2.5.3-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/3b/f0/ee19aeccaea881c38d129f015b2be7658724fcefa3a506d7c44747d764d9/pylint-2.5.3.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/fb/13/519c1264a134beab2be4bac8dd3e64948980a5ca7833b31cf0255b21f20a/pylint-2.6.0-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/24/4a/a07484119d23283de4d8db8176e85be3b20583eefc1cbfa8363b1414fbe2/pylint-2.6.0.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/8c/dd/f50b7a0f6dd3028e951f285c0b841cad72d47a157695b00fbcf95fe30fac/pylint-2.6.1-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/31/34/7359a85cdfba6d428801f9602685008892a0ccdec8c893492511933a18d9/pylint-2.6.1.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/63/64/f1ef360a24eccdd538454b86d6c55096929f008dd146404760e90c09fc49/pylint-2.6.2-py3-none-any.whl (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
unearth.evaluator: Skipping link <Link https://files.pythonhosted.org/packages/f7/d4/c065f898e48e0d839525a2ede871f6f083ad322fb42c0ca0e7cf7ab7bb07/pylint-2.6.2.tar.gz (from https://pypi.org/simple/pylint/)>: Invalid requires-python: >=3.5.*
pdm.termui:     Could not find any matching candidates.
pdm.termui:     Could not find any matching candidates even when considering pre-releases.
pdm.termui: Error occurs
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/pdm/2.17.1/libexec/lib/python3.12/site-packages/pdm/termui.py", line 259, in logging
    yield logger
  File "/opt/homebrew/Cellar/pdm/2.17.1/libexec/lib/python3.12/site-packages/pdm/cli/actions.py", line 164, in do_lock
    raise ResolutionImpossible("Unable to find a resolution") from None
resolvelib.resolvers.ResolutionImpossible: Unable to find a resolution
```

PDM info:
```PDM version:
  2.17.1
Python Interpreter:
  /Users/liran/hiredscore/git/random/pdm_pylint/.venv/bin/python (3.9)
Project Root:
  /Users/liran/hiredscore/git/random/pdm_pylint
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.12.4",
  "os_name": "posix",
  "platform_machine": "arm64",
  "platform_release": "22.6.0",
  "platform_system": "Darwin",
  "platform_version": "Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000",
  "python_full_version": "3.12.4",
  "platform_python_implementation": "CPython",
  "python_version": "3.12",
  "sys_platform": "darwin"
}

```



Discussion:
using the same `venv` that PDM created and installing with pip:
```
(pdm_pylint-3.9) ➜  pdm_pylint pip install pylint==2.5.3
Collecting pylint==2.5.3
  Using cached pylint-2.5.3-py3-none-any.whl.metadata (6.6 kB)
WARNING: Package 'pylint' has an invalid Requires-Python: Invalid specifier: '>=3.5.*'
```

and eventually:
```
Successfully installed astroid-2.5 isort-4.3.21 lazy-object-proxy-1.10.0 mccabe-0.6.1 pylint-2.5.3 toml-0.10.2 wrapt-1.12.1
```
PDM is just less forgiving than pip. It cannot reliably lock dependencies if the metadata is invalid.
> PDM is just less forgiving than pip. It cannot reliably lock dependencies if the metadata is invalid.

I understand, it just means we can't install certain libraries with PDM
eventually, >=3.5.* is equal to >=3.5.0 or >= 3.5 and I guess that's how pip resolves it
> eventually, >=3.5.* is equal to >=3.5.0 or >= 3.5 and I guess that's how pip resolves it

No, starting from pip 24.1 these values will be ignored(regarded as no requires-python), PDM will follow this behavior.
> > eventually, >=3.5.* is equal to >=3.5.0 or >= 3.5 and I guess that's how pip resolves it
> 
> No, starting from pip 24.1 these values will be ignored(regarded as no requires-python), PDM will follow this behavior.

this will do the trick
thanks 



Patch:
diff --git a/news/3038.bugfix.md b/news/3038.bugfix.md
new file mode 100644
index 0000000000..7071bbe8f4
--- /dev/null
+++ b/news/3038.bugfix.md
@@ -0,0 +1,1 @@
+Ignore invalid requires-python values from index.
diff --git a/pdm.lock b/pdm.lock
index aef926ce59..ce90b164f2 100644
--- a/pdm.lock
+++ b/pdm.lock
@@ -5,7 +5,7 @@
 groups = ["default", "all", "cookiecutter", "copier", "doc", "keyring", "pytest", "template", "test", "tox", "workflow"]
 strategy = ["inherit_metadata"]
 lock_version = "4.5.0"
-content_hash = "sha256:89752749790efd07ae098751683577b1e5c6412239ae91863adc2cf8fb1fa2f4"
+content_hash = "sha256:a28c1999e735d82f74d27cf8b71c16d65597564f593aa923f1f5a0aeb1ffe6af"
 
 [[metadata.targets]]
 requires_python = ">=3.8"
@@ -563,7 +563,7 @@ files = [
 
 [[package]]
 name = "dep-logic"
-version = "0.4.3"
+version = "0.4.4"
 requires_python = ">=3.8"
 summary = "Python dependency specifications supporting logical operations"
 groups = ["default"]
@@ -571,8 +571,8 @@ dependencies = [
     "packaging>=22",
 ]
 files = [
-    {file = "dep_logic-0.4.3-py3-none-any.whl", hash = "sha256:03f2740fc40e2848f2a4c77baddcc8f5e3773c304da947815306d1e616f3942c"},
-    {file = "dep_logic-0.4.3.tar.gz", hash = "sha256:e4768f0a26c8c1c0e39fd520f3e0bd099ca528ec6a8f20359fbc89ffcdf8da45"},
+    {file = "dep_logic-0.4.4-py3-none-any.whl", hash = "sha256:3f47301f9a8230443d3df7d7f9bdc33d35d8591a14112d36f221b0e33810d3ae"},
+    {file = "dep_logic-0.4.4.tar.gz", hash = "sha256:e716afdda9351107c54ef4f6fd3fd29568f53529afb333b4958183b9d306e44a"},
 ]
 
 [[package]]
diff --git a/pyproject.toml b/pyproject.toml
index 2d79473e0b..b0d19ca284 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,7 +21,7 @@ dependencies = [
     "virtualenv>=20",
     "pyproject-hooks",
     "unearth>=0.16.0",
-    "dep-logic>=0.4.3",
+    "dep-logic>=0.4.4",
     "findpython>=0.6.0,<1.0.0a0",
     "tomlkit>=0.11.1,<1",
     "shellingham>=1.3.2",
diff --git a/src/pdm/models/candidates.py b/src/pdm/models/candidates.py
index 9d062d6d8f..18edd3b5de 100644
--- a/src/pdm/models/candidates.py
+++ b/src/pdm/models/candidates.py
@@ -237,6 +237,10 @@ def requires_python(self) -> str:
 
     @requires_python.setter
     def requires_python(self, value: str) -> None:
+        try:  # ensure the specifier is valid
+            PySpecSet(value)
+        except InvalidPyVersion:
+            return
         self._requires_python = value
 
     @no_type_check
diff --git a/src/pdm/models/finder.py b/src/pdm/models/finder.py
index bef1675ff7..6073e4ef49 100644
--- a/src/pdm/models/finder.py
+++ b/src/pdm/models/finder.py
@@ -1,16 +1,18 @@
 from __future__ import annotations
 
+import logging
 from typing import TYPE_CHECKING, Any, Callable
 
 import unearth
 from dep_logic.specifiers import InvalidSpecifier, parse_version_specifier
-from packaging.specifiers import InvalidSpecifier as PkgInvalidSpecifier
 from packaging.version import Version
 from unearth.evaluator import Evaluator, FormatControl, LinkMismatchError, Package
 
 from pdm.models.markers import EnvSpec
 from pdm.utils import parse_version
 
+logger = logging.getLogger("unearth")
+
 if TYPE_CHECKING:
     from pdm.models.session import PDMPyPIClient
 
@@ -40,8 +42,11 @@ def check_requires_python(self, link: unearth.Link) -> None:
         if link.requires_python:
             try:
                 requires_python = parse_version_specifier(link.requires_python)
-            except (InvalidSpecifier, PkgInvalidSpecifier) as e:
-                raise LinkMismatchError(f"Invalid requires-python: {link.requires_python}") from e
+            except InvalidSpecifier as e:
+                logger.debug(
+                    "Invalid requires-python specifier for link(%s) %s: %s", link.redacted, link.requires_python, e
+                )
+                return
             if (requires_python & self.env_spec.requires_python).is_empty():
                 raise LinkMismatchError(
                     f"The package requires-python {link.requires_python} is not compatible with the target {self.env_spec.requires_python}."
diff --git a/src/pdm/models/requirements.py b/src/pdm/models/requirements.py
index c2d75fedd3..66b3cbb445 100644
--- a/src/pdm/models/requirements.py
+++ b/src/pdm/models/requirements.py
@@ -14,7 +14,7 @@
 
 from packaging.requirements import InvalidRequirement
 from packaging.requirements import Requirement as PackageRequirement
-from packaging.specifiers import SpecifierSet
+from packaging.specifiers import InvalidSpecifier, SpecifierSet
 from packaging.utils import parse_sdist_filename, parse_wheel_filename
 
 from pdm.compat import Distribution
@@ -143,7 +143,10 @@ def create(cls: type[T], **kwargs: Any) -> T:
         if "extras" in kwargs and isinstance(kwargs["extras"], str):
             kwargs["extras"] = tuple(e.strip() for e in kwargs["extras"][1:-1].split(","))
         version = kwargs.pop("version", "")
-        kwargs["specifier"] = get_specifier(version)
+        try:
+            kwargs["specifier"] = get_specifier(version)
+        except InvalidSpecifier as e:
+            raise RequirementError(f'Invalid specifier for {kwargs.get("name")}: {version}: {e}') from None
         return cls(**{k: v for k, v in kwargs.items() if k in inspect.signature(cls).parameters})
 
     @classmethod
@@ -171,7 +174,7 @@ def from_dist(cls, dist: Distribution) -> Requirement:
     @classmethod
     def from_req_dict(cls, name: str, req_dict: RequirementDict, check_installable: bool = True) -> Requirement:
         if isinstance(req_dict, str):  # Version specifier only.
-            return NamedRequirement(name=name, specifier=get_specifier(req_dict))
+            return NamedRequirement.create(name=name, version=req_dict)
         for vcs in VCS_SCHEMA:
             if vcs in req_dict:
                 repo = cast(str, req_dict.pop(vcs, None))
diff --git a/src/pdm/models/specifiers.py b/src/pdm/models/specifiers.py
index 1048d96c69..d86424d3da 100644
--- a/src/pdm/models/specifiers.py
+++ b/src/pdm/models/specifiers.py
@@ -35,7 +35,7 @@ def _read_max_versions() -> dict[Version, int]:
 def get_specifier(version_str: str | None) -> SpecifierSet:
     if not version_str or version_str == "*":
         return SpecifierSet()
-    return SpecifierSet(fix_legacy_specifier(version_str))
+    return SpecifierSet(version_str)
 
 
 _legacy_specifier_re = re.compile(r"(==|!=|<=|>=|<|>)(\s*)([^,;\s)]*)")


Test patch:
diff --git a/tests/models/test_candidates.py b/tests/models/test_candidates.py
index fd60d8a223..058372ff09 100644
--- a/tests/models/test_candidates.py
+++ b/tests/models/test_candidates.py
@@ -5,7 +5,6 @@
 import pytest
 from unearth import Link
 
-from pdm.exceptions import CandidateNotFound
 from pdm.models.candidates import Candidate
 from pdm.models.requirements import Requirement, parse_requirement
 from pdm.models.specifiers import PySpecSet
@@ -272,8 +271,7 @@ def test_legacy_pep345_tag_link(project):
     project.project_config["pypi.url"] = "https://my.pypi.org/simple"
     req = parse_requirement("pep345-legacy")
     repo = project.get_repository()
-    with pytest.raises(CandidateNotFound):
-        _ = next(iter(repo.find_candidates(req)))
+    _ = next(iter(repo.find_candidates(req)))
 
 
 @pytest.mark.filterwarnings("ignore::FutureWarning")
@@ -281,8 +279,7 @@ def test_ignore_invalid_py_version(project):
     project.project_config["pypi.url"] = "https://my.pypi.org/simple"
     req = parse_requirement("wheel")
     repo = project.get_repository()
-    with pytest.raises(CandidateNotFound):
-        _ = next(iter(repo.find_candidates(req)))
+    _ = next(iter(repo.find_candidates(req)))
 
 
 def test_find_candidates_from_find_links(project):