plone / plonecli

Plone Command Line Client - for creating and working with custom add-ons and themes
https://pypi.org/project/plonecli/
Other
19 stars 10 forks source link

Disallow or Warn '-' in addon names #72

Open arky opened 3 years ago

arky commented 3 years ago

Description

Create an addon with '-' in the name. This makes the package incompatible with pip.

What I Did

$ plonecli create addon collective.new-testcase

$ cd collective.new-testcase

$ python -m virtualenv . 

$ source bin/activate

$ ./bin/pip install -r requirements.txt

$ ./bin/buildout -vvv
in: '/tmp/collective.new-testcase/.'
/tmp/collective.new-testcase/bin/python /tmp/tmpw94ch09q -q develop -mN -d /tmp/collective.new-testcase/develop-eggs/tmprorn71nwbuild
error in collective.new-testcase setup command: ("EntryPoint must be in 'name=module:attrs [extras]' format", 'update_locale = collective.new-testcase.locales.update:update_locale')
While:
  Installing.
  Processing develop directory '/tmp/collective.new-testcase/.'.

An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
  File "/tmp/collective.new-testcase/lib/python3.9/site-packages/zc/buildout/buildout.py", line 2174, in main
    getattr(buildout, command)(args)
  File "/tmp/collective.new-testcase/lib/python3.9/site-packages/zc/buildout/buildout.py", line 679, in install
    installed_develop_eggs = self._develop()
  File "/tmp/collective.new-testcase/lib/python3.9/site-packages/zc/buildout/buildout.py", line 922, in _develop
    zc.buildout.easy_install.develop(setup, dest)
  File "/tmp/collective.new-testcase/lib/python3.9/site-packages/zc/buildout/easy_install.py", line 1100, in develop
    call_subprocess(args)
  File "/tmp/collective.new-testcase/lib/python3.9/site-packages/zc/buildout/easy_install.py", line 164, in call_subprocess
    raise Exception(
Exception: Failed to run command:
'/tmp/collective.new-testcase/bin/python', '/tmp/tmpw94ch09q', '-q', 'develop', '-mN', '-d', '/tmp/collective.new-testcase/develop-eggs/tmprorn71nwbuild'
MrTango commented 2 years ago

This is actually allowed syntax, but I'm aware that we still have problems with dashes or underlines in package names. We have to test a bit more and find a more robust way to nromalize the package name. Help is very welcome here ;)

arky commented 2 years ago

@MrTango Meanwhile I think a good solution is to document this gotcha in the documentation to save people from pulling out their hair. :D

MrTango commented 2 years ago

indeed, PR welcome ;)

arky commented 2 years ago

@MrTango Attempted to fix it here https://github.com/plone/plonecli/pull/77/files

ale-rt commented 2 years ago

Note that setuptools provides:

from setuptools.package_index import safe_name

I used that to fix a mr.developer issue with - in the package name:

You might want to use it to handle this issue as well.