Documentation issue - Create a Plone 5 theme product (addon)

Hi, just want to follow the steps on

https://docs.plone.org/adapt-and-extend/theming/theme_product.html

to create a plonetheme product addon on a freshly installed Plone 5.0.7 via Unified installer.

EDIT: I installed Plone 5.0.7 via the unified installer on Centos 6.7 as recomended, which worked like a charme. Then i wanted to create my own theme on the file-system and followed the steps in the docs (link see above). This worked until the step where i had to execute the bootstrap-buildout.py script in my themes folder, which gave the error. For executing the bootstrap-buildout.py is used the python the unfied installer installed for me. When following the relevant part in the docs its not clear which python to use, which matters at least at Centos. Later on in other chapters it comes out that the environment the docs has its examples in was created only by a buildoutscript from scratch, which is the way a developer does it but not someone coming new to Plone in a first try.

So the steps installing mrbob and its templates worked, but the run of the bootstrap-buildout.py with the python the unified installer installed failed (This sentence edited, too).

It gives the following:

../../bin/python bootstrap-buildout.py
ez_setup.py is deprecated and when using it setuptools will be pinned to 33.1.1 since it's the last version that supports setuptools self upgrade/installation, check https://github.com/pypa/setuptools/issues/581 for more info; use pip to install setuptools
no previously-included directories found matching 'doc'
no previously-included directories found matching 'old-tutorial'
Traceback (most recent call last):
File "bootstrap-buildout.py", line 199, in
ws.require(requirement)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/pkg_resources/init.py", line 968, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/pkg_resources/init.py", line 859, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (zc.buildout 2.5.3 (/usr/local/Plone5/zeocluster/lib/python2.7/site-packages), Requirement.parse('zc.buildout==2.9.3'))

The documented approach to generate a theme addon on the filesystem should succeed, because it is a step one does after realizing that ttw theming has its limits. Just to tell you because i ran into it. If there is a better place to file such bugs please let me know.

Thanks for the great work on Plone 5!

1 Like

Ah yes. The "bootstrap-buildout.py" error. It happens more often. Ever since newer versions of setuptools, you should use pip (in a virtualenv) to install setuptools, not this script that quite often breaks or has broken.

Not at a real computer now, so can't check the exact syntax, but something like "pip install setuptools" should work.

And mr.bob template should probably be changed to create a requirements.txt that contains sane versions of setuptools.

EDIT: it seems a lot of changes have already made it into mr.bob: https://github.com/plone/bobtemplates.plone/commits/master , so maybe check if you can use a direct checkout of it.

when i do

bin/pip install setuptools

i get

Requirement already satisfied: setuptools in ./lib/python2.7/site-packages
Requirement already satisfied: packaging>=16.8 in ./lib/python2.7/site-packages (from setuptools)
Requirement already satisfied: appdirs>=1.4.0 in ./lib/python2.7/site-packages (from setuptools)
Requirement already satisfied: six>=1.6.0 in ./lib/python2.7/site-packages (from setuptools)
Requirement already satisfied: pyparsing in ./lib/python2.7/site-packages (from packaging>=16.8->setuptools)

How do i tell my main buildout.cfg to do a direct checkout of mrbob ?

@polyester, it doesn't seem a version issue to me.

It seems that @tdkuehnel downloaded UnifiedInstaller and followed https://docs.plone.org/adapt-and-extend/theming/theme_product.html tutorial, but started doing bin/pip (available in Plone 5.0.7 UnifiedInstaller) instead of just pip: installed mr.bob, created a package and tried to use bin/python from UnifiedInstaller to run the bootstrap (as it says in the tutorial). @tdkuehnel, is this what you did? Could you edit your first message, and give us more information?

Anyways, to install a package from github master, the following syntax pip install git+https://github.com/domenkozar/mr.bob.git is available. Check the docs: https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support

try:

 bin/pip install -U setuptools

To install mr.bob

bin/pip install -U bobtemplates.plone

Then mr.bob will be available as

bin/mrbob

Question: What we need to improve in the docs or in the Installer ?

1 Like

@pigeonflight this two steps give

