pex-tool / pex

A tool for generating .pex (Python EXecutable) files, lock files and venvs.
https://docs.pex-tool.org/
Apache License 2.0
2.61k stars 261 forks source link

Incorrect lock with pinned requirement + extras (old Pip) #2048

Closed jsirois closed 1 year ago

jsirois commented 1 year ago

This lock nets apache-airflow 2.4.3:

$ pex3 lock create "apache-airflow==2.4.3" --style universal --interpreter-constraint "==3.10.*" --target-system linux --target-system mac --resolver-vers
ion pip-2020-resolver --indent 2 -o extras-none.lock

This does not. It nets apache-airflow 2.5.1 instead:

$ pex3 lock create "apache-airflow[cncf.kubernetes]==2.4.3" --style universal --interpreter-constraint "==3.10.*" --target-system linux --target-system ma
c --resolver-version pip-2020-resolver --indent 2 -o extras-cncf.kubernetes.lock
jsirois commented 1 year ago

@adityav this fixes:

$ pex3 lock create "apache-airflow[cncf.kubernetes]==2.4.3" --style universal --interpreter-constraint "==3.10.*" --target-system linux --target-system mac --resolver-version pip-2020-resolver --pip-version 22.3 --indent 2 -o pip-22.3-extras-cncf.kubernetes.lock

The key bit being --pip-version 22.3

A proof of the fix is:

$ pex --lock pip-22.3-extras-cncf.kubernetes.lock -oexample.pex
$ pex-tools ./example.pex info -i2 | jq '{reqs: .requirements, dists: .distributions | keys[] | select(test("^apache_airflow-"))}'
{
  "reqs": [
    "apache-airflow[cncf.kubernetes]==2.4.3"
  ],
  "dists": "apache_airflow-2.4.3-py3-none-any.whl"
}

But I've attachedthe resulting lock as well: pip-22.3-extras-cncf.kubernetes.lock.txt