##// END OF EJS Templates
celery: upgrade to Celery 5.0 ... and adjust for Click API...
Mads Kiilerich -
r8619:385d1b31 default
parent child Browse files
Show More
@@ -1,46 +1,53 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 # This program is free software: you can redistribute it and/or modify
2 # This program is free software: you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation, either version 3 of the License, or
4 # the Free Software Foundation, either version 3 of the License, or
5 # (at your option) any later version.
5 # (at your option) any later version.
6 #
6 #
7 # This program is distributed in the hope that it will be useful,
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
10 # GNU General Public License for more details.
11 #
11 #
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import celery.bin.worker
16 import click
15 import click
16 from celery.bin.celery import celery as celery_command
17
17
18 import kallithea
18 import kallithea
19 import kallithea.bin.kallithea_cli_base as cli_base
19 import kallithea.bin.kallithea_cli_base as cli_base
20 from kallithea.lib import celery_app
20 from kallithea.lib import celery_app
21 from kallithea.lib.utils2 import asbool
21 from kallithea.lib.utils2 import asbool
22
22
23
23
24 @cli_base.register_command(needs_config_file=True)
24 @cli_base.register_command(needs_config_file=True)
25 @click.argument('celery_args', nargs=-1)
25 @click.argument('celery_args', nargs=-1)
26 def celery_run(celery_args, config):
26 def celery_run(celery_args, config):
27 """Start Celery worker(s) for asynchronous tasks.
27 """Start Celery worker(s) for asynchronous tasks.
28
28
29 This commands starts the Celery daemon which will spawn workers to handle
29 This commands starts the Celery daemon which will spawn workers to handle
30 certain asynchronous tasks for Kallithea.
30 certain asynchronous tasks for Kallithea.
31
31
32 Any extra arguments you pass to this command will be passed through to
32 Any extra arguments you pass to this command will be passed through to
33 Celery. Use '--' before such extra arguments to avoid options to be parsed
33 Celery. Use '--' before such extra arguments to avoid options to be parsed
34 by this CLI command.
34 by this CLI command.
35 """
35 """
36
36
37 if not asbool(config.get('use_celery')):
37 if not asbool(config.get('use_celery')):
38 raise Exception('Please set use_celery = true in .ini config '
38 raise Exception('Please set use_celery = true in .ini config '
39 'file before running this command')
39 'file before running this command')
40
40
41 kallithea.CELERY_APP.config_from_object(celery_app.make_celery_config(config))
41 kallithea.CELERY_APP.config_from_object(celery_app.make_celery_config(config))
42
42
43 kallithea.CELERY_APP.loader.on_worker_process_init = lambda: kallithea.config.application.make_app(config.global_conf, **config.local_conf)
43 kallithea.CELERY_APP.loader.on_worker_process_init = lambda: kallithea.config.application.make_app(config.global_conf, **config.local_conf)
44
44
45 cmd = celery.bin.worker.worker(kallithea.CELERY_APP)
45 args = list(celery_args)
46 return cmd.run_from_argv(None, command='celery-run -c CONFIG_FILE --', argv=list(celery_args))
46 # args[0] is generally ignored when prog_name is specified, but -h *needs* it to be 'worker' ... but will also suggest that users specify 'worker' explicitly
47 if not args or args[0] != 'worker':
48 args.insert(0, 'worker')
49
50 # inline kallithea.CELERY_APP.start in order to allow specifying prog_name
51 assert celery_command.params[0].name == 'app'
52 celery_command.params[0].default = kallithea.CELERY_APP
53 celery_command.main(args=args, prog_name='kallithea-cli celery-run -c CONFIG_FILE --')
@@ -1,161 +1,161 b''
1 #!/usr/bin/env python3
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
2 # -*- coding: utf-8 -*-
3 import os
3 import os
4 import platform
4 import platform
5 import re
5 import re
6 import sys
6 import sys
7
7
8 import setuptools
8 import setuptools
9 # monkey patch setuptools to use distutils owner/group functionality
9 # monkey patch setuptools to use distutils owner/group functionality
10 from setuptools.command import sdist
10 from setuptools.command import sdist
11
11
12
12
13 if sys.version_info < (3, 6):
13 if sys.version_info < (3, 6):
14 raise Exception('Kallithea requires Python 3.6 or later')
14 raise Exception('Kallithea requires Python 3.6 or later')
15
15
16
16
17 here = os.path.abspath(os.path.dirname(__file__))
17 here = os.path.abspath(os.path.dirname(__file__))
18
18
19
19
20 def _get_meta_var(name, data, callback_handler=None):
20 def _get_meta_var(name, data, callback_handler=None):
21 matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
21 matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
22 if matches:
22 if matches:
23 s = eval(matches.groups()[0])
23 s = eval(matches.groups()[0])
24 if callable(callback_handler):
24 if callable(callback_handler):
25 return callback_handler(s)
25 return callback_handler(s)
26 return s
26 return s
27
27
28 _meta = open(os.path.join(here, 'kallithea', '__init__.py'), 'r')
28 _meta = open(os.path.join(here, 'kallithea', '__init__.py'), 'r')
29 _metadata = _meta.read()
29 _metadata = _meta.read()
30 _meta.close()
30 _meta.close()
31
31
32 def callback(V):
32 def callback(V):
33 return '.'.join(map(str, V[:3])) + '.'.join(V[3:])
33 return '.'.join(map(str, V[:3])) + '.'.join(V[3:])
34 __version__ = _get_meta_var('VERSION', _metadata, callback)
34 __version__ = _get_meta_var('VERSION', _metadata, callback)
35 __license__ = _get_meta_var('__license__', _metadata)
35 __license__ = _get_meta_var('__license__', _metadata)
36 __author__ = _get_meta_var('__author__', _metadata)
36 __author__ = _get_meta_var('__author__', _metadata)
37 __url__ = _get_meta_var('__url__', _metadata)
37 __url__ = _get_meta_var('__url__', _metadata)
38 # defines current platform
38 # defines current platform
39 __platform__ = platform.system()
39 __platform__ = platform.system()
40
40
41 is_windows = __platform__ in ['Windows']
41 is_windows = __platform__ in ['Windows']
42
42
43 requirements = [
43 requirements = [
44 "alembic >= 1.0.10, < 1.5",
44 "alembic >= 1.0.10, < 1.5",
45 "gearbox >= 0.1.0, < 1",
45 "gearbox >= 0.1.0, < 1",
46 "waitress >= 0.8.8, < 1.5",
46 "waitress >= 0.8.8, < 1.5",
47 "WebOb >= 1.8, < 1.9",
47 "WebOb >= 1.8, < 1.9",
48 "backlash >= 0.1.2, < 1",
48 "backlash >= 0.1.2, < 1",
49 "TurboGears2 >= 2.4, < 2.5",
49 "TurboGears2 >= 2.4, < 2.5",
50 "tgext.routes >= 0.2.0, < 1",
50 "tgext.routes >= 0.2.0, < 1",
51 "Beaker >= 1.10.1, < 2",
51 "Beaker >= 1.10.1, < 2",
52 "WebHelpers2 >= 2.0, < 2.1",
52 "WebHelpers2 >= 2.0, < 2.1",
53 "FormEncode >= 1.3.1, < 1.4",
53 "FormEncode >= 1.3.1, < 1.4",
54 "SQLAlchemy >= 1.2.9, < 1.4",
54 "SQLAlchemy >= 1.2.9, < 1.4",
55 "Mako >= 0.9.1, < 1.2",
55 "Mako >= 0.9.1, < 1.2",
56 "Pygments >= 2.2.0, < 2.7",
56 "Pygments >= 2.2.0, < 2.7",
57 "Whoosh >= 2.7.1, < 2.8",
57 "Whoosh >= 2.7.1, < 2.8",
58 "celery >= 4.3, < 4.5, != 4.4.4", # 4.4.4 is broken due to unexpressed dependency on 'future', see https://github.com/celery/celery/pull/6146
58 "celery >= 5, < 5.1",
59 "Babel >= 1.3, < 2.9",
59 "Babel >= 1.3, < 2.9",
60 "python-dateutil >= 2.1.0, < 2.9",
60 "python-dateutil >= 2.1.0, < 2.9",
61 "Markdown >= 2.2.1, < 3.2",
61 "Markdown >= 2.2.1, < 3.2",
62 "docutils >= 0.11, < 0.17",
62 "docutils >= 0.11, < 0.17",
63 "URLObject >= 2.3.4, < 2.5",
63 "URLObject >= 2.3.4, < 2.5",
64 "Routes >= 2.0, < 2.5",
64 "Routes >= 2.0, < 2.5",
65 "dulwich >= 0.19.0, < 0.20",
65 "dulwich >= 0.19.0, < 0.20",
66 "mercurial >= 5.2, < 5.7",
66 "mercurial >= 5.2, < 5.7",
67 "decorator >= 4.2.1, < 4.5",
67 "decorator >= 4.2.1, < 4.5",
68 "Paste >= 2.0.3, < 3.5",
68 "Paste >= 2.0.3, < 3.5",
69 "bleach >= 3.0, < 3.1.4",
69 "bleach >= 3.0, < 3.1.4",
70 "Click >= 7.0, < 8",
70 "Click >= 7.0, < 8",
71 "ipaddr >= 2.2.0, < 2.3",
71 "ipaddr >= 2.2.0, < 2.3",
72 "paginate >= 0.5, < 0.6",
72 "paginate >= 0.5, < 0.6",
73 "paginate_sqlalchemy >= 0.3.0, < 0.4",
73 "paginate_sqlalchemy >= 0.3.0, < 0.4",
74 "bcrypt >= 3.1.0, < 3.2",
74 "bcrypt >= 3.1.0, < 3.2",
75 "pip >= 20.0, < 999",
75 "pip >= 20.0, < 999",
76 ]
76 ]
77
77
78 dependency_links = [
78 dependency_links = [
79 ]
79 ]
80
80
81 classifiers = [
81 classifiers = [
82 'Development Status :: 4 - Beta',
82 'Development Status :: 4 - Beta',
83 'Environment :: Web Environment',
83 'Environment :: Web Environment',
84 'Framework :: Pylons',
84 'Framework :: Pylons',
85 'Intended Audience :: Developers',
85 'Intended Audience :: Developers',
86 'License :: OSI Approved :: GNU General Public License (GPL)',
86 'License :: OSI Approved :: GNU General Public License (GPL)',
87 'Operating System :: OS Independent',
87 'Operating System :: OS Independent',
88 'Programming Language :: Python :: 3.6',
88 'Programming Language :: Python :: 3.6',
89 'Programming Language :: Python :: 3.7',
89 'Programming Language :: Python :: 3.7',
90 'Programming Language :: Python :: 3.8',
90 'Programming Language :: Python :: 3.8',
91 'Topic :: Software Development :: Version Control',
91 'Topic :: Software Development :: Version Control',
92 ]
92 ]
93
93
94
94
95 # additional files from project that goes somewhere in the filesystem
95 # additional files from project that goes somewhere in the filesystem
96 # relative to sys.prefix
96 # relative to sys.prefix
97 data_files = []
97 data_files = []
98
98
99 description = ('Kallithea is a fast and powerful management tool '
99 description = ('Kallithea is a fast and powerful management tool '
100 'for Mercurial and Git with a built in push/pull server, '
100 'for Mercurial and Git with a built in push/pull server, '
101 'full text search and code-review.')
101 'full text search and code-review.')
102
102
103 keywords = ' '.join([
103 keywords = ' '.join([
104 'kallithea', 'mercurial', 'git', 'code review',
104 'kallithea', 'mercurial', 'git', 'code review',
105 'repo groups', 'ldap', 'repository management', 'hgweb replacement',
105 'repo groups', 'ldap', 'repository management', 'hgweb replacement',
106 'hgwebdir', 'gitweb replacement', 'serving hgweb',
106 'hgwebdir', 'gitweb replacement', 'serving hgweb',
107 ])
107 ])
108
108
109 # long description
109 # long description
110 README_FILE = 'README.rst'
110 README_FILE = 'README.rst'
111 try:
111 try:
112 long_description = open(README_FILE).read()
112 long_description = open(README_FILE).read()
113 except IOError as err:
113 except IOError as err:
114 sys.stderr.write(
114 sys.stderr.write(
115 "[WARNING] Cannot find file specified as long_description (%s): %s\n"
115 "[WARNING] Cannot find file specified as long_description (%s): %s\n"
116 % (README_FILE, err)
116 % (README_FILE, err)
117 )
117 )
118 long_description = description
118 long_description = description
119
119
120
120
121 sdist_org = sdist.sdist
121 sdist_org = sdist.sdist
122 class sdist_new(sdist_org):
122 class sdist_new(sdist_org):
123 def initialize_options(self):
123 def initialize_options(self):
124 sdist_org.initialize_options(self)
124 sdist_org.initialize_options(self)
125 self.owner = self.group = 'root'
125 self.owner = self.group = 'root'
126 sdist.sdist = sdist_new
126 sdist.sdist = sdist_new
127
127
128 packages = setuptools.find_packages(exclude=['ez_setup'])
128 packages = setuptools.find_packages(exclude=['ez_setup'])
129
129
130 setuptools.setup(
130 setuptools.setup(
131 name='Kallithea',
131 name='Kallithea',
132 version=__version__,
132 version=__version__,
133 description=description,
133 description=description,
134 long_description=long_description,
134 long_description=long_description,
135 keywords=keywords,
135 keywords=keywords,
136 license=__license__,
136 license=__license__,
137 author=__author__,
137 author=__author__,
138 author_email='kallithea@sfconservancy.org',
138 author_email='kallithea@sfconservancy.org',
139 dependency_links=dependency_links,
139 dependency_links=dependency_links,
140 url=__url__,
140 url=__url__,
141 install_requires=requirements,
141 install_requires=requirements,
142 classifiers=classifiers,
142 classifiers=classifiers,
143 data_files=data_files,
143 data_files=data_files,
144 packages=packages,
144 packages=packages,
145 include_package_data=True,
145 include_package_data=True,
146 message_extractors={'kallithea': [
146 message_extractors={'kallithea': [
147 ('**.py', 'python', None),
147 ('**.py', 'python', None),
148 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
148 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
149 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
149 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
150 ('public/**', 'ignore', None)]},
150 ('public/**', 'ignore', None)]},
151 zip_safe=False,
151 zip_safe=False,
152 entry_points="""
152 entry_points="""
153 [console_scripts]
153 [console_scripts]
154 kallithea-api = kallithea.bin.kallithea_api:main
154 kallithea-api = kallithea.bin.kallithea_api:main
155 kallithea-gist = kallithea.bin.kallithea_gist:main
155 kallithea-gist = kallithea.bin.kallithea_gist:main
156 kallithea-cli = kallithea.bin.kallithea_cli:cli
156 kallithea-cli = kallithea.bin.kallithea_cli:cli
157
157
158 [paste.app_factory]
158 [paste.app_factory]
159 main = kallithea.config.application:make_app
159 main = kallithea.config.application:make_app
160 """,
160 """,
161 )
161 )
General Comments 0
You need to be logged in to leave comments. Login now