[root@webserver zeocluster]# sudo -u plone_buildout bin/pip install -U setuptools
The directory '/bin/false/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/bin/false/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: setuptools in ./lib/python2.7/site-packages
Requirement already up-to-date: packaging>=16.8 in ./lib/python2.7/site-packages (from setuptools)
Requirement already up-to-date: appdirs>=1.4.0 in ./lib/python2.7/site-packages (from setuptools)
Requirement already up-to-date: six>=1.6.0 in ./lib/python2.7/site-packages (from setuptools)
Requirement already up-to-date: pyparsing in ./lib/python2.7/site-packages (from packaging>=16.8->setuptools)
[root@webserver zeocluster]# sudo -u plone_buildout bin/pip install -U bobtemplates.plone
The directory '/bin/false/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/bin/false/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: bobtemplates.plone in ./lib/python2.7/site-packages
Requirement already up-to-date: setuptools in ./lib/python2.7/site-packages (from bobtemplates.plone)
Requirement already up-to-date: mr.bob in ./lib/python2.7/site-packages (from bobtemplates.plone)
Requirement already up-to-date: packaging>=16.8 in ./lib/python2.7/site-packages (from setuptools->bobtemplates.plone)
Requirement already up-to-date: appdirs>=1.4.0 in ./lib/python2.7/site-packages (from setuptools->bobtemplates.plone)
Requirement already up-to-date: six>=1.6.0 in ./lib/python2.7/site-packages (from setuptools->bobtemplates.plone)
Requirement already up-to-date: Jinja2>=2.5.0 in ./lib/python2.7/site-packages (from mr.bob->bobtemplates.plone)
Requirement already up-to-date: pyparsing in ./lib/python2.7/site-packages (from packaging>=16.8->setuptools->bobtemplates.plone)
Requirement already up-to-date: MarkupSafe>=0.23 in ./lib/python2.7/site-packages (from Jinja2>=2.5.0->mr.bob->bobtemplates.plone)

so the installing of mrbob is not the problem. The problem is the next step mentioned in the docs as

(The following is copied from the docs)
Now you have a new python package in your current folder:

(mrbob)maik@planetmobile:~/develop/plone/plonetheme.tango
$ ls
bootstrap-buildout.py buildout.cfg CONTRIBUTORS.rst MANIFEST.in setup.py travis.cfg
bootstrap-buildout.pyc CHANGES.rst docs README.rst src

You can run:

$ python bootstrap-buildout.py
Creating directory '/home/maik/develop/plone/plonetheme.tango/bin'.
Creating directory '/home/maik/develop/plone/plonetheme.tango/parts'.
Creating directory '/home/maik/develop/plone/plonetheme.tango/develop-eggs'.
Generated script '/home/maik/develop/plone/plonetheme.tango/bin/buildout'.

Then you can run:

$ ./bin/buildout

This will create the whole develoment environment for your package:

$ ls bin/
buildout code-analysis-hasattr develop pildriver.py
code-analysis code-analysis-imports flake8 pilfile.py
code-analysis-clean-lines code-analysis-jscs fullrelease pilfont.py
code-analysis-csslint code-analysis-jshint instance pilprint.py
code-analysis-debug-statements code-analysis-pep3101 lasttagdiff postrelease
code-analysis-deprecated-aliases code-analysis-prefer-single-quotes lasttaglog prerelease
code-analysis-find-untranslated code-analysis-utf8-header longtest release
code-analysis-flake8

which gives the error this thread is about. I cannot create the development files needed for my theme via the bootstrap-buildout.py. So we need either:

make the bootstrap-buildout.py in the mrbob created theme folder working with a unified installed environment

or

tell in the docs the steps needed to make the unified installed environment capable of executing the mentioned step in the docs successfully, which is the "python bootstrap-buildout.py" line.

or

find another way to generate the needed files in the freshly mrbob created theme folder.

@idgserpro Yes, this is exactly what i did.

My Centos has no system wide pip command which i could use inside my Plone instance.

On Centos it is not advised to use system python or its tools inside Plone anyway, and with the files mrbob generated inside my theme product is no pip command. So i decided the docs mean "use the pip from your plones python".

Still not clear to me how to fix my problem. Mrbob generated theme folder at hand, but can not generate the files needed.

Maybe saying "When developing themes, please create you plone environment completely via virtualenv/zc.buildout, and use the unified installer only for production setup" could solve this issue?

@tdkuehnel Let's try it different, I try to be verbose:

Precondiations: You have a system wide Python 2.7 available. Also, you have virtualenv installed system wide (if not you need to install it).

Step one virtualenv:

  • create a new directory and cd into it.
  • execute virtualenv .

Now you have a Python interpreter isolated from system Python in ./bin/python

Step two: install pip:

Now you have an ./bin/pip in your isolated virtual Python environment. All installed with this pip is installed only in this directory for only this Python interpreter.

Step three: Install mr.bob

  • execute ./bin/pip install bobtemplates.plone
  • (this should install mr.bob as dependency)

Now you have ./bin/mr.bob available. Use it to generate the code and copy the code into the Plone installed by the UnifiedInstaller.

