Skip to content

pip-sync --python-executable evaluates markers for the wrong environment #2115

Open
@gschaffner

Description

@gschaffner

pip-sync --python-executable evaluates environment markers for the wrong environment. It evaluates for the calling environment instead of the target environment.

Environment Versions

  1. OS Type: Arch Linux
  2. Python version: multiple required to repro; see below
  3. pip version: 24.1.2
  4. pip-tools version: 7.4.1

Steps to replicate

Minimal reproducer:

#!/usr/bin/env bash

shopt -s inherit_errexit
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace

cd "$(mktemp -d)"

:
python3.12 -m venv --upgrade-deps .venv312
.venv312/bin/python -V
.venv312/bin/pip install --quiet pip-tools
.venv312/bin/pip-sync --version
.venv312/bin/pip --version

:
python3.11 -m venv --upgrade-deps .venv311
.venv311/bin/python -V
.venv311/bin/pip uninstall --quiet --yes setuptools
.venv311/bin/pip --version

:
<<EOF cat > req.pipreq
typing-extensions==4.12.2 ; python_version < "3.12"
EOF
.venv312/bin/pip-sync --python-executable=.venv311/bin/python req.pipreq
.venv311/bin/python -c 'import typing_extensions'

Output:

++ mktemp -d
+ cd /tmp/tmp.0EtEvbDhIl
+ :
+ python3.12 -m venv --upgrade-deps .venv312
+ .venv312/bin/python -V
Python 3.12.4
+ .venv312/bin/pip install --quiet pip-tools
+ .venv312/bin/pip-sync --version
pip-sync, version 7.4.1
+ .venv312/bin/pip --version
pip 24.1.2 from /tmp/tmp.0EtEvbDhIl/.venv312/lib/python3.12/site-packages/pip (python 3.12)
+ :
+ python3.11 -m venv --upgrade-deps .venv311
+ .venv311/bin/python -V
Python 3.11.9
+ .venv311/bin/pip uninstall --quiet --yes setuptools
+ .venv311/bin/pip --version
pip 24.1.2 from /tmp/tmp.0EtEvbDhIl/.venv311/lib/python3.11/site-packages/pip (python 3.11)
+ :
+ cat
+ .venv312/bin/pip-sync --python-executable=.venv311/bin/python req.pipreq
Everything up-to-date
+ .venv311/bin/python -c 'import typing_extensions'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'typing_extensions'

Expected result

pip-sync installs typing_extensions.

Actual result

pip-sync exits 0 without installing typing_extensions (Everything up-to-date).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not workingmarkersRelated to environment markerssync

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions