Skip to content

Fixes #58 Implement egg-info version parsing#529

Open
arnowaschk wants to merge 1 commit into
bndr:masterfrom
arnowaschk:058-fix-egg-info-version
Open

Fixes #58 Implement egg-info version parsing#529
arnowaschk wants to merge 1 commit into
bndr:masterfrom
arnowaschk:058-fix-egg-info-version

Conversation

@arnowaschk

Copy link
Copy Markdown

Fixes #58

pipreqs could misparse <package>.egg-info metadata directories and emit malformed package/version pairs. This patch:

  • prefers METADATA / PKG-INFO when available
  • preserves the old version fallback for regular directory names
  • adds regression coverage for egg-info and metadata-based parsing

I verified the focused regression tests locally.

Greetings Arno

…nfo and enhance tests for package name extraction

@StantonMatt StantonMatt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this locally against #58. The branch fixes the original no-version <package>.egg-info case in a way that keeps the package name usable instead of splitting the suffix as a bogus version.

Direct reproduction:

origin/master: [{'name': 'mypackage.egg', 'version': 'info', 'exports': ['mypackage']}]
pr-529:       [{'name': 'mypackage', 'version': None, 'exports': ['mypackage']}]

I also checked the metadata path and the old directory-name fallback through the new tests. Local verification on Python 3.9.6:

python -m unittest tests.test_pipreqs.TestPipreqs.test_get_locally_installed_packages_ignores_egg_info_suffix tests.test_pipreqs.TestPipreqs.test_get_package_name_and_version_preserves_regular_version tests.test_pipreqs.TestPipreqs.test_get_package_name_and_version_keeps_hyphenated_name_without_version tests.test_pipreqs.TestPipreqs.test_get_locally_installed_packages_prefers_metadata_name
python -m unittest discover
python -m py_compile pipreqs/pipreqs.py tests/test_pipreqs.py
python -m flake8 pipreqs/pipreqs.py tests/test_pipreqs.py
git diff --check origin/master...HEAD

The focused tests passed, full discovery passed 33 tests, and lint/compile/diff checks passed. GitHub reports no check runs for this PR, so there is no upstream CI result to claim, but I do not see a blocking issue from this pass.

@arnowaschk

Copy link
Copy Markdown
Author

@StantonMatt Thank you for your efforts!

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

Successfully merging this pull request may close these issues.

<package>/<package>.egg-info directories cause bad versions in requirements.txt

2 participants