I'm seeing how it could work with the Unified Installer, as that's repeatable.

This gets me a lot further:

  • install using Unified Installer 5.0.7
  • go into the zinstance folder
  • source bin/activate
  • bin/pip install mr.bob
  • bin/pip install bobtemplates.plone
  • cd src
  • mrbob -O plonetheme.tango bobtemplates:plone_addon (answer questions)
  • cd plonetheme.tango
  • pip install zc.buildout (this uses the pip from the UI virtualenv, double check with "which pip" if in doubt)
  • buildout

and away she goes....
Until you hit the next snark, that is,

Error: There is a version conflict.
We already have: pycodestyle 2.3.1
but flake8 3.0.4 requires 'pycodestyle<2.1.0,>=2.0.0'.

but that appears to be a version conflict much later on in the proces, and is probably easily fixable with a version pin. At least the initial steps succeed, using the contained environment of the Unified Installer. Which is better for repeatability and documenting purposes.

@jensens Ok i tried this. With a recent virtualenv i got pip already installed by virtualenv. But then i got an error

[root@webserver plonetheme.tango2]# bin/mrbob -O plonetheme.tango2 bobtemplates:plone_addon

Welcome to mr.bob interactive mode. Before we generate directory structure, some questions need to be answered.

Answer with a question mark to display help.
Values in square brackets at the end of the questions show the default value if there is no answer.

--> What kind of package would you like to create? Choose between 'Basic', 'Dexterity', and 'Theme'. [Basic]: Theme

--> Theme name [Tango2]:

Traceback (most recent call last):
File "bin/mrbob", line 11, in
sys.exit(main())
File "/usr/local/Plone5/zeocluster/src/plonetheme.tango2/lib/python2.6/site-packages/mrbob/cli.py", line 172, in main
c.ask_questions()
File "/usr/local/Plone5/zeocluster/src/plonetheme.tango2/lib/python2.6/site-packages/mrbob/configurator.py", line 231, in ask_questions
self.variables[question.name] = question.ask(self)
File "/usr/local/Plone5/zeocluster/src/plonetheme.tango2/lib/python2.6/site-packages/mrbob/configurator.py", line 297, in ask
f(configurator, self)
File "/usr/local/Plone5/zeocluster/src/plonetheme.tango2/lib/python2.6/site-packages/bobtemplates/hooks.py", line 86, in pre_username
default = get_git_info('user.name')
File "/usr/local/Plone5/zeocluster/src/plonetheme.tango2/lib/python2.6/site-packages/bobtemplates/hooks.py", line 49, in get_git_info
result = subprocess.check_output(gitargs + [value]).strip()
AttributeError: 'module' object has no attribute 'check_output'

because of the system python version 2.6 of the centos 6.3 is too old. I will try again with the Plones 2.7 python in a virtualenv in the eventing when i am back at my PC. Thanks a lot so far for your efforts !

Phew, Python 2.6 is really old, this won't work. I was not aware that it is still around.

yep, setting
flake8 = 3.3.0
flake8-isort = 2.2

in buildout.cfg in the generated theme package allows for the whole thing to run through, using just the Unified Installer virtualenv.

@tdkuehnel if you could try it on your system, that would be good.

@polyester, this pinning problem was already addressed, we need a 2.0 release of bobtemplates.plone.

1 Like

Ok, @jensens, with the python from Plone 5.0.7 via unified installer and a recent virtualenv-15.1.0 i had around it worked as you described it ! Just a little warning about "ez_setup.py is deprecated", and that pip was already installed by virtualenv so no need to install it by hand.

@polyester, i can not find any virtualenv in the whole unified installer installed Plone5 directory. I had one laying around and used this, that worked.

Ok, after having a look at the buildout.cfg in the mrbob generated theme addon folder, it looks like it will generate a whole additional plone installation in my theme folder, is this by intention ? I see additional parts as for development, but is this by intention to install a second complete Plone when i only want to create my own theme on the filesystem ? Should'nt i put the necessary parts into my main buildout.cfg in the unified installed plone and work from that ? I am a bit confused now.

You do not need the self contained buildout of your generated add on. Its optional.

You can simply add this newly generated package to the existing Unified Installer based installation you already have.
In section [buildout] of Unified Installers buildout.cfg there is a key develop = (if not add one there). Add there the path to the package generated by mr.bob like so:

develop = 
    /full/path/to/mrbob.generated.package

Hint: it is the path to the generated directory that contains the setup.py file.

Now rerun the bin/buildout of the UnifiedInstaller so it picks up you generated package.
If everything went right, after (re)starting Plone, your generated package is available in the Add Ons Sections of the Plone Control Panel, ready to install.

