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

Fix pip file deps conversion #926

Merged
merged 3 commits into from Oct 18, 2017
Merged

Conversation

krismolendyke
Copy link
Contributor

Fix for determining if a package name is a locally installed package. I ran into this because a project I work on depends on the ansible Python package and has a top-level ansible/ directory which is not a Python package.

The current logic detects the ansible/ filesystem directory as a Python package file installation and sets the package name to the hash of the directory path, which is nonsense. Then, pip tries to uninstall something like deadbeef and fails, not uninstalling anything after that non-existent "package".

I kept this change simple and stupid as I believe that the file (un)installation support is really just about files, and I didn't want to drag importlib into this.

re:

@techalchemy
Copy link
Member

good catch, I was knee deep in some of this stuff when I wrote it so I didn't have the wherewithal to step back from this. This is a good fix.

Copy link
Sponsor Member

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

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

One minor change and I think we're good here. Thanks for putting this together @krismolendyke!

os.mkdir(os.path.join(p.path, "tablib"))

c = p.pipenv('install {}'.format(file_name))
key = [k for k in p.pipfile['packages'].keys()][0]
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I should have caught this when the original test was added. Why are we creating a new list for keys when keys() already returns a list?

Let's not continue this trend into new tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably because in Python 2 keys() returns a list but in Python 3 keys() returns a view that would need to be coerced to a list to be indexed.

Copy link
Member

Choose a reason for hiding this comment

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

we do this in a number of places in the codebase for this reason and in the other tests that check on this as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK rather than deal with this silly 2/3 issue I just removed the copy/pasta of the offending test. The original test remains but this new one does not propagate that behavior.

@nateprewitt
Copy link
Sponsor Member

Thanks @krismolendyke!

@nateprewitt nateprewitt merged commit 2071478 into pypa:master Oct 18, 2017
@krismolendyke
Copy link
Contributor Author

🙇

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.

None yet

3 participants