-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Followup from #10040 - Support uv compiled requirements files #10688
Open
imajes
wants to merge
19
commits into
dependabot:main
Choose a base branch
from
imajes:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
bc29be7
Support python uv as pip-compile compatible replacement
avilaton 823600b
Update requirements.txt
avilaton 6fbb577
Update python/helpers/requirements.txt
avilaton 94bb96b
Update python/spec/fixtures/requirements/pip_compile_uv_header.txt
avilaton 2a63fb6
Bump uv. New uv_pip_compile_options_from_compiled_file method and big…
albertferras-vrf 1fef8ee
Update python/helpers/requirements.txt
avilaton 703cbe4
Update python/lib/dependabot/python/file_updater/pip_compile_file_upd…
avilaton 408fcef
Update python/lib/dependabot/python/file_updater/pip_compile_file_upd…
avilaton a5ec78a
Rename uv_pip_compile_file_updater_spec.rb to pip_compile_file_update…
avilaton 26caba4
Update python/lib/dependabot/python/file_updater/pip_compile_file_upd…
avilaton e1913f0
Update python/lib/dependabot/python/file_updater/pip_compile_file_upd…
avilaton a659f80
Update python/lib/dependabot/python/file_updater/pip_compile_file_upd…
avilaton 5f26e1e
Update python/helpers/requirements.txt
avilaton f31dc26
Update python/lib/dependabot/python/update_checker/pip_compile_versio…
avilaton 0d7312e
Update pip_compile_version_resolver.rb
avilaton 03d0ef9
Add missing functions
avilaton ee616b2
Remove legacy pip stuff I don't mean to mess with
avilaton 8101dde
[BUGFIX] Resolve missing regex const definition
imajes fa5519d
[BUGFIX] Update as per comments from RazerM
imajes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ class PipCompileVersionResolver | |
PYTHON_PACKAGE_NAME_REGEX = /[A-Za-z0-9_\-]+/ | ||
RESOLUTION_IMPOSSIBLE_ERROR = "ResolutionImpossible" | ||
ERROR_REGEX = /(?<=ERROR\:\W).*$/ | ||
RESOLVER_REGEX = /(?<=--resolver=)(\w+)/ | ||
|
||
attr_reader :dependency | ||
attr_reader :dependency_files | ||
|
@@ -91,12 +92,12 @@ def fetch_latest_resolvable_version_string(requirement:) | |
def compile_file(filename) | ||
# Shell out to pip-compile. | ||
# This is slow, as pip-compile needs to do installs. | ||
options = pip_compile_options(filename) | ||
options, command = pip_compile_options(filename) | ||
options_fingerprint = pip_compile_options_fingerprint(options) | ||
|
||
run_pip_compile_command( | ||
"pyenv exec pip-compile -v #{options} -P #{dependency.name} #{filename}", | ||
fingerprint: "pyenv exec pip-compile -v #{options_fingerprint} -P <dependency_name> <filename>" | ||
"#{command} -v #{options} -P #{dependency.name} #{filename}", | ||
fingerprint: "#{command} -v #{options_fingerprint} -P <dependency_name> <filename>" | ||
) | ||
|
||
return true if dependency.top_level? | ||
|
@@ -110,8 +111,8 @@ def compile_file(filename) | |
# update_not_possible. | ||
write_original_manifest_files | ||
run_pip_compile_command( | ||
"pyenv exec pip-compile #{options} #{filename}", | ||
fingerprint: "pyenv exec pip-compile #{options_fingerprint} <filename>" | ||
"#{command} #{options} #{filename}", | ||
fingerprint: "#{command} #{options_fingerprint} <filename>" | ||
) | ||
|
||
true | ||
|
@@ -201,12 +202,12 @@ def check_original_requirements_resolvable | |
write_temporary_dependency_files(update_requirement: false) | ||
|
||
filenames_to_compile.each do |filename| | ||
options = pip_compile_options(filename) | ||
options, command = pip_compile_options(filename) | ||
options_fingerprint = pip_compile_options_fingerprint(options) | ||
|
||
run_pip_compile_command( | ||
"pyenv exec pip-compile #{options} #{filename}", | ||
fingerprint: "pyenv exec pip-compile #{options_fingerprint} <filename>" | ||
"#{command} #{options} #{filename}", | ||
fingerprint: "#{command} #{options_fingerprint} <filename>" | ||
) | ||
end | ||
|
||
|
@@ -251,7 +252,16 @@ def pip_compile_options(filename) | |
options << "--output-file=#{requirements_file.name}" | ||
end | ||
|
||
options.join(" ") | ||
if (requirements_file = compiled_file_for_filename(filename)) | ||
if requirements_file.content.include?("uv pip compile") | ||
options += uv_pip_compile_options_from_compiled_file(requirements_file) | ||
command = "pyenv exec uv pip compile" | ||
else | ||
command = "pyenv exec pip-compile" | ||
end | ||
end | ||
|
||
[options.join(" "), command] | ||
end | ||
|
||
def pip_compile_index_options | ||
|
@@ -277,6 +287,32 @@ def run_pip_compile_command(command, fingerprint:) | |
run_command(command, fingerprint: fingerprint) | ||
end | ||
|
||
def uv_pip_compile_options_from_compiled_file(requirements_file) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this implementation needs to be updated to match the one in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gotcha |
||
options = ["--output-file=#{requirements_file.name}"] | ||
|
||
options << "--no-emit-index-url" unless requirements_file.content.include?("index-url http") | ||
|
||
options << "--generate-hashes" if requirements_file.content.include?("--hash=sha") | ||
|
||
options << "--no-annotate" unless requirements_file.content.include?("# via ") | ||
|
||
options << "--pre" if requirements_file.content.include?("--pre") | ||
|
||
options << "--no-strip-extras" if requirements_file.content.include?("--no-strip-extras") | ||
|
||
if requirements_file.content.include?("--no-binary") || requirements_file.content.include?("--only-binary") | ||
options << "--emit-build-options" | ||
end | ||
|
||
if (resolver = RESOLVER_REGEX.match(requirements_file.content)) | ||
options << "--resolver=#{resolver}" | ||
end | ||
|
||
options << "--universal" if requirements_file.content.include?("--universal") | ||
|
||
options | ||
end | ||
|
||
def python_env | ||
env = {} | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would cause dependabot to strip an existing index-url.
see #10040 (comment)
probably needs a test generated with
--emit-index-url
to make sure dependabot doesn't remove itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah good catch!