Skip to content

Commit

Permalink
Merge pull request #4439 from NicolasT/pip-compile-strip-extras
Browse files Browse the repository at this point in the history
Python: Honour `--strip-extras` flag of `pip-compile`
  • Loading branch information
jurre authored Nov 23, 2021
2 parents 26264e5 + 2cf1980 commit 4af1cd4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ def pip_compile_options_from_compiled_file(requirements_file)
options << "--no-header" unless requirements_file.content.include?("autogenerated by pip-c")

options << "--pre" if requirements_file.content.include?("--pre")

options << "--strip-extras" if requirements_file.content.include?("--strip-extras")

options
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,5 +505,21 @@
end
end
end

context "with stripped extras" do
let(:manifest_fixture_name) { "strip_extras.in" }
let(:generated_fixture_name) { "pip_compile_strip_extras.txt" }
let(:dependency_name) { "cachecontrol" }
let(:dependency_version) { "0.12.10" }
let(:dependency_previous_version) { "0.12.9" }

it "doesn't add an extras annotation on cachecontrol" do
expect(updated_files.count).to eq(1)
expect(updated_files.first.content).to include("--strip-extras")
expect(updated_files.first.content).to include("cachecontrol==0.12.10")
expect(updated_files.first.content).
to_not include("cachecontrol[filecache]==")
end
end
end
end
1 change: 1 addition & 0 deletions python/spec/fixtures/pip_compile_files/strip_extras.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cachecontrol[filecache]
22 changes: 22 additions & 0 deletions python/spec/fixtures/requirements/pip_compile_strip_extras.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
#
# pip-compile --strip-extras --output-file=constraints.txt constraints.in
#
cachecontrol==0.12.10
# via -r constraints.in
certifi==2021.10.8
# via requests
charset-normalizer==2.0.7
# via requests
idna==3.3
# via requests
lockfile==0.12.2
# via cachecontrol
msgpack==1.0.2
# via cachecontrol
requests==2.26.0
# via cachecontrol
urllib3==1.26.7
# via requests

0 comments on commit 4af1cd4

Please sign in to comment.