plone / bobtemplates.plone

Python Code Templates for Plone Projects with mr.bob
https://pypi.org/project/bobtemplates.plone/
GNU General Public License v2.0
24 stars 31 forks source link

'tox' error when creating a package with the 'addon' template #442

Closed erral closed 4 years ago

erral commented 4 years ago

When creating a package using the 'addon' template I get the following error:

--> Do you want me to activate VS Code support? (y/n) [y]: 

Traceback (most recent call last):
  File "/home/erral/.virtualenvs/plonecli/bin/mrbob", line 8, in <module>
    sys.exit(main())
  File "/home/erral/.virtualenvs/plonecli/lib/python3.8/site-packages/mrbob/cli.py", line 175, in main
    c.render()
  File "/home/erral/.virtualenvs/plonecli/lib/python3.8/site-packages/mrbob/configurator.py", line 199, in render
    f(self)
  File "/home/erral/.virtualenvs/plonecli/lib/python3.8/site-packages/bobtemplates/plone/addon.py", line 141, in post_render
    run_isort(configurator)
  File "/home/erral/.virtualenvs/plonecli/lib/python3.8/site-packages/bobtemplates/plone/utils.py", line 74, in run_isort
    test_result = subprocess.check_output(
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tox'

This happens because utils.py runs tox in the package but tox is not installed https://github.com/plone/bobtemplates.plone/blob/master/bobtemplates/plone/utils.py#L71

This could be fixed adding tox as a dependency for bobtemplates.plone

idgserpro commented 3 years ago

Adding this as a dependency breaks Plone 4 installations that add bobtemplates.plone as an egg:

    pkg_resources.require("UNKNOWN")  # latest installed version
    pkg_resources.require("UNKNOWN==0.0.0")  # this exact version
    pkg_resources.require("UNKNOWN>=0.0.0")  # this version or higher

While:
  Installing mrbob.
  Getting distribution for 'tox'.

lib/python2.7/site-packages/zc/buildout/easy_install.py", line 1704, in _move_to_eggs_dir_and_compile
    os.rename(tmp_loc, newloc)
OSError: [Errno 66] Directory not empty

Workaroud: pin bobtemplates.plone before this commit (bobtemplates.plone = 5.1.1).

In the documentation, right now, we have:

Add-ons created with bobtemplates.plone are tested to work in Plone 4.3.x and Plone 5. They should also work with older versions but that was not tested. It should work on Linux, Mac and Windows.

It doesn't say that bobtemplates.plone needs to work with Plone 4, just that addons created with it should work. So, not sure if this is a regression.