@jensens, thank you very much ! I will try all steps together now from a fresh install and report if all succeeds and when yes will share what we need to improve the docs.

Update: Plone 5.0.7 successfully installed via unified installer. There is no mr.bob or its templates pre installed.

I put mr.bob and bobtemplates.plone into the eggs section of my main buildout.cfg, the one from the unified installer.

sudo -u plone_buildout bin/buildout

ran sucessfully

executed mrbob, answered the questions to create the templates dir.

At next we need a virtualenv. a

bin/pip install virtualenv

did it, in the main zeocluster directory.

Then i changed into the src/plonetheme.tango dir and initialize it with the virtualenv:

../../virtualenv . --no-site-packages

and then

bin/pip install zc.buildout

At this step i put the generated plonetheme.tango path entry into the develop section of my main unified installed buildout.cfg, ran

sudo -u plone_buildout bin/buildout

and voila, everything worked as expected, um, say, it worked.

So maybe i can strip down all this virtualenv stuff?

Yes i can, just verfied that also.

So these simple steps need to be updated in the docs:

add mr.bob and bobtemplates.plone to the eggs section of the main buildout.cfg. run bin/buildout.

use bin/mrbob to generate a folder with templates, answer the questions and add this package path to the develop section of the buildout, run bin/buildout. Take care of the permission. I used sudo -U plone_buildout for that. All Done ! Hopefully, i better check if my theme package is available in my Plone instance after a restart, wait ...

No, nothing to install in the add ons section or at the theme control panel. But Plone started in the foreground cleanly.

[root@webserver zeocluster]# sudo -u plone_buildout bin/buildout
Develop: '/usr/local/Plone5/zeocluster/src/plonetheme.tango'
Updating zeoserver.
...

mea culpa! I forgot one important detail:

You also need to add the name of the package (plonetheme.tango) to the eggs key (as a new line below the two existing). In the above instructions together with the step where develop = is added/modified. Thus it means you need to run buildout again and restart plone.

@jensens Ok, thank you, i did that and got the following:

[root@webserver zeocluster]# sudo -u plone_buildout bin/buildout
Develop: '/usr/local/Plone5/zeocluster/src/plonetheme.tango'
Updating zeoserver.
Installing client1.
/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/pkg_resources/init.py:183: RuntimeWarning: You have iterated over the result of pkg_resources.parse_version. This is a legacy behavior which is inconsistent with the new version class introduced in setuptools 8.0. In most cases, conversion to a tuple is unnecessary. For comparison of versions, sort the Version instances directly. If you have another use case requiring the tuple, please file a bug with the setuptools project describing that need.
stacklevel=1,
While:
Installing client1.

An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/zc/buildout/buildout.py", line 1995, in main
getattr(buildout, command)(args)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/zc/buildout/buildout.py", line 666, in install
installed_files = self[part]._call(recipe.install)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/zc/buildout/buildout.py", line 1410, in _call
return f()
File "/usr/local/Plone5/buildout-cache/eggs/plone.recipe.zope2instance-4.2.22-py2.7.egg/plone/recipe/zope2instance/init.py", line 113, in install
installed.extend(self.install_scripts())
File "/usr/local/Plone5/buildout-cache/eggs/plone.recipe.zope2instance-4.2.22-py2.7.egg/plone/recipe/zope2instance/init.py", line 617, in install_scripts
requirements, ws = self.egg.working_set(['plone.recipe.zope2instance'])
File "/usr/local/Plone5/buildout-cache/eggs/zc.recipe.egg-2.0.3-py2.7.egg/zc/recipe/egg/egg.py", line 84, in working_set
allow_hosts=self.allow_hosts)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/zc/buildout/easy_install.py", line 859, in install
return installer.install(specs, working_set)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/zc/buildout/easy_install.py", line 634, in install
for spec in specs]
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/pkg_resources/init.py", line 2935, in parse
req, = parse_requirements(s)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/pkg_resources/init.py", line 2883, in parse_requirements
yield Requirement(line)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/pkg_resources/init.py", line 2892, in init
raise RequirementParseError(str(e))
RequirementParseError: Invalid requirement, parse error at "'/ploneth'"

As so often when i(!) am reading the tracebacks, i really have no clue in which file/line the actual error is. It looks like pkg_resources/init.py parses something inside the theme egg folder, but which file and line it has a problem with? Maybe i patch the init.py to tell me that ...

EDIT: the complete requirement string causing the problem is 'src/plonetheme.tango' as my print statement tells me.

EDIT: making the path in the eggs entry absolute gives same error.