mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-07 03:55:22 +00:00
fix(pipreqs): fix package import names (case sensitive)
This commit is contained in:
parent
a0c796bc6b
commit
f2024cbc40
@ -62,7 +62,7 @@ def get_all_imports(start_path):
|
|||||||
'Found third-party packages: {0}'.format(third_party_packages))
|
'Found third-party packages: {0}'.format(third_party_packages))
|
||||||
with open(os.path.join(os.path.dirname(__file__), "stdlib"), "r") as f:
|
with open(os.path.join(os.path.dirname(__file__), "stdlib"), "r") as f:
|
||||||
data = [x.strip() for x in f.readlines()]
|
data = [x.strip() for x in f.readlines()]
|
||||||
return get_pkg_names_from_import_names(sorted(list(set(third_party_packages) - set(data))))
|
return sorted(list(set(third_party_packages) - set(data)))
|
||||||
|
|
||||||
|
|
||||||
def generate_requirements_file(path, imports):
|
def generate_requirements_file(path, imports):
|
||||||
@ -111,8 +111,8 @@ def get_import_local(imports):
|
|||||||
local = get_locally_installed_packages()
|
local = get_locally_installed_packages()
|
||||||
result = []
|
result = []
|
||||||
for item in imports:
|
for item in imports:
|
||||||
if item in local:
|
if item.lower() in local:
|
||||||
result.append(local[item])
|
result.append(local[item.lower()])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_pkg_names_from_import_names(pkgs):
|
def get_pkg_names_from_import_names(pkgs):
|
||||||
@ -132,7 +132,9 @@ def get_pkg_names_from_import_names(pkgs):
|
|||||||
def init(args):
|
def init(args):
|
||||||
print("Looking for imports")
|
print("Looking for imports")
|
||||||
imports = get_all_imports(args['<path>'])
|
imports = get_all_imports(args['<path>'])
|
||||||
|
imports = get_pkg_names_from_import_names(imports)
|
||||||
print("Found third-party imports: " + ", ".join(imports))
|
print("Found third-party imports: " + ", ".join(imports))
|
||||||
|
|
||||||
if args['--use-local']:
|
if args['--use-local']:
|
||||||
print(
|
print(
|
||||||
"Getting package version information ONLY from local installation.")
|
"Getting package version information ONLY from local installation.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user