moinwiki / moin-1.9

MoinMoin Wiki (1.9, also: 1.5a ... 1.8), stable, for production wikis
https://moinmo.in/
Other
140 stars 51 forks source link

running moinmoin 1.9.x with PyPy #91

Open ThomasWaldmann opened 2 years ago

ThomasWaldmann commented 2 years ago

CPython 2.7 is out of support since quite a while and because of that often removed from new distributions.

But there is pypy (not: pypy3) and you can use it to run moin!

https://www.pypy.org/

ubuntu 22.04:

apt install pypy pypy-dev pypy-setuptools
apt install virtualenv
virtualenv --python=pypy env-pypy
source env-pypy/bin/activate

Now you have a virtual env active with a python 2.7 compatible pypy.

Running moin:

cd moin-1.9
python wikiserver.py

moin will then run on localhost:8080 (this can be changed in wikiserverconfig.py).

ThomasWaldmann commented 2 years ago

Wasn't successful yet installing uwsgi, but gunicorn seems to work:

#!/usr/bin/env pypy

import multiprocessing

import gunicorn.app.base

from MoinMoin.wsgiapp import application as handler_app

class StandaloneApplication(gunicorn.app.base.BaseApplication):

    def __init__(self, app, options=None):
        self.options = options or {}
        self.application = app
        super(StandaloneApplication, self).__init__()

    def load_config(self):
        config = {key: value for key, value in self.options.items()
                  if key in self.cfg.settings and value is not None}
        for key, value in config.items():
            self.cfg.set(key.lower(), value)

    def load(self):
        return self.application

if __name__ == '__main__':
    options = {
        'bind': '%s:%s' % ('0.0.0.0', '8080'),
        'workers': multiprocessing.cpu_count() * 2 + 1,
    }
    StandaloneApplication(handler_app, options).run()