plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
254 stars 191 forks source link

Document Python 3 buildout #2041

Closed pbauer closed 2 years ago

pbauer commented 7 years ago

Document how to create a buildout that can test plone-packages against Python 3

pbauer commented 7 years ago

To be able to run test of plone-packages with python 3 locally you need to create a coredev-buildout along this example:

#!/bin/bash
git clone git@github.com:plone/buildout.coredev.git coredev-py3
cd coredev-py3
python3 -m venv .
source bin/activate
pip install -U setuptools zc.buildout
./bin/buildout -c experimental/py3x-test.cfg

This is also how the jenkings-job http://jenkins.plone.org/view/py3/job/py3-test/ is run ( https://github.com/plone/jenkins.plone.org/blob/master/scripts/pkg-py3.sh)

Run the tests with ./bin/test Add packages that are ported to Python 3 to experimental/py3x-test.cfg.

gforcada commented 7 years ago

That's quite a nice writeup 😆 thanks for documenting it!

loechel commented 7 years ago

@pbauer could this go into the standard documentation and maybe the buildout.coredev documentation please

tomgross commented 7 years ago

I created a gist with the updated version of the script: https://gist.github.com/tomgross/94109bdef51547f07a2a0cc3be2dac0e

rodfersou commented 7 years ago

wow! UnicodeError never more!

pbauer commented 6 years ago

In https://github.com/plone/Products.CMFPlone/issues/2184#issuecomment-359445243 I also now documented how to run the whole of Plone (without AT) in python3. I copy it here for completeness sake.

Running Plone on Python 3

The config py3.cfg (https://github.com/plone/buildout.coredev/blob/5.2/py3.cfg) can be used to build and run Plone on Python3. It removes the Arcetypes-dependecies that will not be ported to python3. In your own projects you could add a similar effect by depending only on Products.CMFPlone instead of Plone.

The config depends on wsgi.cfg for wsgi-support and adds checkouts and branches with python3 compatability that is work-in progress.

It also removes a lot of parts that either break at the moment or are not necessary before startup works.

Clone coredev and use branch 5.2::

$ git clone git@github.com:plone/buildout.coredev.git coredev_py3
$ cd coredev_py3
$ git checkout 5.2

Create py3 virtualenv::

$ python3.6 -m venv .

Install buildout::

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

Run buildout::

$ ./bin/buildout -c py3.cfg

Start Plone::

 $ ./bin/wsgi
pbauer commented 6 years ago

Since python 3 support was merged in Plone 5.2 the above documentation is outdated.

Here is how you do that now:

Running Plone 5.2 on Python 3

The configuration-file buildout.cfg (https://github.com/plone/buildout.coredev/blob/5.2/buildout.cfg) can be used to build Plone on Python 2 and 3. It will only include Archetypes-dependecies when running on python 2.

Clone coredev and use branch 5.2:

$ git clone git@github.com:plone/buildout.coredev.git coredev_py3
$ cd coredev_py3
$ git checkout 5.2

Create a py3 virtualenv with either Python 3.6 or 3.7 (they are very similar):

$ python3.7 -m venv .

Install buildout:

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

Run buildout:

$ ./bin/buildout

Start Plone:

 $ ./bin/instance fg

By default Plone it will then run on port 8080 using the wsgi-server waitress: http://localhost:8080

You can easily extend that buildout by for example adding your own file local.cfg which then specifies a addon you want to migrate/test in Plone on Python 3.

The following example would add plone.tiles and collective.easyform to the buildout:

[buildout]
extends = buildout.cfg

always-checkout = true

custom-eggs +=
    collective.easyform
    plone.tiles

test-eggs +=
    collective.easyform [test]
    plone.tiles [test]

auto-checkout +=
    collective.easyform
    plone.tiles

[sources]
collective.easyform = git git@github.com:collective/collective.easyform.git branch=python3
plone.tiles = git git@github.com:plone/plone.tiles.git branch=python3

You can build this configuration now using ./bin/buildout -c local.cfg

staeff commented 6 years ago

Start Plone:

 $ ./bin/wsgi

@pbauer I was curious to try it out after your talk. The command to run an instance with python3 is back to $ ./bin/instance fg, right?

pbauer commented 6 years ago

yes, I updated that part.