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

Normalized package names #81

Closed
LiquidLemon opened this issue Feb 14, 2022 · 2 comments
Closed

Normalized package names #81

LiquidLemon opened this issue Feb 14, 2022 · 2 comments

Comments

@LiquidLemon
Copy link

I'm using pip-tools which, as of recently, outputs normalized package names into my requirements.txt. All special characters are replaced with -. This is absolutely fine for pip but causes liccheck to fail.

$ liccheck -s strategy.ini
gathering licenses...
Traceback (most recent call last):
  File "/usr/local/bin/liccheck", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/liccheck/command_line.py", line 344, in main
    sys.exit(run(args))
  File "/usr/local/lib/python3.7/site-packages/liccheck/command_line.py", line 339, in run
    return process(args.requirement_txt_file, strategy, args.level, args.reporting_txt_file, args.no_deps)
  File "/usr/local/lib/python3.7/site-packages/liccheck/command_line.py", line 249, in process
    pkg_info = get_packages_info(requirement_file, no_deps)
  File "/usr/local/lib/python3.7/site-packages/liccheck/command_line.py", line 165, in get_packages_info
    packages = [transform(dist) for dist in resolve_func(requirements)]
  File "/usr/local/lib/python3.7/site-packages/liccheck/command_line.py", line 165, in <listcomp>
    packages = [transform(dist) for dist in resolve_func(requirements)]
  File "/usr/local/lib/python3.7/site-packages/liccheck/requirements.py", line 51, in resolve
    for dist in pkg_resources.working_set.resolve(requirements):
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 783, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'ruamel-yaml-clib==0.2.2' distribution was not found and is required by the application
$ pip freeze | grep clib
ruamel.yaml.clib==0.2.2

The canonical name for this package is ruamel.yaml.clib but my requirements.txt contains ruamel-yaml-clib. Is there any way to make liccheck work with these normalized names?

@craigds
Copy link

craigds commented Feb 22, 2022

We're having a very similar issue (though, a slightly different error) with the zope packages, which pip-tools 6.5.0+ (and thus dependabot) are now normalising from zope.interface to zope-interface. A minimal repro is:

python3 -m venv liccheck-test
. liccheck-test/bin/activate
pip install liccheck
echo 'zope-interface' > requirements.txt
pip install -r requirements.txt
echo '[Licenses]
authorized_licenses:
    zope public' > licenses.ini
liccheck -s licenses.ini -l cautious -r requirements.txt --no-deps

Which has the following output:

gathering licenses...
Traceback (most recent call last):
  File "/Users/cdestigter/liccheck-test/bin/liccheck", line 8, in <module>
    sys.exit(main())
  File "/Users/cdestigter/liccheck-test/lib/python3.9/site-packages/liccheck/command_line.py", line 344, in main
    sys.exit(run(args))
  File "/Users/cdestigter/liccheck-test/lib/python3.9/site-packages/liccheck/command_line.py", line 339, in run
    return process(args.requirement_txt_file, strategy, args.level, args.reporting_txt_file, args.no_deps)
  File "/Users/cdestigter/liccheck-test/lib/python3.9/site-packages/liccheck/command_line.py", line 249, in process
    pkg_info = get_packages_info(requirement_file, no_deps)
  File "/Users/cdestigter/liccheck-test/lib/python3.9/site-packages/liccheck/command_line.py", line 165, in get_packages_info
    packages = [transform(dist) for dist in resolve_func(requirements)]
  File "/Users/cdestigter/liccheck-test/lib/python3.9/site-packages/liccheck/command_line.py", line 165, in <listcomp>
    packages = [transform(dist) for dist in resolve_func(requirements)]
  File "/Users/cdestigter/liccheck-test/lib/python3.9/site-packages/liccheck/command_line.py", line 119, in transform
    licenses = get_licenses_from_classifiers(dist) or get_license(dist) or []
  File "/Users/cdestigter/liccheck-test/lib/python3.9/site-packages/liccheck/command_line.py", line 145, in get_licenses_from_classifiers
    if dist.has_metadata(dist.PKG_INFO):
AttributeError: 'NoneType' object has no attribute 'has_metadata'

@LiquidLemon
Copy link
Author

This has now been resolved upstream in setuptools (pypa/setuptools#3153) and is no longer an issue with setuptools >= 62.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants