pdm-project / pdm

A modern Python package and dependency manager supporting the latest PEP standards
https://pdm-project.org
MIT License
7.91k stars 396 forks source link

InvalidPyVersion with message: postreleases are not supported for python version specifiers #1334

Closed jdvalentine closed 2 years ago

jdvalentine commented 2 years ago

I am attempting to install a local package into a .venv. This project was originally managed with pipenv and the requirements were imported from the Pipenv file. The algoliasearch module was preventing locking, so I removed it from pyproject.toml . I have now tried to add it back in:

Steps to reproduce

$ pdm -v add algoliasearch

Actual behavior

Command output:

Adding packages to default dependencies: algoliasearch
See /tmp/pdm-lock-3t2qgv7r.log for detailed debug log.
[InvalidPyVersion]: 3.3.*': postreleases are not supported for python version specifiers.

/tmp/pdm-lock-3t2qgv7r.log contains the following (I have removed the long list of .exe files found in the repo):

pdm.termui:   pytest
pdm.termui:   black
pdm.termui:   fastapi
pdm.termui:   uvicorn
pdm.termui:   neo4j
pdm.termui:   python-multipart
pdm.termui:   Jinja2
pdm.termui:   aiofiles
pdm.termui:   toml
pdm.termui:   Babel
pdm.termui:   sentry-sdk
pdm.termui:   httpx-oauth
pdm.termui:   itsdangerous
pdm.termui:   httpx
pdm.termui:   starlette
pdm.termui:   Authlib
pdm.termui:   requests
pdm.termui:   fastapi-mail
pdm.termui:   icecream
pdm.termui:   boto3
pdm.termui:   filetype
pdm.termui:   tld
pdm.termui:   bs4
pdm.termui:   lxml
pdm.termui:   python-json-logger
pdm.termui:   fastapi-utils
pdm.termui:   Pillow
pdm.termui:   pandas
pdm.termui:   fastapi-cache2
pdm.termui:   passlib
pdm.termui:   algoliasearch
pdm.termui:   python>=3.10
pdm.termui:   Adding requirement pytest
pdm.termui:   Adding requirement black
pdm.termui:   Adding requirement fastapi
pdm.termui:   Adding requirement uvicorn
pdm.termui:   Adding requirement neo4j
pdm.termui:   Adding requirement python-multipart
pdm.termui:   Adding requirement Jinja2
pdm.termui:   Adding requirement aiofiles
pdm.termui:   Adding requirement toml
pdm.termui:   Adding requirement Babel
pdm.termui:   Adding requirement sentry-sdk
pdm.termui:   Adding requirement httpx-oauth
pdm.termui:   Adding requirement itsdangerous
pdm.termui:   Adding requirement httpx
pdm.termui:   Adding requirement starlette
pdm.termui:   Adding requirement Authlib
pdm.termui:   Adding requirement requests
pdm.termui:   Adding requirement fastapi-mail
pdm.termui:   Adding requirement icecream
pdm.termui:   Adding requirement boto3
pdm.termui:   Adding requirement filetype
pdm.termui:   Adding requirement tld
pdm.termui:   Adding requirement bs4
pdm.termui:   Adding requirement lxml
pdm.termui:   Adding requirement python-json-logger
pdm.termui:   Adding requirement fastapi-utils
pdm.termui:   Adding requirement Pillow
pdm.termui:   Adding requirement pandas
pdm.termui:   Adding requirement fastapi-cache2
pdm.termui:   Adding requirement passlib
pdm.termui:   Adding requirement algoliasearch
unearth: Collecting links from https://pypi.python.org/simple/algoliasearch/
unearth: Found index url https://pypi.python.org/simple
unearth: Skip link <Link https://files.pythonhosted.org/packages/42/1d/e64344bf68dc746e9c245a1251dc54cb3b7e120206655e16ba2f18cfcf1b/algoliasearch-1.0.0.macosx-10.8-intel.exe (from https://pypi.org/simple/algoliasearch/)>: Unsupported archive format: algoliasearch-1.0.0.macosx-10.8-intel.exe
unearth: Skip link <Link https://files.pythonhosted.org/packages/fa/2e/8b85978e1dc6509b9f7570012ea14a6f88838c7057130250f40351aa7f6d/algoliasearch-1.0.1.macosx-10.8-intel.exe (from https://pypi.org/simple/algoliasearch/)>: Unsupported archive format: algoliasearch-1.0.1.macosx-10.8-intel.exe
unearth: Skip link <Link https://files.pythonhosted.org/packages/b1/81/5d34fe268825c4bae18d9b43220da7f140311b7531a6bcfc6035f39b2a5f/algoliasearch-1.0.2.macosx-10.8-intel.exe (from https://pypi.org/simple/algoliasearch/)>: Unsupported archive format: algoliasearch-1.0.2.macosx-10.8-intel.exe
=== SNIP ===
unearth: Skip link <Link https://files.pythonhosted.org/packages/37/9f/41b2c6e9111bc759977feeef5946b18fdfc3aa1b10ab4537a45ee569b994/algoliasearch-1.5.4.macosx-10.10-intel.exe (from https://pypi.org/simple/algoliasearch/)>: Unsupported archive format: algoliasearch-1.5.4.macosx-10.10-intel.exe
unearth: Skip link <Link https://files.pythonhosted.org/packages/30/a8/7c7901368aab6089c02962e96aa8edee4a6df57c6c23779e54d9a3a69b86/algoliasearch-1.5.5.macosx-10.10-intel.exe (from https://pypi.org/simple/algoliasearch/)>: Unsupported archive format: algoliasearch-1.5.5.macosx-10.10-intel.exe
pdm.termui: Error occurs
Traceback (most recent call last):
  File "/home/james/.local/lib/python3.10/site-packages/pdm/termui.py", line 234, in logging
    yield logger
  File "/home/james/.local/lib/python3.10/site-packages/pdm/cli/actions.py", line 101, in do_lock
    mapping, dependencies = resolve(
  File "/home/james/.local/lib/python3.10/site-packages/pdm/resolver/core.py", line 30, in resolve
    result = resolver.resolve(requirements, max_rounds)
  File "/home/james/.local/lib/python3.10/site-packages/resolvelib/resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/james/.local/lib/python3.10/site-packages/resolvelib/resolvers.py", line 348, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "/home/james/.local/lib/python3.10/site-packages/resolvelib/resolvers.py", line 172, in _add_to_criteria
    if not criterion.candidates:
  File "/home/james/.local/lib/python3.10/site-packages/resolvelib/structs.py", line 126, in __bool__
    next(self._factory())
  File "/home/james/.local/lib/python3.10/site-packages/pdm/resolver/providers.py", line 252, in matches_gen
    yield from super_find()
  File "/home/james/.local/lib/python3.10/site-packages/pdm/resolver/providers.py", line 146, in matches_gen
    candidates = self._find_candidates(reqs[0])
  File "/home/james/.local/lib/python3.10/site-packages/pdm/resolver/providers.py", line 128, in _find_candidates
    return self.repository.find_candidates(
  File "/home/james/.local/lib/python3.10/site-packages/pdm/models/repositories.py", line 148, in find_candidates
    applicable_cans_python_compatible = [
  File "/home/james/.local/lib/python3.10/site-packages/pdm/models/repositories.py", line 151, in <listcomp>
    if ignore_requires_python or requires_python.is_subset(c.requires_python)
  File "/home/james/.local/lib/python3.10/site-packages/pdm/models/specifiers.py", line 363, in is_subset
    other = type(self)(str(other))
  File "/home/james/.local/lib/python3.10/site-packages/pdm/models/specifiers.py", line 68, in __init__
    self._analyze_specifiers()
  File "/home/james/.local/lib/python3.10/site-packages/pdm/models/specifiers.py", line 74, in _analyze_specifiers
    op, version = _normalize_op_specifier(spec.operator, spec.version)
  File "/home/james/.local/lib/python3.10/site-packages/pdm/models/specifiers.py", line 27, in _normalize_op_specifier
    version = Version(version_str)
  File "/home/james/.local/lib/python3.10/site-packages/pdm/models/versions.py", line 49, in __init__
    raise InvalidPyVersion(
pdm.exceptions.InvalidPyVersion: 3.1.*': postreleases are not supported for python version specifiers.

Expected behavior

The latest version of the package should be installed, as it is by Pipenv. Is there a workaround in the case that version numbering by a package maintainer is not as expected?

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.1.2
Python Interpreter:
  /home/james/code-projects/whatcourses/whatcourses-api/.venv/bin/python (3.10)
Project Root:
  /home/james/code-projects/whatcourses/whatcourses-api
Project Packages:
  None
{
  "implementation_name": "cpython",
  "implementation_version": "3.10.4",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.15.0-46-generic",
  "platform_system": "Linux",
  "platform_version": "#49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022",
  "python_full_version": "3.10.4",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "linux"
}
jdvalentine commented 2 years ago

Thank you @frostming - I have confirmed this fix at my end. :+1: