Skip to content

Commit

Permalink
Added a --no-chill option (#36)
Browse files Browse the repository at this point in the history
* Bump version to 1.0.1

* Fix failing Flake8 test

* Update history

* Add --no-chill command line option. Fixes #34

* Remove click and add black to the requirements file

* Version update

* Remove black - not a dev requirement

* 'Refactored by Sourcery' (#37)

Co-authored-by: Sourcery AI <>

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
rbanffy and sourcery-ai[bot] authored Jan 18, 2021
1 parent 42fd692 commit 6d33071
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
5 changes: 3 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
History
=======

current
-------
1.0.1 (2021-01-18)
------------------

* Add `no-chill` option so that pip-chill is not shown as installed
* Do Linux tests on Focal where possible (2.7 and 3.7 on ppc64le and s390x, 2.7 on arm64 run Bionic)
* Fix wrong URLs in CONTRIBUTING.rst
* Add 3.7, 3.8, 3.9 to ppc64le and s390x, 3.10-dev to Linux, macOS
Expand Down
10 changes: 9 additions & 1 deletion pip_chill/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def main():
dest="no_version",
help="omit version numbers.",
)
parser.add_argument(
"--no-chill",
action="store_true",
dest="no_chill",
help="don't show installed pip-chill.",
)
parser.add_argument(
"-a",
"--all",
Expand All @@ -37,7 +43,9 @@ def main():
)
args = parser.parse_args()

distributions, dependencies = pip_chill.chill(show_all=args.show_all)
distributions, dependencies = pip_chill.chill(
show_all=args.show_all, no_chill=args.no_chill
)
for package in distributions:
if args.no_version:
print(package.get_name_without_version())
Expand Down
5 changes: 4 additions & 1 deletion pip_chill/pip_chill.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ def __hash__(self):
return hash(self.name)


def chill(show_all=False):
def chill(show_all=False, no_chill=False):
if show_all:
ignored_packages = ()
else:
ignored_packages = {"pip", "wheel", "setuptools", "pkg-resources"}

if no_chill:
ignored_packages.add("pip-chill")

# Gather all packages that are requirements and will be auto-installed.
distributions = {}
dependencies = {}
Expand Down
1 change: 0 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
bandit
bumpversion
click
coverage
flake8
nose
Expand Down
13 changes: 10 additions & 3 deletions tests/test_pip_chill.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ def test_command_line_interface_omits_ignored(self):

result = os.popen(command).read()
for package in ["wheel", "setuptools", "pip"]:
self.assertFalse(
any([p.startswith(package + "==") for p in result.split("\n")])
)
self.assertFalse(any(p.startswith(package + "==") for p in result.split("\n")))

def test_command_line_interface_all(self):
command = "pip_chill/cli.py --all"
Expand Down Expand Up @@ -144,6 +142,15 @@ def test_command_line_interface_long_all(self):
for package in ["pip-chill", "pip"]:
self.assertIn(package, result)

def test_command_line_interface_no_chill(self):
command = "pip_chill/cli.py --no-chill"

returncode = os.system(command)
self.assertEqual(returncode, 0)

result = os.popen(command).read()
self.assertNotIn("pip-chill", result)

def test_command_line_invalid_option(self):
command = "pip_chill/cli.py --invalid-option"

Expand Down

0 comments on commit 6d33071

Please sign in to comment.