Package: dh-python
Version: 5.20230603
Severity: normal

I had to override dh_python3 to add --no-guessing-deps in the latest
dnspython upload because it was getting things wrong.  Here's what it
generated:

python3-httpcore | python3 (<< 3.8), python3-sniffio, python3:any

The correct answer here is actually use python3:any.  Here's what I
think is going on:

>From the pyproject.toml file:

[tool.poetry.dependencies]
python = "^3.8"
httpx = {version=">=0.24.1", optional=true, python=">=3.8"}
httpcore = {version=">=0.17.3", optional=true, python=">=3.8"}
h2 = {version=">=4.1.0", optional=true, python=">=3.8"}
idna = {version=">=2.1,<4.0", optional=true}
cryptography = {version=">=2.6,<42.0", optional=true}
trio = {version=">=0.14,<0.23", optional=true}
sniffio = {version="^1.1", optional=true}
wmi = {version="^1.5.1", optional=true}
aioquic = {version=">=0.9.20", optional=true}

...

[tool.poetry.extras]
doh = ['httpx', 'h2']
idna = ['idna']
dnssec = ['cryptography']
trio = ['trio']
wmi = ['wmi']
doq = ['aioquic']

There are two issues:

1.  httpcore and sniffio shouldn't be listed at all.  They are optional.
I suspect that either poetry or dh-python is looking at the extras
section and since those packages aren't listed for one of the extras, it
assumes the package is required, despite the optional flag.  They
probably should be listed somewhere (upstream bug), but I think if it
says optional, it shouldn't be added to Depends.

2.  Generating an optional depends on python3 << 3.8 isn't helpful.  It
looks to me like {version=">=0.17.3", optional=true, python=">=3.8"} is
being mis-interpreted.  I believe the intent here is to say that the
dependency is optional when python3 > 3.8, not you need it if python3 >
3.8.  There's a larger question of why the interpreter version is there
at all, given that's now the minimum python3 version supported, but
that's an upstream issue, we ought to get it right.

Scott K

Reply via email to