How to add an add-on to Plone 5.2.8 in Windows 10?

I create an add-on and run buildout (see below) but the add-on doesn't appear in prefs_install_products_form.

Create simple add-on as follows:

$SRC_DIR = "c:\Users\vagrant\Plone-5.2.8-zeo\zeocluster\src"
cd ${SRC_DIR}
@'
[variables]
author.name = theAuthor
author.email = info@domain.org
author.github.user = gitusername
package.description = An add-on for Plone
package.git.init = True
package.git.autocommit: True
plone.version = 5.2.8
python.version = python3.8
vscode_support = False
'@ | Out-File -Encoding ascii "${SRC_DIR}\packagename.subpackagename.ini"
Get-Content "${SRC_DIR}\packagename.subpackagename.ini"

..\bin\mrbob.exe `
    --config packagename.subpackagename.ini `
    -O packagename.subpackagename bobtemplates.plone:addon

add the add-on to a buildout config file and run buildout

$ZEOCLUSTER_DIR = "c:\Users\vagrant\Plone-5.2.8-zeo\zeocluster"
cd ${$ZEOCLUSTER_DIR}
@'
[buildout]
extends =
    develop.cfg
eggs +=
    packagename.subpackagename
[sources]
packagename.subpackagename = fs packagename.subpackagename path=src
'@ | Out-File -Encoding ascii ${$ZEOCLUSTER_DIR}\packagename.subpackagename.cfg

.\bin\buildout.bat -c .\packagename.subpackagename.cfg

Run zeoserver_runzeo and runwsgi

.\bin\zeoserver_runzeo.bat
.\bin\runwsgi.exe -dv .\parts\client1\etc\wsgi.ini

Try to also explicitly load the ZCML of the new package:

(re-run buildout to apply the change)

@jensens: zcml doesn't work neither.

Neither with a "normal" add-on seems to work (see below). It seems to be a more general issue.

cd ${INSTANCE_HOME}
@'
[buildout]
extends =
    develop.cfg
eggs +=
    collective.fontawesome
'@ | Out-File -Encoding ascii "${INSTANCE_HOME}\collective.fontawesome.cfg"
Get-Content "${INSTANCE_HOME}\collective.fontawesome.cfg"

& ${INSTANCE_HOME}\bin\buildout.bat -c ${INSTANCE_HOME}\collective.fontawesome.cfg

I'd expect buildout creating a client1 script or modifying runwsgi-script.py. None is the case.

If I add the following to the sys.path in runwsgi-script.py it works:

'c:\\users\\vagrant\\plone-5.2.8-zeo\\buildout-cache\\eggs\\cp38m\\collective.fontawesome-1.1-py3.8.egg',

buildout neither creates a client1 script nor modifies runwsgi-script.py.

Therefore runwsgi-script.py is only aware of the sys.path created during windows_install.bat.

Question: is bin\runwsgi.exe -dv parts\client1\etc\wsgi.ini the windows way to start client1?

If this is the case, is it possible at all to develop an add-on in windows? Is there anyone who has succesfully developed an add-on with Plone 5.2.8 on Windows 10? Any step-by-step guide?

2019 my intern documented his way to develop add-ons on Windows 10 here Installing Plone on a Windows 10 Linux Subsystem for Development — Plone Documentation v5.2

That said, it should be possible with UnifiedInstaller too, but I have no experience here.

@jensens: Thank you for your comment.

Using WSL or WSL2, or a VM with of without vagrant, or cygwin or something similary are, of course, excellent ways to get things running in another OS "on top" of Windows. Personally I prefer virtual machines because they can be customized to emulate target production systems and offer snapshots. But this is a personal preference.

But none of the above is sensu stricto "running on Windows".

What I'd like to find out is whether Plone (as of Version 5.2.8 or 5.2.9) can be installed and be used for development on Windows 10 (without WSL or VM).

Has anyone succesfully installed and developed an add-on with Plone 5.2.8 on Windows 10?

mekell via Plone Community wrote at 2022-7-20 07:49 +0000:

...
Has anyone succesfully installed and developed an add-on with Plone 5.2.8 on Windows 10?

