##// END OF EJS Templates
setuptools: versioning and licensing updated
ergo -
r29:f648fb29 0.9.0
parent child Browse files
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -0,0 +1,1 b''
1 0.9.0
@@ -1,60 +1,77 b''
1 import os
1 import os
2 import sys
2 import sys
3 import re
3 import re
4
4
5 from setuptools import setup, find_packages
5 from setuptools import setup, find_packages
6
6
7 here = os.path.abspath(os.path.dirname(__file__))
7 here = os.path.abspath(os.path.dirname(__file__))
8 README = open(os.path.join(here, 'README.md')).read()
8 README = open(os.path.join(here, 'README.md')).read()
9 CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
9 CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
10
10
11 REQUIREMENTS = open(os.path.join(here, 'requirements.txt')).readlines()
11 REQUIREMENTS = open(os.path.join(here, 'requirements.txt')).readlines()
12
12
13 compiled = re.compile('([^=><]*).*')
13 compiled = re.compile('([^=><]*).*')
14
14
15
15
16 def parse_req(req):
16 def parse_req(req):
17 return compiled.search(req).group(1).strip()
17 return compiled.search(req).group(1).strip()
18
18
19
19
20 requires = [_f for _f in map(parse_req, REQUIREMENTS) if _f]
20 requires = [_f for _f in map(parse_req, REQUIREMENTS) if _f]
21
21
22 if sys.version_info[:3] < (2, 5, 0):
22
23 requires.append('pysqlite')
23 def _get_meta_var(name, data, callback_handler=None):
24 import re
25 matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
26 if matches:
27 if not callable(callback_handler):
28 callback_handler = lambda v: v
29
30 return callback_handler(eval(matches.groups()[0]))
31
32 with open(os.path.join(here, 'src', 'appenlight', '__init__.py'), 'r') as _meta:
33 _metadata = _meta.read()
34
35 with open(os.path.join('src', 'appenlight', 'VERSION')) as _meta_version:
36 __version__ = _meta_version.read().strip()
37
38 __license__ = _get_meta_var('__license__', _metadata)
39 __author__ = _get_meta_var('__author__', _metadata)
40 __url__ = _get_meta_var('__url__', _metadata)
24
41
25 found_packages = find_packages('src')
42 found_packages = find_packages('src')
26 found_packages.append('appenlight.migrations.versions')
43 found_packages.append('appenlight.migrations.versions')
27 setup(name='appenlight',
44 setup(name='appenlight',
28 version='0.1',
29 description='appenlight',
45 description='appenlight',
30 long_description=README + '\n\n' + CHANGES,
46 long_description=README + '\n\n' + CHANGES,
31 classifiers=[
47 classifiers=[
32 "Programming Language :: Python",
48 "Programming Language :: Python",
33 "Framework :: Pylons",
49 "Framework :: Pylons",
34 "Topic :: Internet :: WWW/HTTP",
50 "Topic :: Internet :: WWW/HTTP",
35 "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
51 "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
36 ],
52 ],
37 author='',
53 version=__version__,
38 author_email='',
54 license=__license__,
39 url='',
55 author=__author__,
56 url=__url__,
40 keywords='web wsgi bfg pylons pyramid',
57 keywords='web wsgi bfg pylons pyramid',
41 package_dir={'': 'src'},
58 package_dir={'': 'src'},
42 packages=found_packages,
59 packages=found_packages,
43 include_package_data=True,
60 include_package_data=True,
44 zip_safe=False,
61 zip_safe=False,
45 test_suite='appenlight',
62 test_suite='appenlight',
46 install_requires=requires,
63 install_requires=requires,
47 entry_points={
64 entry_points={
48 'paste.app_factory': [
65 'paste.app_factory': [
49 'main = appenlight:main'
66 'main = appenlight:main'
50 ],
67 ],
51 'console_scripts': [
68 'console_scripts': [
52 'appenlight-cleanup = appenlight.scripts.cleanup:main',
69 'appenlight-cleanup = appenlight.scripts.cleanup:main',
53 'appenlight-initializedb = appenlight.scripts.initialize_db:main',
70 'appenlight-initializedb = appenlight.scripts.initialize_db:main',
54 'appenlight-migratedb = appenlight.scripts.migratedb:main',
71 'appenlight-migratedb = appenlight.scripts.migratedb:main',
55 'appenlight-reindex-elasticsearch = appenlight.scripts.reindex_elasticsearch:main',
72 'appenlight-reindex-elasticsearch = appenlight.scripts.reindex_elasticsearch:main',
56 'appenlight-static = appenlight.scripts.static:main',
73 'appenlight-static = appenlight.scripts.static:main',
57 'appenlight-make-config = appenlight.scripts.make_config:main',
74 'appenlight-make-config = appenlight.scripts.make_config:main',
58 ]
75 ]
59 }
76 }
60 )
77 )
@@ -1,218 +1,222 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2010-2016 RhodeCode GmbH
3 # Copyright (C) 2010-2016 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # AppEnlight Enterprise Edition, including its added features, Support
18 # AppEnlight Enterprise Edition, including its added features, Support
19 # services, and proprietary license terms, please see
19 # services, and proprietary license terms, please see
20 # https://rhodecode.com/licenses/
20 # https://rhodecode.com/licenses/
21
21
22 import datetime
22 import datetime
23 import logging
23 import logging
24 import pyelasticsearch
24 import pyelasticsearch
25 import redis
25 import redis
26 import os
26 import os
27 from pkg_resources import iter_entry_points
27 from pkg_resources import iter_entry_points
28
28
29 import appenlight.lib.jinja2_filters as jinja2_filters
29 import appenlight.lib.jinja2_filters as jinja2_filters
30 import appenlight.lib.encryption as encryption
30 import appenlight.lib.encryption as encryption
31
31
32 from pyramid.config import PHASE3_CONFIG
32 from pyramid.config import PHASE3_CONFIG
33 from pyramid.authentication import AuthTktAuthenticationPolicy
33 from pyramid.authentication import AuthTktAuthenticationPolicy
34 from pyramid.authorization import ACLAuthorizationPolicy
34 from pyramid.authorization import ACLAuthorizationPolicy
35 from pyramid_mailer.mailer import Mailer
35 from pyramid_mailer.mailer import Mailer
36 from pyramid.renderers import JSON
36 from pyramid.renderers import JSON
37 from pyramid_redis_sessions import session_factory_from_settings
37 from pyramid_redis_sessions import session_factory_from_settings
38 from pyramid.settings import asbool, aslist
38 from pyramid.settings import asbool, aslist
39 from pyramid.security import AllPermissionsList
39 from pyramid.security import AllPermissionsList
40 from pyramid_authstack import AuthenticationStackPolicy
40 from pyramid_authstack import AuthenticationStackPolicy
41 from redlock import Redlock
41 from redlock import Redlock
42 from sqlalchemy import engine_from_config
42 from sqlalchemy import engine_from_config
43
43
44 from appenlight.celery import configure_celery
44 from appenlight.celery import configure_celery
45 from appenlight.lib.configurator import (CythonCompatConfigurator,
45 from appenlight.lib.configurator import (CythonCompatConfigurator,
46 register_appenlight_plugin)
46 register_appenlight_plugin)
47 from appenlight.lib import cache_regions
47 from appenlight.lib import cache_regions
48 from appenlight.lib.ext_json import json
48 from appenlight.lib.ext_json import json
49 from appenlight.security import groupfinder, AuthTokenAuthenticationPolicy
49 from appenlight.security import groupfinder, AuthTokenAuthenticationPolicy
50
50
51 __license__ = 'AGPLv3, and Commercial License'
52 __author__ = 'RhodeCode GmbH'
53 __url__ = 'http://rhodecode.com'
54
51 json_renderer = JSON(serializer=json.dumps, indent=4)
55 json_renderer = JSON(serializer=json.dumps, indent=4)
52
56
53 log = logging.getLogger(__name__)
57 log = logging.getLogger(__name__)
54
58
55
59
56 def datetime_adapter(obj, request):
60 def datetime_adapter(obj, request):
57 return obj.isoformat()
61 return obj.isoformat()
58
62
59
63
60 def all_permissions_adapter(obj, request):
64 def all_permissions_adapter(obj, request):
61 return '__all_permissions__'
65 return '__all_permissions__'
62
66
63
67
64 json_renderer.add_adapter(datetime.datetime, datetime_adapter)
68 json_renderer.add_adapter(datetime.datetime, datetime_adapter)
65 json_renderer.add_adapter(AllPermissionsList, all_permissions_adapter)
69 json_renderer.add_adapter(AllPermissionsList, all_permissions_adapter)
66
70
67
71
68 def main(global_config, **settings):
72 def main(global_config, **settings):
69 """ This function returns a Pyramid WSGI application.
73 """ This function returns a Pyramid WSGI application.
70 """
74 """
71 auth_tkt_policy = AuthTktAuthenticationPolicy(
75 auth_tkt_policy = AuthTktAuthenticationPolicy(
72 settings['authtkt.secret'],
76 settings['authtkt.secret'],
73 hashalg='sha512',
77 hashalg='sha512',
74 callback=groupfinder,
78 callback=groupfinder,
75 max_age=2592000,
79 max_age=2592000,
76 secure=asbool(settings.get('authtkt.secure', 'false')))
80 secure=asbool(settings.get('authtkt.secure', 'false')))
77 auth_token_policy = AuthTokenAuthenticationPolicy(
81 auth_token_policy = AuthTokenAuthenticationPolicy(
78 callback=groupfinder
82 callback=groupfinder
79 )
83 )
80 authorization_policy = ACLAuthorizationPolicy()
84 authorization_policy = ACLAuthorizationPolicy()
81 authentication_policy = AuthenticationStackPolicy()
85 authentication_policy = AuthenticationStackPolicy()
82 authentication_policy.add_policy('auth_tkt', auth_tkt_policy)
86 authentication_policy.add_policy('auth_tkt', auth_tkt_policy)
83 authentication_policy.add_policy('auth_token', auth_token_policy)
87 authentication_policy.add_policy('auth_token', auth_token_policy)
84 # set crypto key
88 # set crypto key
85 encryption.ENCRYPTION_SECRET = settings.get('encryption_secret')
89 encryption.ENCRYPTION_SECRET = settings.get('encryption_secret')
86 # import this later so encyption key can be monkeypatched
90 # import this later so encyption key can be monkeypatched
87 from appenlight.models import DBSession, register_datastores
91 from appenlight.models import DBSession, register_datastores
88 # update config with cometd info
92 # update config with cometd info
89 settings['cometd_servers'] = {'server': settings['cometd.server'],
93 settings['cometd_servers'] = {'server': settings['cometd.server'],
90 'secret': settings['cometd.secret']}
94 'secret': settings['cometd.secret']}
91
95
92 # Create the Pyramid Configurator.
96 # Create the Pyramid Configurator.
93 settings['_mail_url'] = settings['mailing.app_url']
97 settings['_mail_url'] = settings['mailing.app_url']
94 config = CythonCompatConfigurator(
98 config = CythonCompatConfigurator(
95 settings=settings,
99 settings=settings,
96 authentication_policy=authentication_policy,
100 authentication_policy=authentication_policy,
97 authorization_policy=authorization_policy,
101 authorization_policy=authorization_policy,
98 root_factory='appenlight.security.RootFactory',
102 root_factory='appenlight.security.RootFactory',
99 default_permission='view')
103 default_permission='view')
100 # custom registry variables
104 # custom registry variables
101
105
102 # resource type information
106 # resource type information
103 config.registry.resource_types = ['resource', 'application']
107 config.registry.resource_types = ['resource', 'application']
104 # plugin information
108 # plugin information
105 config.registry.appenlight_plugins = {}
109 config.registry.appenlight_plugins = {}
106
110
107 config.set_default_csrf_options(require_csrf=True, header='X-XSRF-TOKEN')
111 config.set_default_csrf_options(require_csrf=True, header='X-XSRF-TOKEN')
108 config.add_view_deriver('appenlight.predicates.csrf_view',
112 config.add_view_deriver('appenlight.predicates.csrf_view',
109 name='csrf_view')
113 name='csrf_view')
110
114
111 # later, when config is available
115 # later, when config is available
112 dogpile_config = {'url': settings['redis.url'],
116 dogpile_config = {'url': settings['redis.url'],
113 "redis_expiration_time": 86400,
117 "redis_expiration_time": 86400,
114 "redis_distributed_lock": True}
118 "redis_distributed_lock": True}
115 cache_regions.regions = cache_regions.CacheRegions(dogpile_config)
119 cache_regions.regions = cache_regions.CacheRegions(dogpile_config)
116 config.registry.cache_regions = cache_regions.regions
120 config.registry.cache_regions = cache_regions.regions
117 engine = engine_from_config(settings, 'sqlalchemy.',
121 engine = engine_from_config(settings, 'sqlalchemy.',
118 json_serializer=json.dumps)
122 json_serializer=json.dumps)
119 DBSession.configure(bind=engine)
123 DBSession.configure(bind=engine)
120
124
121 # json rederer that serializes datetime
125 # json rederer that serializes datetime
122 config.add_renderer('json', json_renderer)
126 config.add_renderer('json', json_renderer)
123 config.set_request_property('appenlight.lib.request.es_conn', 'es_conn')
127 config.set_request_property('appenlight.lib.request.es_conn', 'es_conn')
124 config.set_request_property('appenlight.lib.request.get_user', 'user',
128 config.set_request_property('appenlight.lib.request.get_user', 'user',
125 reify=True)
129 reify=True)
126 config.set_request_property('appenlight.lib.request.get_csrf_token',
130 config.set_request_property('appenlight.lib.request.get_csrf_token',
127 'csrf_token', reify=True)
131 'csrf_token', reify=True)
128 config.set_request_property('appenlight.lib.request.safe_json_body',
132 config.set_request_property('appenlight.lib.request.safe_json_body',
129 'safe_json_body', reify=True)
133 'safe_json_body', reify=True)
130 config.set_request_property('appenlight.lib.request.unsafe_json_body',
134 config.set_request_property('appenlight.lib.request.unsafe_json_body',
131 'unsafe_json_body', reify=True)
135 'unsafe_json_body', reify=True)
132 config.add_request_method('appenlight.lib.request.add_flash_to_headers',
136 config.add_request_method('appenlight.lib.request.add_flash_to_headers',
133 'add_flash_to_headers')
137 'add_flash_to_headers')
134 config.add_request_method('appenlight.lib.request.get_authomatic',
138 config.add_request_method('appenlight.lib.request.get_authomatic',
135 'authomatic', reify=True)
139 'authomatic', reify=True)
136
140
137 config.include('pyramid_redis_sessions')
141 config.include('pyramid_redis_sessions')
138 config.include('pyramid_tm')
142 config.include('pyramid_tm')
139 config.include('pyramid_jinja2')
143 config.include('pyramid_jinja2')
140 config.include('appenlight_client.ext.pyramid_tween')
144 config.include('appenlight_client.ext.pyramid_tween')
141 config.include('ziggurat_foundations.ext.pyramid.sign_in')
145 config.include('ziggurat_foundations.ext.pyramid.sign_in')
142 es_server_list = aslist(settings['elasticsearch.nodes'])
146 es_server_list = aslist(settings['elasticsearch.nodes'])
143 redis_url = settings['redis.url']
147 redis_url = settings['redis.url']
144 log.warning('Elasticsearch server list: {}'.format(es_server_list))
148 log.warning('Elasticsearch server list: {}'.format(es_server_list))
145 log.warning('Redis server: {}'.format(redis_url))
149 log.warning('Redis server: {}'.format(redis_url))
146 config.registry.es_conn = pyelasticsearch.ElasticSearch(es_server_list)
150 config.registry.es_conn = pyelasticsearch.ElasticSearch(es_server_list)
147 config.registry.redis_conn = redis.StrictRedis.from_url(redis_url)
151 config.registry.redis_conn = redis.StrictRedis.from_url(redis_url)
148
152
149 config.registry.redis_lockmgr = Redlock([settings['redis.redlock.url'], ],
153 config.registry.redis_lockmgr = Redlock([settings['redis.redlock.url'], ],
150 retry_count=0, retry_delay=0)
154 retry_count=0, retry_delay=0)
151 # mailer
155 # mailer
152 config.registry.mailer = Mailer.from_settings(settings)
156 config.registry.mailer = Mailer.from_settings(settings)
153
157
154 # Configure sessions
158 # Configure sessions
155 session_factory = session_factory_from_settings(settings)
159 session_factory = session_factory_from_settings(settings)
156 config.set_session_factory(session_factory)
160 config.set_session_factory(session_factory)
157
161
158 # Configure renderers and event subscribers
162 # Configure renderers and event subscribers
159 config.add_jinja2_extension('jinja2.ext.loopcontrols')
163 config.add_jinja2_extension('jinja2.ext.loopcontrols')
160 config.add_jinja2_search_path('appenlight:templates')
164 config.add_jinja2_search_path('appenlight:templates')
161 # event subscribers
165 # event subscribers
162 config.add_subscriber("appenlight.subscribers.application_created",
166 config.add_subscriber("appenlight.subscribers.application_created",
163 "pyramid.events.ApplicationCreated")
167 "pyramid.events.ApplicationCreated")
164 config.add_subscriber("appenlight.subscribers.add_renderer_globals",
168 config.add_subscriber("appenlight.subscribers.add_renderer_globals",
165 "pyramid.events.BeforeRender")
169 "pyramid.events.BeforeRender")
166 config.add_subscriber('appenlight.subscribers.new_request',
170 config.add_subscriber('appenlight.subscribers.new_request',
167 'pyramid.events.NewRequest')
171 'pyramid.events.NewRequest')
168 config.add_view_predicate('context_type_class',
172 config.add_view_predicate('context_type_class',
169 'appenlight.predicates.contextTypeClass')
173 'appenlight.predicates.contextTypeClass')
170
174
171 register_datastores(es_conn=config.registry.es_conn,
175 register_datastores(es_conn=config.registry.es_conn,
172 redis_conn=config.registry.redis_conn,
176 redis_conn=config.registry.redis_conn,
173 redis_lockmgr=config.registry.redis_lockmgr)
177 redis_lockmgr=config.registry.redis_lockmgr)
174
178
175 # base stuff and scan
179 # base stuff and scan
176
180
177 # need to ensure webassets exists otherwise config.override_asset()
181 # need to ensure webassets exists otherwise config.override_asset()
178 # throws exception
182 # throws exception
179 if not os.path.exists(settings['webassets.dir']):
183 if not os.path.exists(settings['webassets.dir']):
180 os.mkdir(settings['webassets.dir'])
184 os.mkdir(settings['webassets.dir'])
181 config.add_static_view(path='appenlight:webassets',
185 config.add_static_view(path='appenlight:webassets',
182 name='static', cache_max_age=3600)
186 name='static', cache_max_age=3600)
183 config.override_asset(to_override='appenlight:webassets/',
187 config.override_asset(to_override='appenlight:webassets/',
184 override_with=settings['webassets.dir'])
188 override_with=settings['webassets.dir'])
185
189
186 config.include('appenlight.views')
190 config.include('appenlight.views')
187 config.include('appenlight.views.admin')
191 config.include('appenlight.views.admin')
188 config.scan(ignore=['appenlight.migrations', 'appenlight.scripts',
192 config.scan(ignore=['appenlight.migrations', 'appenlight.scripts',
189 'appenlight.tests'])
193 'appenlight.tests'])
190
194
191 config.add_directive('register_appenlight_plugin',
195 config.add_directive('register_appenlight_plugin',
192 register_appenlight_plugin)
196 register_appenlight_plugin)
193
197
194 for entry_point in iter_entry_points(group='appenlight.plugins'):
198 for entry_point in iter_entry_points(group='appenlight.plugins'):
195 plugin = entry_point.load()
199 plugin = entry_point.load()
196 plugin.includeme(config)
200 plugin.includeme(config)
197
201
198 # include other appenlight plugins explictly if needed
202 # include other appenlight plugins explictly if needed
199 includes = aslist(settings.get('appenlight.includes', []))
203 includes = aslist(settings.get('appenlight.includes', []))
200 for inc in includes:
204 for inc in includes:
201 config.include(inc)
205 config.include(inc)
202
206
203 # run this after everything registers in configurator
207 # run this after everything registers in configurator
204
208
205 def pre_commit():
209 def pre_commit():
206 jinja_env = config.get_jinja2_environment()
210 jinja_env = config.get_jinja2_environment()
207 jinja_env.filters['tojson'] = json.dumps
211 jinja_env.filters['tojson'] = json.dumps
208 jinja_env.filters['toJSONUnsafe'] = jinja2_filters.toJSONUnsafe
212 jinja_env.filters['toJSONUnsafe'] = jinja2_filters.toJSONUnsafe
209
213
210 config.action(None, pre_commit, order=PHASE3_CONFIG + 999)
214 config.action(None, pre_commit, order=PHASE3_CONFIG + 999)
211
215
212 def wrap_config_celery():
216 def wrap_config_celery():
213 configure_celery(config.registry)
217 configure_celery(config.registry)
214
218
215 config.action(None, wrap_config_celery, order=PHASE3_CONFIG + 999)
219 config.action(None, wrap_config_celery, order=PHASE3_CONFIG + 999)
216
220
217 app = config.make_wsgi_app()
221 app = config.make_wsgi_app()
218 return app
222 return app
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now