KEMBAR78
Support egg/setuptools packages for PEP 561 searching. by emmatyping · Pull Request #5282 · python/mypy · GitHub
Skip to content

Conversation

@emmatyping
Copy link
Member

This adds support for setuptool's egg format, which includes support for editable installs (pip install -e ./python setup.py develop)!

Setuptools creates its own directory to put the package we want to find. These directories are listed in easy-install.pth in a site-package directory.

Fixes #5007

install_cmd.append('-e')
install_cmd.append('.')
else:
install_cmd = [python_executable, 'setup.py', 'install']
Copy link
Member

Choose a reason for hiding this comment

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

Should this be develop if editable is True?

Copy link
Member Author

Choose a reason for hiding this comment

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

I suppose that would be better, but the test should just use pip and editable (since pip install -e . calls python setup.py develop). But just to be safe, I will change it.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

LG, just one question about make_abspath().

mypy/build.py Outdated
if os.path.abspath(path) == path:
return path
else:
return os.path.join(root, path)
Copy link
Member

Choose a reason for hiding this comment

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

This feels a bit complicated (perhaps in part because you're assigning to a parameter). Is the intention this?

if os.path.isabs(path):
    return os.path.normpath(path)
else:
    return os.path.join(root, os.path.normpath(path))

While that looks like more code the flow feels a bit clearer. Also it's possible that in one of the branches you don't actually care about normpath, but I can't tell. (Or possibly you might want to call it after calling join.) Finally I note that presumably root is assumed to be absolute itself, else the function name would be misleading.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, when I wrote this I didn't know isabs existed. :) But that is much better than what I was doing. I will use your suggested code.

@gvanrossum gvanrossum merged commit 9ab6936 into python:master Jul 2, 2018
@emmatyping emmatyping deleted the eggsupport branch January 31, 2019 02:33
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.

3 participants