A recent discussion targeted how to debug Plone under Windows
(it asked specifically what one can use in place of
bin/{client1|instance} debug under Windows).

I suppose that the wish to debug Plone under Windows was
motivated by a serious development project (as a stock Plone
usually does not require debugging).
Thus, the anwser to your question above is likely "yes".

Search the discussion for details.

@dieter: Thanks for your comment. I assume you refer to the discussion in (How to debug plone under Windows 10?). I cannot see there any hint to develop an add-on.

As I already mentioned I suspect that the problem is in buildout: buildout (in Windows 10) always generates exactly the same runwsgi-script.py no matter what configuration (.cfg) is passed to it.

This can be reproduced by running bin\buildout.bat first with buildout.cfg and then with develop.cfg and comparing the generated scripts in the bin directory:

  • Both buildout.cfg and develop.cfg generate the following scripts (both the .exe and the .py part) with exactly the same content, i.e. the same sys.path: buildout, mkwsgiinstance, repozo, runwsgi, zconsole, zeopack, zeoserver, zeoserver_runzeo, zeoserver_service.

  • As expected zopepy-script.py is different if generated with develop.cfg: It contains plone.reload in the sys.path if generated with develop.cfg but not if generated with buildout.cfg.

  • Following scripts (both the .exe and the .py part) are generated with develop.cfg but not with buildout.cfg: bumpversion, develop, diazocompiler, diazopreprocessor, diazorun, fullrelease, i18ndude, lasttagdiff, lasttaglog, longtest, mrbob, pocompile, postrelease, prerelease, release, and test.

Maybe I'm wrong but I'd expect a runwsgi-script.py with the eggs added to sys.path. In the case of develop.cfg I'd expect plone.reload to be in the sys.path. This is not the case. Therefore a client started with bin\runwsgi.exe -dv parts\client1\etc\wsgi.ini cannot have access to plone.reload or any egg not included in the sys.path of runwsgi-script.py.

Am I correct in assuming the above?

mekell via Plone Community wrote at 2022-7-20 11:04 +0000:

...
Maybe I'm wrong but I'd expect a runwsgi-script.py with the eggs added to sys.path. In the case of develop.cfg I'd expect plone.reload to be in the sys.path. This is not the case. Therefore a client started with bin\runwsgi.exe -dv parts\client1\etc\wsgi.ini cannot have access to plone.reload or any egg not included in the sys.path of runwsgi-script.py.

Am I correct in assuming the above?

A (buildout) recipe is responsible for the script generation.
Not sure whether Windows requires a different recipe
(on *nix, the corresponding scripts are generated by
plone.recipe.zope2instance).

sys.path is generally generated from the eggs definition
of the corresponding section. This is fairly easy: it is quite
difficult to see what could go wrong there.

Yes. sys.path should be generated from the eggs definition. But this is definitely not the case for runwsgi-script.py in Windows 10.

I might be wrong, but isn't Plone 5.2 supposed to be started with bin/instance.exe or bin/client1.exe when using the buildout from UnifiedInstaller?

mekell via Plone Community wrote at 2022-7-20 12:05 +0000:

Yes. sys.path should be generated from the eggs definition. But this is definitely not the case for runwsgi-script.py in Windows 10.

Check which recipe is responsible. Look at its source to find
out what could go wrong (or start debugging it).

Here is the minimal scenario to test this issue in Powershell:

cd c:\Users\vagrant

Start-BitsTransfer `
    -Source https://launchpad.net/plone/5.2/5.2.8/+download/Plone-5.2.8-UnifiedInstaller-1.0.tgz `
    -Destination Plone-5.2.8-UnifiedInstaller-1.0.tgz

tar -xzf Plone-5.2.8-UnifiedInstaller-1.0.tgz

$INSTALLER_HOME = "c:\Users\vagrant\Plone-5.2.8-UnifiedInstaller-1.0"
$PLONE_HOME = "c:\Users\vagrant\Plone-5.2.8"
$INSTANCE_HOME = "${PLONE_HOME}\zeocluster"

cd ${INSTALLER_HOME}
.\windows_install.bat `
    --password=admin `
    --target=${PLONE_HOME} `
    --instance=zeocluster `
    --clients=2 zeo

