From 481780f036428908262e9b7bf4e40974e436438e Mon Sep 17 00:00:00 2001 From: Ricardo Banffy Date: Mon, 22 Jan 2018 13:22:01 +0000 Subject: [PATCH 01/20] Version bump, fix import --- pip_chill/pip_chill.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pip_chill/pip_chill.py b/pip_chill/pip_chill.py index 5c7e48e..6bb10c5 100644 --- a/pip_chill/pip_chill.py +++ b/pip_chill/pip_chill.py @@ -3,7 +3,7 @@ import pip -from utils import Distribution +from pip_chill.utils import Distribution def chill(show_all=False): diff --git a/setup.py b/setup.py index 458679f..6122f1b 100755 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='pip-chill', - version='0.1.6', + version='0.1.7', description="Like `pip freeze` but lists only the packages that are not " "dependencies of installed packages.", long_description=readme + '\n\n' + history, From 31b869b4ebd74f038f2abc45bbfcfa7f4809deb2 Mon Sep 17 00:00:00 2001 From: Ricardo Banffy Date: Mon, 22 Jan 2018 14:17:15 +0000 Subject: [PATCH 02/20] Fix fixed import --- pip_chill/pip_chill.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pip_chill/pip_chill.py b/pip_chill/pip_chill.py index 6bb10c5..5c7e48e 100644 --- a/pip_chill/pip_chill.py +++ b/pip_chill/pip_chill.py @@ -3,7 +3,7 @@ import pip -from pip_chill.utils import Distribution +from utils import Distribution def chill(show_all=False): From af5bab5bf632f9c0eeabffac1ed5ec274611dc61 Mon Sep 17 00:00:00 2001 From: Ricardo Banffy Date: Mon, 22 Jan 2018 14:18:01 +0000 Subject: [PATCH 03/20] Update requirements * Luke Skibinski --- requirements_dev.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index b8246a4..c0bd8ca 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,8 +1,7 @@ -pip bumpversion -wheel -watchdog +click +coverage flake8 +sphinx tox -coverage -Sphinx +watchdog From 9d9fc0205724a31c7f58371bdebe6d15da23537b Mon Sep 17 00:00:00 2001 From: Ricardo Banffy Date: Mon, 22 Jan 2018 14:18:25 +0000 Subject: [PATCH 04/20] Update requirement inside setup.py - remove version pinning --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6122f1b..5ab2c71 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ history = history_file.read() requirements = [ - 'Click>=6.0', + 'click', ] test_requirements = [ From 85cf658ea62ad64c7a45178d0b4ee8fb55538922 Mon Sep 17 00:00:00 2001 From: Ricardo Banffy Date: Mon, 22 Jan 2018 14:19:06 +0000 Subject: [PATCH 05/20] Move to Python 3.6 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 4182a52..12b4684 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py35, flake8 +envlist = py27, py36, flake8 [testenv:flake8] basepython=python From 34bc8f955dbd025487746bb5d6e63f42be5e0b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 09:34:23 +0100 Subject: [PATCH 06/20] Import get_installed_distributions directly from inside pip --- pip_chill/pip_chill.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pip_chill/pip_chill.py b/pip_chill/pip_chill.py index 5c7e48e..8ba6377 100644 --- a/pip_chill/pip_chill.py +++ b/pip_chill/pip_chill.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Lists installed packages that are not dependencies of others""" -import pip +from pip._internal.utils.misc import get_installed_distributions from utils import Distribution @@ -17,7 +17,7 @@ def chill(show_all=False): distributions = {} dependencies = {} - for distribution in pip.get_installed_distributions(): + for distribution in get_installed_distributions(): if distribution.key in ignored_packages: continue From cab47b9a9c533b78168320b2b53df7a7b83d5032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 09:35:01 +0100 Subject: [PATCH 07/20] Move Distribution definition inside main module --- pip_chill/pip_chill.py | 32 +++++++++++++++++++++++++++++++- pip_chill/utils.py | 33 --------------------------------- 2 files changed, 31 insertions(+), 34 deletions(-) delete mode 100644 pip_chill/utils.py diff --git a/pip_chill/pip_chill.py b/pip_chill/pip_chill.py index 8ba6377..23d23e4 100644 --- a/pip_chill/pip_chill.py +++ b/pip_chill/pip_chill.py @@ -3,7 +3,37 @@ from pip._internal.utils.misc import get_installed_distributions -from utils import Distribution + +# from pip_chill.utils import Distribution +class Distribution: + def __init__(self, name, version=None, required_by=None): + self.name = name + self.version = version + self.required_by = set(required_by) if required_by else set() + + def get_name_without_version(self): + if self.required_by: + return '# {} # Installed as dependency for {}' \ + .format(self.name, ', '.join(self.required_by)) + return self.name + + def __str__(self): + if self.required_by: + return '# {}=={} # Installed as dependency for {}' \ + .format(self.name, self.version, ', '.join(self.required_by)) + return '{}=={}'.format(self.name, self.version) + + def __cmp__(self, other): + if isinstance(other, Distribution): + return self.name == other.name + + return self.name == other + + def __lt__(self, other): + return self.name < other.name + + def __hash__(self): + return self.name def chill(show_all=False): diff --git a/pip_chill/utils.py b/pip_chill/utils.py deleted file mode 100644 index 56e3691..0000000 --- a/pip_chill/utils.py +++ /dev/null @@ -1,33 +0,0 @@ -# #!/usr/local/bin/python -# # -*- coding: utf-8 -*- - - -class Distribution: - def __init__(self, name, version=None, required_by=None): - self.name = name - self.version = version - self.required_by = set(required_by) if required_by else set() - - def get_name_without_version(self): - if self.required_by: - return '# {} # Installed as dependency for {}' \ - .format(self.name, ', '.join(self.required_by)) - return self.name - - def __str__(self): - if self.required_by: - return '# {}=={} # Installed as dependency for {}' \ - .format(self.name, self.version, ', '.join(self.required_by)) - return '{}=={}'.format(self.name, self.version) - - def __cmp__(self, other): - if isinstance(other, Distribution): - return self.name == other.name - - return self.name == other - - def __lt__(self, other): - return self.name < other.name - - def __hash__(self): - return self.name From e4f888cad61b586f4f8c414f8e6c5c00f94ac2b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 09:36:16 +0100 Subject: [PATCH 08/20] No longer remove pip-chill from generated requirements --- pip_chill/pip_chill.py | 2 +- tests/test_pip_chill.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pip_chill/pip_chill.py b/pip_chill/pip_chill.py index 23d23e4..d8e8822 100644 --- a/pip_chill/pip_chill.py +++ b/pip_chill/pip_chill.py @@ -41,7 +41,7 @@ def chill(show_all=False): ignored_packages = () else: ignored_packages = { - 'pip', 'pip-chill', 'wheel', 'setuptools', 'pkg-resources'} + 'pip', 'wheel', 'setuptools', 'pkg-resources'} # Gather all packages that are requirements and will be auto-installed. distributions = {} diff --git a/tests/test_pip_chill.py b/tests/test_pip_chill.py index ec26aa3..2e53a50 100644 --- a/tests/test_pip_chill.py +++ b/tests/test_pip_chill.py @@ -27,7 +27,7 @@ def tearDown(self): def test_pip_ommitted(self): packages, _ = pip_chill.chill() - hidden = {'pip-chill', 'wheel', 'setuptools', 'pip'} + hidden = {'wheel', 'setuptools', 'pip'} for package in packages: assert package.name not in hidden @@ -56,8 +56,10 @@ def test_command_line_interface_omits_ignored(self): runner = CliRunner() result = runner.invoke(cli.main) assert result.exit_code == 0 - for package in ['pip-chill', 'wheel', 'setuptools', 'pip']: - assert package not in result.output + for package in ['wheel', 'setuptools', 'pip']: + assert not any( + [p.startswith(package + '==') + for p in result.output.split('\n')]) def test_command_line_interface_all(self): runner = CliRunner() From 50fb55b388eaaab1da060763a7c85d3565f9c6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 09:38:41 +0100 Subject: [PATCH 09/20] Remove support for Python 3.3, add support for 3.6 and 3.7 --- setup.py | 3 ++- tox.ini | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 5ab2c71..9b23ec9 100755 --- a/setup.py +++ b/setup.py @@ -50,9 +50,10 @@ "Programming Language :: Python :: 2", 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', ], test_suite='tests', tests_require=test_requirements diff --git a/tox.ini b/tox.ini index 12b4684..1456d32 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py36, flake8 +envlist = py27, py34, py35, py36, py37, flake8 [testenv:flake8] basepython=python From 965acf6705315fb2ff4fb3d6961123ed4ea17b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 09:40:12 +0100 Subject: [PATCH 10/20] Add folders to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c400888..0d67194 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,8 @@ target/ .venv .venv3 .env +env2 # Others cache +.pytest_cache From c0a2c64be1dad354662be75ed2fe3c6a8924f025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 14:13:48 +0100 Subject: [PATCH 11/20] Proper comparison tests --- pip_chill/pip_chill.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pip_chill/pip_chill.py b/pip_chill/pip_chill.py index d8e8822..f4dbbd6 100644 --- a/pip_chill/pip_chill.py +++ b/pip_chill/pip_chill.py @@ -23,17 +23,19 @@ def __str__(self): .format(self.name, self.version, ', '.join(self.required_by)) return '{}=={}'.format(self.name, self.version) - def __cmp__(self, other): - if isinstance(other, Distribution): - return self.name == other.name - - return self.name == other + def __eq__(self, other): + if self is other: + return True + elif isinstance(other, Distribution): + return True if self.name == other.name else False + else: + return True if self.name == other else False def __lt__(self, other): return self.name < other.name def __hash__(self): - return self.name + return hash(self.name) def chill(show_all=False): From 16663bb80f909992bc758f2e82e091a0c1b902d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 14:14:45 +0100 Subject: [PATCH 12/20] Add extra tests for the comparison operators --- tests/test_pip_chill.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/test_pip_chill.py b/tests/test_pip_chill.py index 2e53a50..4f1b3a2 100644 --- a/tests/test_pip_chill.py +++ b/tests/test_pip_chill.py @@ -13,14 +13,19 @@ import unittest from click.testing import CliRunner -from pip_chill import pip_chill -from pip_chill import cli +from pip_chill import ( + pip_chill, + cli, + ) +from pip_chill.pip_chill import Distribution class TestPip_chill(unittest.TestCase): def setUp(self): - pass + self.distribution_1 = Distribution('pip-chill', '2.0.0', []) + self.distribution_2 = Distribution('pip', '10.0.0', [self.distribution_1]) + self.distribution_3 = Distribution('pip', '11.0.0', [self.distribution_1]) def tearDown(self): pass @@ -37,6 +42,17 @@ def test_all(self): for package in ['wheel', 'pip']: assert package in package_names + def test_hashes(self): + packages, _ = pip_chill.chill() + for package in packages: + assert hash(package) == hash(package.name) + + def test_equality(self): + assert self.distribution_1 != self.distribution_2 + assert self.distribution_1 == self.distribution_1 + assert self.distribution_2 == self.distribution_3 + assert self.distribution_2 == self.distribution_2.name + def test_command_line_interface_help(self): runner = CliRunner() result = runner.invoke(cli.main, ['--help']) From c41800a38656ec17c689ad423c2a0d1ad46e382c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 14:15:14 +0100 Subject: [PATCH 13/20] Test command line verbose options --- tests/test_pip_chill.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_pip_chill.py b/tests/test_pip_chill.py index 4f1b3a2..2e47333 100644 --- a/tests/test_pip_chill.py +++ b/tests/test_pip_chill.py @@ -68,6 +68,19 @@ def test_command_line_interface_no_version(self): assert result.exit_code == 0 assert '==' not in result.output + def test_command_line_interface_verbose(self): + runner = CliRunner() + result = runner.invoke(cli.main, ['--verbose']) + assert result.exit_code == 0 + assert '# Installed as dependency for' in result.output + + def test_command_line_interface_verbose_no_version(self): + runner = CliRunner() + result = runner.invoke(cli.main, ['--verbose', '--no-version']) + assert result.exit_code == 0 + assert '==' not in result.output + assert '# Installed as dependency for' in result.output + def test_command_line_interface_omits_ignored(self): runner = CliRunner() result = runner.invoke(cli.main) From dffe389d0a371fd36d80d04d83680071e4daf061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 14:15:31 +0100 Subject: [PATCH 14/20] Enable test targets on Makefile --- Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 8d34cf9..566efc6 100644 --- a/Makefile +++ b/Makefile @@ -50,15 +50,13 @@ clean-test: ## remove test and coverage artifacts lint: ## check style with flake8 flake8 pip_chill tests -# test: ## run tests quickly with the default Python +test: ## run tests quickly with the default Python + python setup.py test -# python setup.py test - -# test-all: ## run tests on every Python version with tox -# tox +test-all: ## run tests on every Python version with tox + tox coverage: ## check code coverage quickly with the default Python - coverage run --source pip_chill setup.py test coverage report -m coverage html From 9150f537d8c9c7132c75549dff41500d2adb3d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 14:16:18 +0100 Subject: [PATCH 15/20] Add dependencies for Tox tests --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 1456d32..219f9e5 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ commands=flake8 pip_chill [testenv] setenv = PYTHONPATH = {toxinidir}:{toxinidir}/pip_chill +deps = -rrequirements_dev.txt commands = python setup.py test From f926e550c1558c0a4153c5a6e1a2292a31310fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 14:16:42 +0100 Subject: [PATCH 16/20] Version bump --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 20f5009..47acce9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.7 +current_version = 0.1.8 commit = True tag = True From 746378236b1d56c7d9eb94f4432835f343343699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 14:27:09 +0100 Subject: [PATCH 17/20] Updated Travis config (removed 3.3, PyPy*, added 3.7 --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9bd41e3..4e810be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,11 @@ language: python python: - "2.7" - - "3.3" - "3.4" - "3.5" - "3.6" + - "3.7" - "nightly" - - "pypy" - - "pypy3" # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: pip install tox-travis From f5910c386519dada31abf0290d35f5b21bfa2b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 14:29:06 +0100 Subject: [PATCH 18/20] Travis doesn't like 3.7 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4e810be..df6796c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ python: - "3.4" - "3.5" - "3.6" - - "3.7" - "nightly" # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors From 5effc49cf6f98317bf024f026379eef524f7895c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 14:37:33 +0100 Subject: [PATCH 19/20] Remove comment (we are already adding deps to the test environment) --- tox.ini | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tox.ini b/tox.ini index 219f9e5..c1dd9a2 100644 --- a/tox.ini +++ b/tox.ini @@ -12,8 +12,3 @@ setenv = deps = -rrequirements_dev.txt commands = python setup.py test - -; If you want to make tox run the tests with the same versions, create a -; requirements.txt with the pinned versions and uncomment the following lines: -; deps = -; -r{toxinidir}/requirements.txt From 0c126ce2e6f7b97dc4ccd9b1ea5d940efa1eaa97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 20 Aug 2018 15:37:43 +0100 Subject: [PATCH 20/20] Version bump to 0.1.8, solves #11, solves #12, solves #14 --- HISTORY.rst | 5 +++++ pip_chill/__init__.py | 2 +- setup.cfg | 1 + setup.py | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 2b22352..5eeaa05 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,11 @@ History ======= +0.1.8 (2018-08-20) +------------------ + +* Fixes, compatibility with Python 2.7, 3.6, 3.7 + 0.1.7 (2018-01-22) ------------------ diff --git a/pip_chill/__init__.py b/pip_chill/__init__.py index 20273a5..3c58c95 100644 --- a/pip_chill/__init__.py +++ b/pip_chill/__init__.py @@ -4,6 +4,6 @@ __author__ = 'Ricardo Bánffy' __email__ = 'rbanffy@gmail.com' -__version__ = '0.1.3' +__version__ = '0.1.8' __all__ = [chill] diff --git a/setup.cfg b/setup.cfg index 47acce9..971df29 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,3 +16,4 @@ universal = 1 [flake8] exclude = docs + diff --git a/setup.py b/setup.py index 9b23ec9..e61cb13 100755 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='pip-chill', - version='0.1.7', + version='0.1.8', description="Like `pip freeze` but lists only the packages that are not " "dependencies of installed packages.", long_description=readme + '\n\n' + history,