Skip to content

Commit

Permalink
Merge pull request #110 from sbidoul/named-editable-sbi
Browse files Browse the repository at this point in the history
Support named editable requirements in contraint files
  • Loading branch information
sbidoul authored Sep 1, 2023
2 parents a43a24c + 0b3e44d commit 26e51ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions news/110.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Support named editable requirements in constraint files (requirements.txt.in)
and lock files (requirements*.txt).
6 changes: 3 additions & 3 deletions src/pip_deepfreeze/req_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def prepare_frozen_reqs_for_upgrade(
if not req_name:
log_error(f"Ignoring unnamed constraint {in_req.raw_line!r}.")
continue
in_reqs.append((req_name, in_req.requirement))
in_reqs.append((req_name, in_req))
# 2. emit frozen_reqs unless upgrade_all or it is in to_upgrade
for frozen_filename in frozen_filenames:
if frozen_filename.is_file() and not upgrade_all:
Expand All @@ -61,6 +61,6 @@ def prepare_frozen_reqs_for_upgrade(
frozen_reqs.add(req_name)
yield frozen_req.requirement
# 3. emit in_reqs that have not been emitted as frozen reqs
for req_name, in_req_str in in_reqs:
for req_name, in_req in in_reqs:
if req_name not in frozen_reqs:
yield in_req_str
yield in_req.raw_line
11 changes: 11 additions & 0 deletions tests/test_req_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,14 @@ def test_req_merge_unnamed_frozen(tmp_path, capsys):
assert set(prepare_frozen_reqs_for_upgrade([frozen_filename], in_filename)) == set()
captured = capsys.readouterr()
assert "Ignoring unnamed frozen requirement '-e .'" in captured.err


def test_req_merge_named_editable(tmp_path):
in_filename = tmp_path / "requirements.txt.in"
in_filename.write_text(
"-e git+https://github.com/pypa/pip-test-package#egg=pip-test-package"
)
frozen_filename = tmp_path / "requirements.txt"
assert set(prepare_frozen_reqs_for_upgrade([frozen_filename], in_filename)) == set(
["-e git+https://github.com/pypa/pip-test-package#egg=pip-test-package"]
)

0 comments on commit 26e51ea

Please sign in to comment.