Initial support for Python 3 apps

Changes uwsgi plugin accordingly
feature/python3
Rui Carmo 2016-08-18 23:37:44 +01:00
rodzic fa6ec6b44f
commit 35d9b39cf2
1 zmienionych plików z 22 dodań i 3 usunięć

25
piku.py
Wyświetl plik

@ -292,6 +292,8 @@ def spawn_app(app, deltas={}):
virtualenv_path = join(ENV_ROOT, app) virtualenv_path = join(ENV_ROOT, app)
# Settings shipped with the app # Settings shipped with the app
env_file = join(APP_ROOT, app, 'ENV') env_file = join(APP_ROOT, app, 'ENV')
# Python version marker
python_version = join(APP_ROOT, app, '.python_version')
# Custom overrides # Custom overrides
settings = join(ENV_ROOT, app, 'ENV') settings = join(ENV_ROOT, app, 'ENV')
# Live settings # Live settings
@ -313,7 +315,14 @@ def spawn_app(app, deltas={}):
# Load environment variables shipped with repo (if any) # Load environment variables shipped with repo (if any)
if exists(env_file): if exists(env_file):
env.update(parse_settings(env_file, env)) env.update(parse_settings(env_file, env))
# Set Python runtime
env['PYTHON_MAJOR_VERSION'] = '2'
if exists(python_version):
with open(python_version) as h:
if h.read().strip()[0] == '3'
env['PYTHON_MAJOR_VERSION'] = '3'
# Override with custom settings (if any) # Override with custom settings (if any)
if exists(settings): if exists(settings):
env.update(parse_settings(settings, env)) env.update(parse_settings(settings, env))
@ -439,11 +448,21 @@ def spawn_worker(app, kind, command, env, ordinal=1):
('log-backupname', '%s.%d.log.old' % (join(LOG_ROOT, app, kind), ordinal)), ('log-backupname', '%s.%d.log.old' % (join(LOG_ROOT, app, kind), ordinal)),
] ]
if kind == 'wsgi': if kind == 'wsgi':
if env['PYTHON_MAJOR_VERSION'] == '2':
if env.get('PYTHON_GEVENT','false').lower() == "true":
settings.extend([('plugin', 'gevent-python')])
else:
settings.extend([('plugin', 'python')])
else:
if env.get('PYTHON_ASYNCIO','false').lower() == "true":
settings.extend([('plugin', 'asyncio-python3')])
else:
settings.extend([('plugin', 'python3')])
settings.extend([ settings.extend([
('module', command), ('module', command),
('threads', env.get('UWSGI_THREADS','4')), ('threads', env.get('UWSGI_THREADS','4')),
('plugin', 'python'),
]) ])
if 'UWSGI_GEVENT' in env: if 'UWSGI_GEVENT' in env:
settings.extend([ settings.extend([