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

Poetry should crash when entry-point has invalid name #2581

Open
Conchylicultor opened this issue Jun 19, 2020 · 2 comments
Open

Poetry should crash when entry-point has invalid name #2581

Conchylicultor opened this issue Jun 19, 2020 · 2 comments
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) area/core Related to the poetry-core library kind/bug Something isn't working as expected status/confirmed Issue is reproduced and confirmed version/1.2.2

Comments

@Conchylicultor
Copy link

Conchylicultor commented Jun 19, 2020

Issue was also posted in pypa/setuptools#2203 and pypa/pip#8461.

Environment

  • Poetry version: 1.0.9
  • pip version: pip 20.1.1
  • Python version: 3.6
  • OS: MacOs

Description

I was experimenting with entry_points and released a test pip package with an invalid "entry-point" name: epot-test (the - is an invalid character):

[tool.poetry.plugins."epot-test.test"]
"abc" = "epot_poetry_test.sub.other:SomeClass"

I was able to successfully publish the package even if the "epot-test" is not a valid entry-point name.

However pip install fails as the entry-point is invalid.

Expected behavior

Poetry should have catch the invalid name and not publish the package in the first place. poetry build should have failed.

How to Reproduce

Create a package with an invalid entry-point name:

[tool.poetry.plugins."epot-test.invalid"]
"a" = "package:SomeClass"
poetry build & poetry publish  # Push the corrupted package << Should fail here!
pip install epot-poetry-test==0.2.0  # Fails (but still install the corrupted package)

# After the corrupted package is installed, it cannot be uninstalled or replaced:
pip uninstall epot-poetry-test  # Fail
pip epot-poetry-test --upgrade  # Fail

Output

epot-macbookpro% pip3 uninstall epot-poetry-test     
Found existing installation: epot-poetry-test 0.2.0
ERROR: Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2857, in get_entry_map
    ep_map = self._ep_map
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2815, in __getattr__
    raise AttributeError(attr)
AttributeError: _ep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
    status = self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/commands/uninstall.py", line 86, in run
    auto_confirm=options.yes, verbose=self.verbosity > 0,
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 675, in uninstall
    uninstalled_pathset = UninstallPathSet.from_dist(dist)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/req/req_uninstall.py", line 571, in from_dist
    console_scripts = dist.get_entry_map(group='console_scripts')
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2860, in get_entry_map
    self._get_metadata('entry_points.txt'), self
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2535, in parse_map
    maps[group] = cls.parse_group(group, lines, dist)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2510, in parse_group
    raise ValueError("Invalid group name", group)
ValueError: ('Invalid group name', 'epot-test.test')

The only way I found was to manually found where the corrupted package was installed and remove the faulty entry point.

@Conchylicultor Conchylicultor added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 19, 2020
@mthuurne
Copy link

I ran into this same issue: a package with a dash in the entry point group name can be installed and used just fine, but it cannot be uninstalled.

The entry points specification is explicit about what characters are allowed, but unfortunately I didn't see that until now. It would be nice if Poetry could catch this mistake early.

I'm using Poetry 1.2.2, pip 22.3 and Python 3.10.6 on Linux.

@neersighted neersighted added area/build-system Related to PEP 517 packaging (see poetry-core) area/core Related to the poetry-core library status/confirmed Issue is reproduced and confirmed version/1.2.2 and removed status/triage This issue needs to be triaged labels Nov 28, 2022
@neersighted
Copy link
Member

I can reproduce this on 1.2.2; this would need to be fixed in core. PRs welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) area/core Related to the poetry-core library kind/bug Something isn't working as expected status/confirmed Issue is reproduced and confirmed version/1.2.2
Projects
None yet
Development

No branches or pull requests

3 participants