Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(pex.tools): prefer a pex-file-provided package versions when --pip flag is also provided #2105

Closed
cognifloyd opened this issue Mar 27, 2023 · 0 comments · Fixed by #2107
Assignees

Comments

@cognifloyd
Copy link

cognifloyd commented Mar 27, 2023

Given a reqs.pex file that includes a version of pip, pex-tools reqs.pex --pip should prefer the versions of packages included in the pex.

This may mean that pex has to downgrade the version of pip (and possibly setuptools, which pip depends on) to match whatever is included in the pex file.

Today, pex creates the virtualenv using the appropriate commands to include pip. Then it installs the requirements from the pex file, but any packages that already exist in the virtualenv, like pip, do not get downgraded to the version in the pex file. This feature request should reverse that.

pex-tools should report a warning about the collision between the pex file and the --pip flag (since the --pip flag is the only reason the virtualenv will have contents before installing things from the pex file). That warning should be silenced by --collisions-ok.

Background: pants

When running ./pants export ..., pants uses pex-tools venv --pip --collisions-ok for mutable virtualenvs.
https://github.com/pantsbuild/pants/blob/8fef19f9050d42c949edf781125cdebd6851fc57/src/python/pants/backend/python/goals/export.py#L239-L253
(that link has the following, which I'm including here since github doesn't include cross-repo snippets):

                    complete_pex_env.create_argv(
                        os.path.join(tmpdir_under_digest_root, pex_pex.exe),
                        *[
                            os.path.join(tmpdir_under_digest_root, requirements_pex.name),
                            "venv",
                            "--pip",
                            "--collisions-ok",
                            output_path,
                        ],
                    ),
                    {
                        **complete_pex_env.environment_dict(python=requirements_pex.python),
                        "PEX_MODULE": "pex.tools",
                    },
                ),

For StackStorm, we depend on pip+setuptools at runtime, and I want to make sure that the locked version is always used in the venv.

Slack

This request follows on a discussion in slack:

@jsirois jsirois self-assigned this Mar 28, 2023
jsirois added a commit that referenced this issue Mar 30, 2023
Now, when creating a venv using pex tools and the `--pip` option from a
PEX that includes pip or setuptools or both, those embedded versions
will be used in place of the conflicting versions installed via `--pip`
if `--collisions-ok` is also specified; otherwise the venv pex tool will
error.

Closes #2105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants