Skip to content

Commit

Permalink
Update to v0.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
HubTou authored Mar 31, 2023
1 parent 548d659 commit 66a46f2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Options | Use
--|Options processing terminator

## ENVIRONMENT
The PIPINFO_DEBUG environment variable can be set to any value to enable debug mode.
The *PIPINFO_DEBUG* environment variable can be set to any value to enable debug mode.
It's mostly used to display and debug the package requirements read from the Python packages metadata files.

The *LOCALAPPDATA* and *TMP* environment variables under Windows, and *HOME*, *TMPDIR* and *TMP* environment variables
Expand Down
16 changes: 7 additions & 9 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# Ideas for improvement and evolution

## Bugs to be fixed
* Handling multiple extra variables in a requirement line. For example:
```
Requires-Dist: pipreqs ; extra == "pipfile-deprecated-finder" or extra == "requirements-deprecated-finder"
```

## Limitations to be removed
* Processing dependencies conditions, including testing variables such as:
os_name, platform_python_implementation, platform_system, sys_platform, python_version, python_full_version, implementation_name
* Handling variations in package dependencies with '-' and '_' characters
* Handling variations ('-' or '_' instead of the other one) in package dependencies

## New features
* Printing the first level of package dependencies (-d|--depends-on)
* Printing the first level of package requirements (-r|--required-by)
* Expanding the 2 previous prints to a tree (-t|--tree)
* Checking the integrity of installed packages (missing or modified files)
* Checking modified files is possible for dist-info packages (with the RECORD file)
but not for egg-info packages which only have list of files (in the SOURCES.txt file)
* Checking the dependencies of installed packages (missing dependencies or wrong versions)
* When checking vulnerabilities, using an orange background when a package has a
vulnerability somewhere in its dependencies tree (a toolchain vulnerability)

## Other possible features
* Checking dependencies on system (FreeBSD for a start) packages
* Checking the integrity of installed packages (missing or modified files)
* Checking the dependencies of installed packages (missing dependencies or wrong versions)
* Wrapping long lines (-w|--wrap)

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = pnu-pipinfo
description = Alternative tool for listing Python packages
long_description = file: README.md
long_description_content_type = text/markdown
version = 0.9.2
version = 0.9.3
license = BSD 3-Clause License
license_files = License
author = Hubert Tournier
Expand Down
60 changes: 23 additions & 37 deletions src/pipinfo/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,35 +78,19 @@ def process_requires_file(filename, requires, extras):
else:
conditions = re.sub(r"^" + dependency + " *;* *", "", line)
if extra:
if dependency in extras[extra]:
if conditions:
extras[extra][dependency] += ";" + conditions
if extra_conditions:
extras[extra][dependency] += ";" + extra_conditions
else:
extras[extra][dependency] = {}
if conditions:
extras[extra][dependency] = conditions
if extra_conditions:
if extras[extra][dependency]:
extras[extra][dependency] += ";" + extra_conditions
else:
extras[extra][dependency] = extra_conditions
if dependency not in extras[extra]:
extras[extra][dependency] = []
if conditions:
extras[extra][dependency].append(conditions)
if extra_conditions:
extras[extra][dependency].append(extra_conditions)
else:
if dependency in requires:
if conditions:
requires[dependency] += ";" + conditions
if extra_conditions:
requires[dependency] += ";" + extra_conditions
else:
requires[dependency] = {}
if conditions:
requires[dependency] = conditions
if extra_conditions:
if requires[dependency]:
requires[dependency] += ";" + extra_conditions
else:
requires[dependency] = extra_conditions
if dependency not in requires:
requires[dependency] = []
if conditions:
requires[dependency].append(conditions)
if extra_conditions:
requires[dependency].append(extra_conditions)

logging.debug("requires:\n%s", pprint.pformat(requires))
logging.debug("extras:\n%s", pprint.pformat(extras))
Expand Down Expand Up @@ -175,25 +159,27 @@ def get_info_from_site_packages_dir(directory, directory_type):
extra = re.sub(r"['\"].*", "", part[1:])

# Remove the extra == "NAME" from the conditions
conditions = re.sub(r" *;* *extra == ." + extra + ". *",
";", conditions)
conditions = re.sub(r" *and *;", "", conditions)
conditions = re.sub(r";and *", ";", conditions)
conditions = re.sub(r";$", "", conditions)
while "extra == " in conditions:
conditions = re.sub(r" *;* *(and|or)* *extra == ('[^']*'|\"[^\"]*\") *(and|or)* *", ";", conditions)
conditions = re.sub(r";*$", "", conditions)

if extra not in extras:
extras[extra] = {}
if dependency in extras[extra]:
if conditions:
extras[extra][dependency] += ";" + conditions
extras[extra][dependency].append(conditions)
elif conditions:
extras[extra][dependency] = [conditions]
else:
extras[extra][dependency] = conditions
extras[extra][dependency] = []
else:
if dependency in requires:
if conditions:
requires[dependency] += ";" + conditions
requires[dependency].append(conditions)
elif conditions:
requires[dependency] = [conditions]
else:
requires[dependency] = conditions
requires[dependency] = []
elif line.startswith("Home-page: "):
pass
elif line.startswith("Project-URL: "):
Expand Down
2 changes: 1 addition & 1 deletion src/pipinfo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
get_packages_required_by, is_package_required, list_packages

# Version string used by the what(1) and ident(1) commands:
ID = "@(#) $Id: pipinfo - Alternative tool for listing Python packages v0.9.2 (March 21, 2023) by Hubert Tournier $"
ID = "@(#) $Id: pipinfo - Alternative tool for listing Python packages v0.9.3 (March 31, 2023) by Hubert Tournier $"

# Default parameters. Can be overcome by environment variables, then command line options
parameters = {
Expand Down

0 comments on commit 66a46f2

Please sign in to comment.