cd ${INSTANCE_HOME}

& ${INSTANCE_HOME}\bin\buildout.bat -c ${INSTANCE_HOME}\buildout.cfg
Copy-Item .\bin\runwsgi-script.py `
    -Destination .\runwsgi-script.py.as-generated-with-buildout.cfg

& ${INSTANCE_HOME}\bin\buildout.bat -c ${INSTANCE_HOME}\develop.cfg
Copy-Item .\bin\runwsgi-script.py `
    -Destination .\runwsgi-script.py.as-generated-with-develop.cfg

Compare-Object `
    (Get-Content .\runwsgi-script.py.as-generated-with-buildout.cfg) `
    (Get-Content .\runwsgi-script.py.as-generated-with-develop.cfg)

runwsgi-script.py.as-generated-with-buildout.cfg and runwsgi-script.py.as-generated-with-develop.cfg have exactly the same sys.path. The script runwsgi-script.py.as-generated-with-develop.cfg doesn't include plone.reload in sys.path as I'd expect from the eggs definition in develop.cfg (line 118).

Am I on the wrong track?

Not in Windows. There is no bin\instance.exe nor bin\client1.exe.

Maybe I miss something here. But I cannot find any other way to start Plone 5.2.8 than bin\runwsgi.exe -dv parts\client1\etc\wsgi.ini.

BTW: See first quick shot to improve the windows install by jensens · Pull Request #151 · plone/plone.recipe.zope2instance · GitHub

I'd like to. But I don't know yet where the code for buildout.exe comes from. I posted yesterday in github:

mekell via Plone Community wrote at 2022-7-20 12:42 +0000:

...
Maybe I miss something here. But I cannot find any other way to start Plone 5.2.8 than bin\runwsgi.exe -dv parts\client1\etc\wsgi.ini.

When I remember right (I am not really interested in Windows),
the discussion I mentioned earlier used zconsole.

mekell via Plone Community wrote at 2022-7-20 12:55 +0000:

I'd like to. But I don't know yet where the code for buildout.exe comes from. I posted yesterday in github:
Where does `buildout.exe` come from? · Issue #611 · buildout/buildout · GitHub

buildout is not responsible for script generation;
it delegates it to a recipe.

Look at the (hierarchical) buildout configuration.
The respective files are organized into (configparser) sections.
The section headers have the form [*section name*].
Some sections describe buildout "part"s. They contain
a definition for recipe. The respective recipe is responsible
for the creation of this part, including associated scripts.

At your place, I would first identify the part responsible
to generate the Plone instance. Under *nix, this is
instance or client1. I do not know what it is under Windows.
You may look into the folder parts: its subfolders represent
the candidates. The correct part folder will contain a subfolder
etc with files zope.conf and site.zcml.
Once you know the part name, you search the buildout configuration
for the corresponding section and locate its recipe definition.

The recipe is plone.recipe.zope2instance. From its documentation:

On the windows platform the ``bin/instance`` script as described below
will not be generated, because it uses a Unix specific implementation.

To run Plone start it with::

  .\bin\runwsgi.exe -v .\parts\etc\wsgi.ini

Or for development in debug mode use::

  .\bin\runwsgi.exe -v .\parts\etc\wsgi.ini

The documentation for the extended Zope control script below does not apply.

The source code of plone.recipe.zope2instance doesn't seem to generate the runwsgi scripts at all: Search · runwsgi · GitHub

The script runwsgi is generated by Zope.setup.py (see Zope/setup.py at master · zopefoundation/Zope · GitHub) as console_scripts entry_point (see Command Line Scripts — Python Packaging Tutorial)

\bin\runwsgi-script.py

\bin\runwsgi.exe 

are related?

The helper script to create the instance just run buildout with this options:
-NU buildout:install-from-cache=true

you can try it and see if something changes.

Yes they are related. runwsgi.exe calls runswgi-script.py.

What do you expect from this? There is no default_configuration in windows.

.\bin\buildout.bat -NU buildout:install-from-cache=true raises Error: Couldn't download 'https://dist.plone.org/release/5.2.8/versions.cfg' in offline mode.