-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(pip_requirements): support hashes #2444
Comments
Can you describe what your expectations are for hash updating? Eg from which sources (public pypi only?) and updated/checked only when the version is changed? |
For example, If you, locally, run |
I guess, ultimately, is that I'd like to see a PR like the one that |
If the hashes are available from pypi results then it should be easy. |
BTW I will rename this issue because python support is enabled - it’s just that it doesn’t support hashes in requirements.txt. I will use this issue instead to track support for hashin-style hash updates. We can reuse existing terminology of “digests” for this |
It used to do that. Not any more. Not as of version 0.13 when it started using |
So if we base Renovate’s solution 100% off PyPi json then that would satisfy your requirements? |
How/where is the algorithm specified? Or can we just use the default? |
However, one thing I need to figure out is this... If I personally run
However, if you don't supply the If the original maker of that
Now all the "junk" hashes are back for this version upgrade :( |
Sounds like we need python version awareness first and then solve hashes second. Is there a standardised way to specify python version in a repository or is it something we’d need users to add to their Renovate config? Right now we just take the latest available on pypi |
Yes. I don't know what Pyup uses internally but they can cope with
What hashin does is that it defaults to |
How so? How does the current Renovate Python support work then?
If the project doesn't have a If a
In that case, it's the same as good old |
We have Python support, we just don’t support varying the results based on what version of Python the user wants, eg 3.6 |
Ah. That way upgrades would be done using the same specified Python versions (and/or algorithm of choice) you used when you added the package to the |
Hashes are not supported and no updates were being posted so removing for now. See renovatebot/renovate#2444
Hashes are not supported and no updates were being posted so removing for now. See renovatebot/renovate#2444
@rarkins I think it's not necessary to know exact Python version, we can infer it from dep's UPD: it seems the python version won't help since it also depends on operating system and so on |
I have clear model on how to handle this, just need some guidance on better implementation: (1) create Ideally I would prefer (3) and will try it first. |
We changed the architecture for how we do updates. I think now what we should do is:
The main question is whether we update the hashes using our own code or using a third party tool like |
@peterbe can you give us an update on your current requirements? Some of the links above now 404 |
@rarkins I'd like to add to the discussion since I have an interest in this feature. I've created a sample repo using an actual set of requirements as they are laid out in a project I work on. It can be found here https://github.com/caphrim007/sample-requirements I think my use case (may?) be more simple than @peterbe ? I don't have a need to specify the python version, the architecture, or the distribution method (source, wheel, etc). My workflow today which I had intended on having renovate do instead is simply
If I can offer any other assistance or feedback, lemme know. Thanks! |
that is what I would expect to see, yes. Based off of the testing I did last night (and what @zharinov had in their PR) at present, renovate would not be able to detect the package name/hashes/ etc. But what you've posted in the pic is essentially what I wanted to get out of renovate. I figured this was the simplest case before tossing in features like python versions, archs, etc. Those too may be desirable at some point in the future. However, today, the basic case is sufficient for my own needs. Not sure about @peterbe's reqs |
@caphrim007 do you know why if you run |
Other than that, it's essentially working: https://github.com/renovate-tests/sample-requirements/pulls |
If I had to guess it's due to some quirk in how naming happens with some dependencies in pypi and req files. I think I have a hack in one of my own scripts to handle this case actually. Let me just verify that though. In a nutshell, it tries to find foo_package, but the dependency is actually foo-package but for whatever reason, the package online is named by hyphen or dash. I can't really explain it because I'm not entirely sure what is happening, but that's my guess. Lemme take a look at my script/hack workaround. I don't think this is a common thing though |
@rarkins what you're seeing appears to be what I was hacking around in my local scripts. pypi...somewhere....draws some sort of distinction between underscored and hyphenated packages. Here's a specific package I was hacking around; https://pypi.org/project/websocket_client/ I'm not sure what the rules are for when to convert between underscored and hyphenated, orther than than underscores are "discouraged" for packages and pypi may be forcing a conversion on your behalf if you submit an underscored package name. https://www.python.org/dev/peps/pep-0008/#package-and-module-names That's my best guess. When I update the package you mentioned, it gets appended to my constraint file as On the bright side, for this package, the hashes for the hyphenated version are the same as for the underscored version. So, a couple of proposals. First, I can reach out to the packaging working group/PyPA folks and ask for some clarification around what is expected (hyphen vs underscore) and why both work when you install them. I imagine its for reasons of not breaking the world though. They likely made a breaking change and didn't want to affect all of the existing software that likely hardcode the underscored name. Second, renovate can make some judgement calls on how it wants to handle these. If PEP8 is the reason that pypi did this, then PEP8 would be considered correct form and it may be the case that renovate would want to do this sort of conversion for the user automatically and replace the underscored name in the requirements file. In case that behavior is making too many assumptions though, maybe this is a configurable option in the pip_requirements manager. Whether or not conversion is done, it would be useful for debugging purposes to see when renovate detects the oddity. For instance, a logger.debug message when it sees the package name that includes an underscore. Perhaps it should ignore packages with underscores, or include a different message in the PR. I'll leave that for you to decide. In this case with my own dependencies I verified that the readme_renderer, when changed to hyphenated, does not result in a failed pip install. So I consider this a bug in my requirements and I'll change it. I did the same verification for the websocket-client dependency and changed that too. Lemme know if you care to have me ask the PyPA folks about the underscore/hyphen thing. Otherwise, I'll have a look at the PR you posted here and see if I get the same results. |
I think is beyond the scope of what Renovate should be responsible for. e.g. if |
@caphrim007 I don't mean to sound lazy but can you, for a moment, look into whether this can be fixed in
in their requirements file but forgot that and typed:
or, the other way around. That it was written as I don't know how hard or easy it would be but it certainly seems like a nice API that
Shall we? https://github.com/peterbe/hashin I don't mind reviewing a PR and discussing but I must admit that I'd struggle to find time to take the lead on it at the moment. |
@peterbe it’s a little different. The user has x_y in their requirements file and we run hashin x_y==1.0.1 but hashin appends x-y==1.0.1 to the file and leaves the existing x_y in place. |
My point is that if run I.e. |
@peterbe I can look into that with hashin. if I open an issue over there, do you have time to talk at me on how we want to implement it? From renovate's perspective i think it can continue to just use hashin. @rarkins hasn't added any special handling to the renovate code, just at the moment it behaves in such a way that it would append the hyphenated/underscored version if it didn't find the other. so i dont think renovate is really blocked here for anything. its just that we could enhance the behavior of hashin. thoughts? |
Yes indeed! I think the issue should be fairly straightforward. We basically want |
@peterbe going to open that issue right now. For the renovate specific usage of this though, should we block this feature until hashin adds the enhancement? Or would this just be a dependency that is updated/installed automatically when renovate runs. I noticed in @rarkins pr that it does a "pip install hashin". |
@rarkins while I wait for the PR I have open for review in hashin, I was curious about @peterbe's other remarks about Python version. For example, I have the following in a repo
I'm curious if there are any conventions that have been made in other managers to support manager specific options to trickle down to the manager, or if there is only a common set of options for all managers ( |
Mousing around the code, I think what I'm wondering about is specifying Artifact configuration. It does appear that some managers allow for that (I looked at bundler and composer), and that such options could provide input to hashin's However, these settings appear to apply to renovate's configuration, and not the configuration found in a source repo, is that correct? As such, one could configure renovate to apply "-p 3.7 -p 3.8" to all source repos with a pip_requirements manager specified, but the repo owner would be unable to control that configuration. Am I reading that correctly? |
We do have a precedent of attempting compatibility of language versions including python. So far this is for package managers that have a field for specifying the python version though. We have some precedent for package manager configuration options such as |
@peterbe and I have resolved the issue you were seeing in the appending of package names. It is available in hashin 0.15.0. At this point I would say it is acceptable to move forward on your draft implementation of hashes which you have linked in this issue. Let us know if there is anything else you need from us. |
🎉 This issue has been resolved in version 21.17.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What Renovate type are you using?
Renovate GitHub App (I think)
Describe the bug
See mozilla-services/tecken#1040
I have a project with renovate and by default Python support should be enabled but PRs on the
requirements.txt
is not being created.The
requirements.txt
definitely has a format that bothpip
andhashin
supports. Nothing weird there.To Reproduce
See above. :)
Expected behavior
More PRs for outdated Python packages in the the
requirements.txt
Additional context
Again; mozilla-services/tecken#1040 (comment)
The text was updated successfully, but these errors were encountered: