python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.42k stars 2.27k forks source link

`poetry show [package]` gives version of `required by` package that doesn't match `poetry.lock` #9749

Open elliot-100 opened 3 hours ago

elliot-100 commented 3 hours ago

Description

Here's an example.

Extract from my project's poetry.lock:

[[package]]
name = "playwright"
version = "1.47.0"
description = "A high-level API to automate web browsers"
optional = false
python-versions = ">=3.8"
files = [--snipped--]

[package.dependencies]
greenlet = "3.0.3"
pyee = "12.0.0"
> poetry show greenlet
 name         : greenlet                                      
 version      : 3.0.3                                         
 description  : Lightweight in-process concurrent programming 

required by
 - playwright 3.0.3

Playwright's latest version is 1.47; it looks like the locked version of greenlet is being shown here instead.

Notes:

Workarounds

Examining poetry.lock and not trusting poetry show [package].

Poetry Installation Method

install.python-poetry.org

Operating System

Windows 11

Poetry Version

1.8.3

Poetry Configuration

cache-dir = "C:\\Users\\--user-redacted--\\AppData\\Local\\pypoetry\\Cache"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
repositories.testpypi.url = "https://test.pypi.org/legacy/"
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = false

### Python Sysconfig

```bash session
Platform: "win-amd64"
Python version: "3.12"
Current installation scheme: "venv"

Paths: 
        data = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12"
        include = "C:\Users\--user-redacted--\AppData\Local\Programs\Python\Python312\Include"
        platinclude = "C:\Users\--user-redacted--\AppData\Local\Programs\Python\Python312\Include"
        platlib = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12\Lib\site-packages"
        platstdlib = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12\Lib"
        purelib = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12\Lib\site-packages"
        scripts = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12\Scripts"
        stdlib = "C:\Users\--user-redacted--\AppData\Local\Programs\Python\Python312\Lib"

Variables: 
        BINDIR = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12\Scripts"
        BINLIBDEST = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12\Lib"
        EXE = ".exe"
        EXT_SUFFIX = ".cp312-win_amd64.pyd"
        INCLUDEPY = "C:\Users\--user-redacted--\AppData\Local\Programs\Python\Python312\Include"  
        LIBDEST = "C:\Users\--user-redacted--\AppData\Local\Programs\Python\Python312\Lib"        
        TZPATH = ""
        VERSION = "312"
        VPATH = "..\.."
        abiflags = ""
        base = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12"
        exec_prefix = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12"
        installed_base = "C:\Users\--user-redacted--\AppData\Local\Programs\Python\Python312"     
        installed_platbase = "C:\Users\--user-redacted--\AppData\Local\Programs\Python\Python312" 
        platbase = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12"
        platlibdir = "DLLs"
        prefix = "C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12"
        projectbase = "C:\Users\--user-redacted--\AppData\Local\Programs\Python\Python312"        
        py_version = "3.12.7"
        py_version_nodot = "312"
        py_version_nodot_plat = "312"
        py_version_short = "3.12"
        srcdir = "C:\Users\--user-redacted--\AppData\Local\Programs\Python\Python312"
        userbase = "C:\Users\--user-redacted--\AppData\Roaming\Python"

Example pyproject.toml

[tool.poetry]
name = "britishcycling-clubs"
version = "0.10.0.post1"
description = "Unofficial library to automate aspects of British/Scottish/Welsh Cycling's club Membership Manager system"
authors = ["elliot-100 <3186037+elliot-100@users.noreply.github.com>"]
readme = "README.md"
homepage = "https://github.com/elliot-100/britishcycling-clubs"
repository = "https://github.com/elliot-100/britishcycling-clubs"
packages = [{include = "britishcycling_clubs"}]
include = ["CHANGELOG.md"]
license = "GPL-3.0-only"

[tool.poetry.dependencies]
python = ">=3.8"
beautifulsoup4 = ">=4.12.2"
requests = ">=2.23.1"
playwright = ">=1.39.0"

[tool.poetry.group.dev.dependencies]
pdoc = ">=14.6.0"
ruff = ">=0.5.7"

[tool.poetry.group.test.dependencies]
mypy = ">=1.11.1"
pytest = ">=7.4.4"
types-requests = ">=2.32.0"
types-beautifulsoup4 = ">=4.12.0"

[tool.mypy]
strict = true

[[tool.mypy.overrides]]
module = "playwright"
disallow_untyped_calls = false

[tool.ruff]
target-version = "py38"  # Ruff doesn't respect Python version in [tool.poetry.dependencies]

[tool.ruff.lint]
select = ["ALL"]

# Ignore rules that conflict with Ruff formatter:
#   COM812 Trailing comma missing
#   ISC001 Implicitly concatenated string literals on one line
ignore = ["COM812", "ISC001"]

[tool.ruff.lint.per-file-ignores]
# Ignore rules that aren't relevant/useful in tests:
#   PLR2004 Magic value used in comparison
#   S101 Use of assert detected
"**/{tests}/*" = ["PLR2004", "S101"]
# Ignore rules that aren't relevant/useful in example scripts:
#   T203 `pprint` found
"example*.py" = ["T203"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Poetry Runtime Logs

Loading configuration file C:\Users\--user-redacted--\AppData\Roaming\pypoetry\config.toml
Using virtualenv: C:\Users\--user-redacted--\AppData\Local\pypoetry\Cache\virtualenvs\britishcycling-clubs-_kmXzTV9-py3.12
 name         : greenlet                                      
 version      : 3.0.3                                         
 description  : Lightweight in-process concurrent programming 

required by
 - playwright 3.0.3
dimbleby commented 3 hours ago

it's not saying that playwright 3.0.3 requires greenlet, it's saying that playwright requires greenlet at exactly version 3.0.3

Secrus commented 2 hours ago

it's not saying that playwright 3.0.3 requires greenlet, it's saying that playwright requires greenlet at exactly version 3.0.3

It is still confusing (confused me too). Issue is valid as bad UX.

dimbleby commented 2 hours ago

sure, no disagreement, just pointing out what it is that poetry is actually telling you

elliot-100 commented 2 hours ago

it's not saying that playwright 3.0.3 requires greenlet, it's saying that playwright requires greenlet at exactly version 3.0.3

From my point of view, it's not saying that at all, and I'm not sure that anyone could reasonably say it does. The documentation has no detail at all here. But it's good to have the intended behaviour confirmed.

I will try to submit a PR to add to the documentation.

What if the command output said:

> poetry show my-package
 name         : my-package                                      
 version      : 1.2.3                                         
 description  : Example 

required by:
 - another-package requires my-package 1.2.3

?

dimbleby commented 2 hours ago

might as well just tweak the code directly, rather than leave it confusing but documented-as-confusing.

fwiw requiring an exact version is unusual - playwright is likely wrong to do this, though I know nothing about that project.

The current output is somewhat less confusing when it says something like

required by 
  - playwright >=2.3.4
  - another >=3,<4