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

Allow omitting version pins from command line when version is given in hashed constraints file #12889

Closed
1 task done
ncoghlan opened this issue Aug 2, 2024 · 2 comments
Closed
1 task done
Labels
resolution: duplicate Duplicate of an existing issue/PR type: feature request Request for a new feature

Comments

@ncoghlan
Copy link
Member

ncoghlan commented Aug 2, 2024

What's the problem this feature will solve?

Making it easier to securely bootstrap environment management tools in CI (and other) environments.

Running pip install --update -c ci-constraints.txt pdm currently emits the following error:

ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
    pdm from https://files.pythonhosted.org/packages/6d/c2/045c3c5c37d9dd297631a6fdcdd54bfc73196c8e5b43b7aca954e4de363a/pdm-2.17.3-py3-none-any.whl

Describe the solution you'd like

I would prefer that the command pip install --update -c ci-constraints.txt pdm work (using the version pin given in the constraints file) without requiring duplication of that information in the installation command.

(passing -r ci-constraints.txt instead isn't desirable, since the goal here is to install just enough to let pdm sync --no-self --dev run to create the actual CI environment)

Alternative Solutions

The workaround is to duplicate the locked pdm version in the GitHub CI bootstrapping step. For my use case, I did that via a short helper script:

# Allow bootstrapping `pdm` in CI environments
# with the command `pip install --update -c ci-constraints.txt -r ci-bootstrap-requirements.txt`
ci_constraints_file="ci-constraints.txt"
pdm export --dev --no-extras -o "$ci_constraints_file"
ci_bootstrap_file="ci-bootstrap-requirements.txt"
echo "# This file is autogenerated, do not edit it manually" > "$ci_bootstrap_file"
echo > "$ci_bootstrap_file"
grep "^pdm==" "$ci_constraints_file" | cut -f 1 -d ' ' > "$ci_bootstrap_file"

Additional context

N/A

Code of Conduct

@ncoghlan ncoghlan added S: needs triage Issues/PRs that need to be triaged type: feature request Request for a new feature labels Aug 2, 2024
@mayeut
Copy link
Member

mayeut commented Aug 2, 2024

somewhat related: #9243

@pradyunsg
Copy link
Member

It's actually a duplicate of that.

#9243 (comment) is this case ~exactly.

@pradyunsg pradyunsg added resolution: duplicate Duplicate of an existing issue/PR and removed S: needs triage Issues/PRs that need to be triaged labels Aug 2, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: duplicate Duplicate of an existing issue/PR type: feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

3 participants