Skip to content
Snippets Groups Projects
Commit d3a5400a authored by Marek Chrastina's avatar Marek Chrastina
Browse files

Add exclude argument

parent aa672d5d
Branches
Tags
1 merge request!7If only bdist is available, check if python_version satisfied python platform version
Pipeline #11105 failed
......@@ -15,13 +15,18 @@ situations. Currently, package extras are not finished.
```console
$ pipdeps --help
usage: pipdeps [-h] (-l | -t | -u | -s [SHOW [SHOW ...]])
usage: pipdeps [-h] [-e [EXCLUDE [EXCLUDE ...]]]
(-l | -t | -u | -s [SHOW [SHOW ...]])
Pipdeps shows/upgrades outdated packages with respect to existing
dependencies.
optional arguments:
-h, --help show this help message and exit
-e [EXCLUDE [EXCLUDE ...]], --exclude [EXCLUDE [EXCLUDE ...]]
Comma separated list of excluded package (and
version). Format package==version or package for all
versions
-l, --list show list of upgradeable packages and versions
-t, --table show table of upgradeable packages and versions
-u, --upgrade upgrade upgradeable packages
......
......@@ -39,6 +39,10 @@ def arg_parse():
description="Pipdeps shows/upgrades outdated packages with respect to existing \
dependencies."
)
parser.add_argument('-e', '--exclude',
nargs='*',
help="Space-separated list of excluded package (and version). \
Format package==version or package for all versions")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-l', '--list',
action='store_true',
......@@ -54,6 +58,14 @@ def arg_parse():
help="show detailed info about upgradeable packages")
return parser.parse_args()
def get_excludes(data):
"""
Parse argument excludes into array of (pkg, ver)
"""
if data is None:
return []
return [pkg.split("==") for pkg in data]
def upgrade_package(data):
"""
pip install --upgrade "<package>==<versions>"
......@@ -645,6 +657,33 @@ def get_hards(data, package_no_news):
'extras': list(set(extras))}
return out
def del_excls(data, excludes):
"""
Return list of packages and their versions that are excluded by argument
"""
to_delete = []
_package_no_news, package_with_news = single_multi(data)
package_not_installed = not_installed(data)
for exc in excludes:
try:
exc_pkg, exc_ver = exc[0], exc[1]
except IndexError:
exc_pkg, exc_ver = exc[0], None
if exc_pkg not in package_with_news+package_not_installed:
print "Warning! Excluded package {} has no upgrades. Ignoring".format(exc_pkg)
continue
vers = [ver for ver, _ver_data in data[exc_pkg]['new_version'].iteritems()]
if exc_ver is not None and exc_ver not in vers:
print "Warning! Excluded package {}=={} is not upgradable. Ignoring".format(exc_pkg,
exc_ver)
continue
if exc_ver is None:
for ver in vers:
to_delete.append((exc_pkg, ver))
else:
to_delete.append((exc_pkg, exc_ver))
return to_delete
def del_hards(data):
"""
Return list of packages and their versions that does not satisfy
......@@ -1110,7 +1149,9 @@ def main():
"""
os.environ["PYTHONWARNINGS"] = "ignore:DEPRECATION"
arguments = arg_parse()
excludes = get_excludes(arguments.exclude)
packages_data = get_pkg_data()
packages_data = move_incompatible(packages_data, del_excls(packages_data, excludes))
packages_data = first_loop(packages_data)
i_branch = ibranch(packages_data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment