Skip to content

[Py3] Remove package containing entry points names with colons #3434

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

Merged
merged 6 commits into from
Feb 2, 2016

Conversation

montefra
Copy link
Contributor

Entry points names containing colons are legit, or at least pkg_resources can deal with them without any issue.

Unfortunately, in python 3 pip uninstall choke on them when removing a package.
This is because ConfigParser supports by defaults also the "INI" format, in which the delimiter is a colon. This is not a problem for python 2.

This PR force the delimiter to be only = to fix this issue.

I haven't add a test as now. I should have to dig into the test suite (which is huge).
In theory would be enough to add an entry point somewhere called e.g.:

entry:point = path.to.package:function

If someone would be so kind as to point me to the correct place to add it, I would be very happy to add it and check if everything is fine.

Review on Reviewable

@xavfernandez
Copy link
Member

@montefra good catch.

For the test, maybe the simplest would be to write a functional test like this one:

def test_simple_uninstall_distutils(script):
"""
Test simple install and uninstall.
"""
script.scratch_path.join("distutils_install").mkdir()
pkg_path = script.scratch_path / 'distutils_install'
pkg_path.join("setup.py").write(textwrap.dedent("""
from distutils.core import setup
setup(
name='distutils-install',
version='0.1',
)
"""))
result = script.run('python', pkg_path / 'setup.py', 'install')
result = script.pip('list')
assert "distutils-install (0.1)" in result.stdout
script.pip('uninstall', 'distutils_install', '-y', expect_stderr=True)
result2 = script.pip('list')
assert "distutils-install (0.1)" not in result2.stdout

Where you can define the setup.py of your project with the problematic entry_point.

@montefra
Copy link
Contributor Author

montefra commented Feb 1, 2016

@xavfernandez: thank you for the pointer. I should commit the test soon.

@montefra
Copy link
Contributor Author

montefra commented Feb 1, 2016

I have added a test.
I've added pretend to the test_requires list to be able to run py.test.
Tox run through, except for py35:

  docs: commands succeeded
  packaging: commands succeeded
  pep8: commands succeeded
ERROR:   py3pep8: InterpreterNotFound: python3.3
ERROR:   py26: InterpreterNotFound: python2.6
  py27: commands succeeded
ERROR:   py33: InterpreterNotFound: python3.3
  py34: commands succeeded
ERROR:   py35: commands failed
ERROR:   pypy: InterpreterNotFound: pypy

Python 3.5 failed with an error which is probably fault of pytest e.g.:

ERROR collecting tests/functional/test_completion.py

.tox/py35/lib/python3.5/site-packages/py/_path/local.py:650: in pyimport
    __import__(modname)
<frozen importlib._bootstrap>:969: in _find_and_load
    ???
<frozen importlib._bootstrap>:954: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:892: in _find_spec
    ???
<frozen importlib._bootstrap>:873: in _find_spec_legacy
    ???
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:137: in find_module
    source_stat, co = _rewrite_test(state, fn_pypath)
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:278: in _rewrite_test
    rewrite_asserts(tree)
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:336: in rewrite_asserts
    AssertionRewriter().run(mod)
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:557: in run
    new.extend(self.visit(child))
/usr/lib/python3.5/ast.py:245: in visit
    return visitor(node)
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:665: in visit_Assert
    top_condition, explanation = self.visit(assert_.test)
/usr/lib/python3.5/ast.py:245: in visit
    return visitor(node)
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:796: in visit_Compare
    left_res, left_expl = self.visit(comp.left)
/usr/lib/python3.5/ast.py:245: in visit
    return visitor(node)
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:647: in generic_visit
    return res, self.explanation_param(self.display(res))
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:584: in display
    return self.helper("saferepr", expr)
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:590: in helper
    return ast.Call(attr, list(args), [], None, None)
E   TypeError: Call constructor takes either 0 or 3 positional arguments

result = script.pip('install', pkg_path)
result = script.pip('list')
assert "ep-install (0.1)" in result.stdout
script.pip('uninstall', 'ep_install', '-y', expect_stderr=True)
Copy link
Member

Choose a reason for hiding this comment

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

Is the expect_stderr=True needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given your question, I guess no.
Who does it work? If expect_stderr=False and there is standard error, raises an error?
In this case I remove it and recommit.

Copy link
Member

Choose a reason for hiding this comment

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

If expect_stderr=False and there is standard error, raises an error?

Yes exactly, it was needed in the distutils case, because pip prints a warning in such case.

@xavfernandez
Copy link
Member

Yes the pytest issue is known: it is pinned to avoid this issue pytest-dev/pytest#1083 but would need to be bumped to work on python 3.5 ...

@montefra
Copy link
Contributor Author

montefra commented Feb 1, 2016

Ok. Thank you for the pytest pointer.

@montefra
Copy link
Contributor Author

montefra commented Feb 1, 2016

@xavfernandez : I've removed it. The test goes fine on my system.

If you accept the PR, do I have to do something else (changelog, other file, ...)?
Do you want me to rebase the branch?

@xavfernandez
Copy link
Member

Well a changelog would make my life easier ^^
cf https://github.com/pypa/pip/blob/develop/CHANGES.txt

The rebase is optional since there is no conflict.

@montefra
Copy link
Contributor Author

montefra commented Feb 1, 2016

@xavfernandez : I'll add an entry under **8.1.0 (unreleased)** tomorrow.

If I see that tomorrow there are conflicts, I'll rebase.

Good night

@xavfernandez
Copy link
Member

@montefra thanks :)

@montefra
Copy link
Contributor Author

montefra commented Feb 2, 2016

@xavfernandez : done.

I hope that everything is fine.

if six.PY2:
options = {}
else:
options = {"delimiters": ('=')}
Copy link
Member

Choose a reason for hiding this comment

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

I think you meant ('=',).
Sorry I did not spot this before...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

of course... Me dumm! I'm not used to use tuples. Thank for spotting it. Committing

@montefra
Copy link
Contributor Author

montefra commented Feb 2, 2016

@xavfernandez I'm about to rebase and push the commit

@montefra montefra force-pushed the fix_uninstall_colon branch from dc33b20 to 3c85765 Compare February 2, 2016 12:52
@montefra
Copy link
Contributor Author

montefra commented Feb 2, 2016

@xavfernandez : rebase done

xavfernandez added a commit that referenced this pull request Feb 2, 2016
[Py3] Remove package containing entry points names with colons
@xavfernandez xavfernandez merged commit 3455016 into pypa:develop Feb 2, 2016
@xavfernandez
Copy link
Member

Thanks for your patience :)

@montefra
Copy link
Contributor Author

montefra commented Feb 2, 2016

thank for accepting the PR and mostly thankd for pip.

@montefra montefra deleted the fix_uninstall_colon branch February 2, 2016 14:08
@xavfernandez xavfernandez added this to the 8.0.3 milestone Feb 8, 2016
xavfernandez added a commit to xavfernandez/pip that referenced this pull request Feb 24, 2016
[Py3] Remove package containing entry points names with colons
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants