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

Ignore installed external packages #61

Merged
merged 2 commits into from Jul 25, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions HISTORY.rst
Expand Up @@ -5,6 +5,8 @@ History

.. New release notes go here

* Ignore installed external (``-e``) packages.

1.1.1 (2018-04-15)
------------------

Expand Down
7 changes: 5 additions & 2 deletions pip_lock.py
Expand Up @@ -30,7 +30,7 @@ def read_pip(filename):
return lines


def get_package_versions(lines):
def get_package_versions(lines, ignore_external=False):
"""Return a dictionary of package versions."""
versions = {}
for line in lines:
Expand All @@ -42,6 +42,9 @@ def get_package_versions(lines):
if line.startswith('https://'):
continue

if ignore_external and line.startswith('-e'):
continue

name, version_plus = line.split('==', 1)
versions[name.lower()] = version_plus.split(' ', 1)[0]

Expand All @@ -53,7 +56,7 @@ def get_mismatches(requirements_file_path):
pip_lines = read_pip(requirements_file_path)

expected = get_package_versions(pip_lines)
actual = get_package_versions(pip_freeze())
actual = get_package_versions(pip_freeze(), ignore_external=True)

mismatches = {}
for name, version in expected.items():
Expand Down
10 changes: 10 additions & 0 deletions tests/test_pip_lock.py
Expand Up @@ -104,6 +104,16 @@ def test_empty(self, pip_freeze, tmpdir):

assert get_mismatches(requirements_path) == {}

@patch('pip_lock.pip_freeze')
def test_editable_packages(self, pip_freeze, tmpdir):
pip_freeze.return_value = [
'-e git+git@github.com:YPlan/pip-lock.git@efac0eef8072d73b001b1bae0731c1d58790ac4b#egg=pip-lock',
'package==1.1',
]
requirements_path = create_file(tmpdir, 'requirements.txt', 'package==1.1')

assert get_mismatches(requirements_path) == {}


class TestPrintErrors(object):

Expand Down