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

Call os.path.normpath to normalize paths for comp #1521

Merged
merged 4 commits into from Nov 10, 2018

Conversation

uranusjr
Copy link
Member

@uranusjr uranusjr commented Oct 24, 2018

Closes #1519.

Pull Request Checklist

  • Changes have tests
  • News fragment added in changelog.d. See documentation for details

I’m not sure how the test should be constructred. It seems silly to just test whether the function is identical to calling the three functions, but any fixed strings would be platform-dependant.

Copy link
Member

@jaraco jaraco left a comment

Choose a reason for hiding this comment

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

I do think a test would be useful. Otherwise, this new behavior could be removed and tests would continue to pass. What you want is a test that demonstrates a path that without this change would fail the expectation in the bug report.

Also, if you would please in the changelog entry reference the module/function where the change is occurring. The audience for the changelog is someone who uses setuptools/pkg_reaources but doesn’t necessarily know the code base, so try to give that audience the context to understand the effect of the change.

@uranusjr
Copy link
Member Author

I added a (rather trivial) test, and modified the fragment to describe the behavioural change rather than the code modification.

@@ -236,3 +236,8 @@ def test_version_resolved_from_egg_info(self, env):
req = pkg_resources.Requirement.parse('foo>=1.9')
dist = pkg_resources.WorkingSet([env.paths['lib']]).find(req)
assert dist.version == version

def test_normalize_path(self, tmpdir):
Copy link
Member

Choose a reason for hiding this comment

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

In 092ef22, I extracted from your commit just the change for the added test, but as you can see in this build, even on Windows, that test doesn't capture the failure. I think instead of using tmpdir here, you should use a contrived path, something where pkg_resources.normalize_path() produces an unexpected result before the patch and an expected result after.

@@ -0,0 +1 @@
Perform additional path normalization to ensure path values to a directory is always the same, preventing false positives when checking scripts have a consistent prefix to set up on Windows.
Copy link
Member

Choose a reason for hiding this comment

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

Prefix with

In pkg_resources.normalize_path, perform additional...

'suffix, parts',
[
# Trailing sep should be normalized.
('foo', ('foo')),
Copy link
Member

Choose a reason for hiding this comment

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

I doubt this does what you intended. It's equivalent to ('foo', 'foo'),.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, Python tuple is hard :p

pkg_resources/tests/test_pkg_resources.py Outdated Show resolved Hide resolved
@uranusjr uranusjr force-pushed the normalize-path-normpath branch 2 times, most recently from 3eeb0b0 to fe58530 Compare October 29, 2018 06:52
@uranusjr
Copy link
Member Author

Test cases updated.

Copy link
Member

@pganssle pganssle left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @uranusjr!

@jaraco Any objections?

@pganssle
Copy link
Member

We're getting a lot of duplicate reports for this, so I think we should go ahead and merge it. I'd like to cut a release soon.

@pganssle pganssle merged commit 7f310da into pypa:master Nov 10, 2018
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.

False positive when checking for inconsistent setup script path on Windows
3 participants