Installing Plone with just pip (without buildout)

For me it seems that, a story for installing Plone with just pip is quite close (thanks to many things prior to this).

I did an example repository with the latest Plone requirements and minimal Plone instance skeleton

git clone https://github.com/datakurre/plone-pip
cd plone-pip

All required packages should install nicely with just pip install on a fresh Python 2.7 virtual env

virtualenv env
env/bin/pip install -U pip setuptools
env/bin/pip install -r requirements-5.1rc2.txt -r requirements.txt

I still required buildout to extracted those requirements using buildout.requirements from Plone 5.1.rc2-pending versions. In addition, I needed to

  • Disable the default z3c.autoinclude and replace it with the branch with pip compatibility.
  • Add my branch of plonecli that includes compatible instance, zeoserver and zeopack scripts I extracted from plone.recipe.zope2instance and plone.recipe.zeoserver.

In addition, the repository contains

  • ./etc/site.zcml, because currently Zope2 is hardcoded to load site.zcml from {config.instancehome}/etc/site.zcml (it would be easy fix into Zope2 to make that fully configurable)
  • minimal ./zope.conf that configures $PWD as instancehome and var (maybe not best practice, but simple for demo; also I could imagine creating custom zope.conf from bobtemplate using plonecli); also <includeDependencies /> directive (the evil twin of good <includePlugins />) is disabled with an environment variable in zope.conf

After installation, Plone can be started in foreground with running a simple script for initializing the admin user and then starting the instance

env/bin/plonecli instance -C zope.conf run admin.py
env/bin/plonecli instance -C zope.conf fg

But that's just the start for the fun. Installing add-ons is simply pip install and restarting the instance

env/bin/pip install collective.easyform
env/bin/pip install plone.app.imagecropping

And creating a new add-on is just an another call to plonecli and python setup.py develop to install the add-on into the virtualenv

source env/bin/activate
plonecli create addon my.addon
cd my.addon
python setup.py develop

I admit that pip may not ever replace existing professional buildout based development and deployment toolchains, but what are the reasonse why we shouldn't polish and promote this approach for new users?

4 Likes

Can we see all the commands you ran? I think you must have skipped over the part that installs Plone :slight_smile:

My first question coming to this is why do you think buildout is bad that it needs to be avoided?

Re: new users, I think an encapsulating installer rather than a command line method is going to attract more novices. I guess it depends if by 'new users' you mean 'new developers'. I also think the Plone Docker is a super easy way to get novices going with a local instance of Plone. Decision makers evaluating Plone are an entirely different category; for those, we need to promote live demo instances as we do on plone.com/try-plone

OK that is pretty slick.

On the other hand, it reminds me of easy_install. I assume there is a reason why we stopped adding add-ons via easy_install. Does your new method avoid those gotchas?

That is very nice! Being compatible with default Python installation mechanisms is definitely a big win when it comes to explain Plone to non-Plone users. That might even replace buildout on simpler deployment projects.

Still, buildout has it's advantages. I wouldn't miss mr.developer to be able to check out any repository while developing.

Does installing via pip mean that no C-optimized but only the Python fallback code is used? (e.g. AccessControl, Acquisition, etc)

I didn't say it's bad (well, it is pretty slow nowadays). Personally, I'm investigating buildoutless build for building containers (either with Docker or with Nix), and it would help also me if there were official requirements.txts maintained :slight_smile:

I skipped that era :frowning: When I did Plone for the first time there was only Products. When I came back, there was already buildout. Yet, I'd guess it would be related to version pins.

Agreed. mr.developer is definitely more flexible way to manage multiple developed packages than just installing packages in develop mode into virtualenv. Also there is no yet alternatives for creating Plone configuration with buildout (not to mention all the other recipes). (Well, I have now a zope.conf-generator for Nix, but that one is not compatible with this thread :slight_smile:

That depends on the availability of wheels for those packages. If there is properly build wheel available, that should include optimizations.

So, having a pip based Docker image could be even easier, because using and extending it would follow common Docker practices? :slight_smile:

I'm not aware of any disadvantages of installing addons via pip. Buildout is doing the same. We need z3c.autoinclude for that to work, but that shouldn't be a problem either...

Did you take a look at pipenv? I use it already for some buildouts locally, just travis has currently some problems I couldn't solve.

That can be easily accomplished with pipenv/pipfile as well :wink:

1 Like

includePlugins part of z3c.autoinclude (for entrypoint=plone) works fine also with pip

Is it worth a PLIP for Plone 5.2? We would need an official requirements.cfg and constraints.cfg, documentation and whats else?

2 Likes

I'm interpreting the negation as a typo - you mean like pip install -e git+https://github.com/plone/Products.CMFPlone.git@5.1rc2#Products.CMFPlone?

That does a source checkout egg develop into your virtualenv and you can then point your editor at it and hack at it as usual. You can use any @refspec (omitting this parametre means HEAD of default branch). Also can go into requirements.txt. The #eggname syntax is a bit weird, but it flags up a warning if you omit it, so it's probably there to make sure the eggname and reponame are not different from each other.

1 Like

Let's not let this block 5.2. To make this officially supported requires possibly a sprint worth of work:

  • pip branch of z3c.autoinclude should be released somehow
  • use includeDependencies-directive in Plone should probably be deprecated and it should be removed from the few remaining core packages using it; currently pip installed Plone only starts when that directive is disabled by special environment variable
  • full path for site.zcml should be configurable in zope.conf (now Zope2 loads it from instancehome/etc)
  • scripts generated by plone.recipe.zope2instance and plone.recipe.zeoserver need a new home (now they are in my branch of plonecli)
  • we need tool for generating site.zcml and zope.conf (e.g. templates bundled with plonecli)
1 Like

Early July good for you?

3 Likes

Just an update to this, I made a comment on this ticket https://github.com/plone/plone.docker/issues/89 with some work we did on this for creating a Docker image that does not bundle a packaging tool in a packaging tool (no more buildout).

I'd be interested in seeing if there is interest in getting the pip install Plone story moved further along as it will pave the way to nice Docker images.

1 Like

Join us at the Alpine City Sprint :smiley: it is a topic there! https://alpinecity.tirol/2020

1 Like

Plone Foundation Code of Conduct