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

adjusting where inconsistency is set. if we are inconsistent, but the… #7152

Merged
merged 6 commits into from
Sep 10, 2019
Merged
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
54 changes: 31 additions & 23 deletions scripts/analyze_deps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
from __future__ import print_function, unicode_literals
import argparse
import ast
from datetime import datetime
Expand Down Expand Up @@ -183,21 +183,24 @@ def render_report(output_path, report_context):
packages, dependencies = get_lib_deps(base_dir)

if args.verbose:
print('Packages analyzed:')
print('Packages analyzed')
print('=================')
for package in sorted(packages.keys()):
info = packages[package]
print("%s %s" % (package, info['version']))
print(" from %s" % (info['source']))

print('\n\nRequirements discovered:')
print('\n\nRequirements discovered')
print('=======================')
for requirement in sorted(dependencies.keys()):
specs = dependencies[requirement]
libs = []
print('\n%s' % (requirement))
print('%s' % (requirement))
for spec in specs.keys():
print('%s' % (spec if spec else '(empty)'))
for lib in specs[spec]:
print(' * %s' % (lib))
print('')

inconsistent = []
for requirement in sorted(dependencies.keys()):
Expand All @@ -206,32 +209,27 @@ def render_report(output_path, report_context):
if num_specs == 1:
continue

if not inconsistent and args.verbose:
print('\nInconsistencies detected')
print('========================')

inconsistent.append(requirement)
if args.verbose:
print("\n\nRequirement '%s' has %s unique specifiers:" % (requirement, num_specs))
print("Requirement '%s' has %s unique specifiers:" % (requirement, num_specs))
for spec in sorted(specs.keys()):
libs = specs[spec]
friendly_spec = '(none)' if spec == '' else spec
print("\n '%s'" % (friendly_spec))
print(" '%s'" % (friendly_spec))
print(' ' + ('-' * (len(friendly_spec) + 2)))
for lib in sorted(libs):
print(' * %s' % (lib))

exitcode = 0
if inconsistent:
if not args.verbose:
print('\n\nIncompatible dependency versions detected in libraries, run this script with --verbose for details')
else:
print('\n')
exitcode = 1
else:
print('\n\nAll library dependencies verified, no incompatible versions detected')
print('')

frozen_filename = os.path.join(base_dir, 'shared_requirements.txt')
if args.freeze:
if exitcode != 0:
if inconsistent:
print('Unable to freeze requirements due to incompatible dependency versions')
sys.exit(exitcode)
sys.exit(1)
else:
with io.open(frozen_filename, 'w', encoding='utf-8') as frozen_file:
for requirement in sorted(dependencies.keys()):
Expand Down Expand Up @@ -260,6 +258,7 @@ def render_report(output_path, report_context):

missing_reqs, new_reqs, changed_reqs = {}, {}, {}
non_overridden_reqs_count = 0
exitcode = 0
if frozen:
flat_deps = {req: sorted(dependencies[req].keys()) for req in dependencies}
missing_reqs, new_reqs, changed_reqs = dict_compare(frozen, flat_deps)
Expand Down Expand Up @@ -302,6 +301,20 @@ def render_report(output_path, report_context):
print("\nThe following libraries declare requirement '%s' which does not match the frozen requirement '%s':" % (changed_req + spec, changed_req + frozen_specs[0]))
for lib in non_overridden_libs:
print(" * %s" % (lib))
if exitcode == 0:
if args.verbose:
print('')
print('All library dependencies validated against frozen requirements')
elif not args.verbose:
print('Library dependencies do not match frozen requirements, run this script with --verbose for details')
elif inconsistent:
exitcode = 1

if exitcode == 1:
if not args.verbose:
print('\nIncompatible dependency versions detected in libraries, run this script with --verbose for details')
else:
print('\nAll library dependencies verified, no incompatible versions detected')

if args.out:
external = [k for k in dependencies if k not in packages and not should_skip_lib(k)]
Expand Down Expand Up @@ -329,9 +342,4 @@ def display_order(k):
'repo_name': 'azure-sdk-for-python'
})

if exitcode == 0:
print('All library dependencies validated against frozen requirements')
elif not args.verbose:
print('Library dependencies do not match frozen requirements, run this script with --verbose for details')

sys.exit(exitcode)