mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
pipreqs: handle everything in lower-case
We can handle all package names in lowercase, since pip is case insensitive, see PEP-426 (https://peps.python.org/pep-0426/#name).
This commit is contained in:
parent
b3d0b4443b
commit
f0965d7aa9
@ -164,6 +164,7 @@ def get_all_imports(path, encoding="utf-8", extra_ignore_dirs=None, follow_links
|
|||||||
imports.add(cleaned_name)
|
imports.add(cleaned_name)
|
||||||
|
|
||||||
packages = imports - (set(candidates) & imports)
|
packages = imports - (set(candidates) & imports)
|
||||||
|
packages = {p.lower() for p in packages}
|
||||||
logging.debug("Found packages: {0}".format(packages))
|
logging.debug("Found packages: {0}".format(packages))
|
||||||
|
|
||||||
with open(join("stdlib"), "r") as f:
|
with open(join("stdlib"), "r") as f:
|
||||||
@ -283,7 +284,7 @@ def get_locally_installed_packages(encoding="utf-8"):
|
|||||||
for module in top_level_modules:
|
for module in top_level_modules:
|
||||||
if (module not in ignore) and (package[0] not in ignore):
|
if (module not in ignore) and (package[0] not in ignore):
|
||||||
# append exported top level modules to the list
|
# append exported top level modules to the list
|
||||||
filtered_top_level_modules.append(module)
|
filtered_top_level_modules.append(module.lower())
|
||||||
|
|
||||||
version = None
|
version = None
|
||||||
if len(package) > 1:
|
if len(package) > 1:
|
||||||
@ -293,7 +294,7 @@ def get_locally_installed_packages(encoding="utf-8"):
|
|||||||
# instead of top_level_module: package pairs
|
# instead of top_level_module: package pairs
|
||||||
packages.append(
|
packages.append(
|
||||||
{
|
{
|
||||||
"name": package[0],
|
"name": package[0].lower(),
|
||||||
"version": version,
|
"version": version,
|
||||||
"exports": filtered_top_level_modules,
|
"exports": filtered_top_level_modules,
|
||||||
}
|
}
|
||||||
@ -338,7 +339,7 @@ def get_pkg_names(pkgs):
|
|||||||
for pkg in pkgs:
|
for pkg in pkgs:
|
||||||
# Look up the mapped requirement. If a mapping isn't found,
|
# Look up the mapped requirement. If a mapping isn't found,
|
||||||
# simply use the package name.
|
# simply use the package name.
|
||||||
result.add(data.get(pkg, pkg))
|
result.add(data.get(pkg, pkg).lower())
|
||||||
# Return a sorted list for backward compatibility.
|
# Return a sorted list for backward compatibility.
|
||||||
return sorted(result, key=lambda s: s.lower())
|
return sorted(result, key=lambda s: s.lower())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user