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

inlude hash for package when generating requirements.txt #2045

Closed
brutus opened this issue Jan 16, 2024 · 3 comments
Closed

inlude hash for package when generating requirements.txt #2045

brutus opened this issue Jan 16, 2024 · 3 comments
Labels
hashes Related to hashes generated via --generate-hashes question User question

Comments

@brutus
Copy link

brutus commented Jan 16, 2024

I have a Python package (with pyproject.toml) that is released to an internal package registry.

I use pip-compile to pin its dependencies like this:

pip-compile \
  --quiet \
  --upgrade \
  --resolver backtracking \
  --allow-unsafe \
  --no-header \
  --strip-extras \
  --annotation-style line \
  pyproject.toml

And an Ansible task to deploy it to some hosts:

- name: install Python package
  pip:
    executable: pip3
    name: mypkg
    version: "0.1.2"
    extra_args: --user --no-cache
  environment:
    PIP_CONSTRAINT: /home/user/requirements.txt

Note: the requirements.txt and a pip.conf for the internal registry were copied beforehand. Seems to work okay so far.

When I add --generate-hashes to the pip-compile call, it bails on me:

Hashes are required in --require-hashes mode, but they are missing from some requirements.

The missing hashes are those for mypkg.

Is there a (supported) way to include mypkg in the generated requirements.txt? Or is this the wrong way to handle it?

@chrysle
Copy link
Contributor

chrysle commented Jan 18, 2024

Thanks for reporting!

Is there a (supported) way to include mypkg in the generated requirements.txt?

If so I don't know it. The --require-hashes option actually comes from pip. I think it's reasonable to operate in that mode when explicitly generating hashes, since they're normally present. However we might add an option to handle additional dependencies in such cases?

@chrysle chrysle added question User question hashes Related to hashes generated via --generate-hashes labels Jan 18, 2024
@webknjaz
Copy link
Member

It's a pip bug: pypa/pip#9243.

@webknjaz webknjaz closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2024
@webknjaz
Copy link
Member

Also, it wouldn't make sense to generate the hash for an editable copy of mypkg since it'll change on the next build and will never match. You really need to package it for deployment and hash that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashes Related to hashes generated via --generate-hashes question User question
Projects
None yet
Development

No branches or pull requests

3 participants