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

Fix usage for source file without an extension. #488

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 1.9.0 (Unreleased)

- Fixed the default output file name when the source file has no extension ([#470](https://github.com/jazzband/pip-tools/issues/470))
- Added a `--max-rounds` argument to the pip-compile command to allow for solving large requirement sets ([#472](https://github.com/jazzband/pip-tools/pull/472))
- Exclude unsafe packages' dependencies when `--allow-unsafe` is not in use (#445)
- Exclude irrelevant pip constraints ([#471](https://github.com/jazzband/pip-tools/pull/471))
Expand Down
2 changes: 1 addition & 1 deletion piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def cli(verbose, dry_run, pre, rebuild, find_links, index_url, extra_index_url,
if output_file:
dst_file = output_file
else:
base_name, _, _ = src_files[0].rpartition('.')
base_name = src_files[0].rsplit('.', 1)[0]
dst_file = base_name + '.txt'

if upgrade and upgrade_packages:
Expand Down
18 changes: 18 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,21 @@ def test_editable_package(tmpdir):
assert out.exit_code == 0
assert fake_package_dir in out.output
assert 'six==1.10.0' in out.output


def test_input_file_without_extension(tmpdir):
"""
piptools can compile a file without an extension,
and add .txt as the defaut output file extension.
"""
runner = CliRunner()
with runner.isolated_filesystem():
with open('requirements', 'w') as req_in:
req_in.write('six==1.10.0')

out = runner.invoke(cli, ['-n', 'requirements'])

print(out.output)
assert out.exit_code == 0
assert '--output-file requirements.txt' in out.output
assert 'six==1.10.0' in out.output