##// END OF EJS Templates
setup: synced with rhodecode tools with better compatability on pip versions
super-admin -
r4897:ff5a3ae7 default
parent child Browse files
Show More
@@ -1,180 +1,208 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2010-2020 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 # Import early to make sure things are patched up properly
22 22 from setuptools import setup, find_packages
23 23
24 24 import os
25 import re
25 26 import sys
26 27 import pkgutil
27 28 import platform
28 29 import codecs
29 30
30 try: # for pip >= 10
31 import pip
32
33 pip_major_version = int(pip.__version__.split(".")[0])
34 if pip_major_version >= 20:
31 35 from pip._internal.req import parse_requirements
32 except ImportError: # for pip <= 9.0.3
36 from pip._internal.network.session import PipSession
37 elif pip_major_version >= 10:
38 from pip._internal.req import parse_requirements
39 from pip._internal.download import PipSession
40 else:
33 41 from pip.req import parse_requirements
42 from pip.download import PipSession
43
34 44
35 try: # for pip >= 10
36 from pip._internal.download import PipSession
37 except ImportError: # for pip <= 9.0.3
38 from pip.download import PipSession
45 def get_package_name(req_object):
46 package_name = None
47 try:
48 from pip._internal.req.constructors import install_req_from_parsed_requirement
49 except ImportError:
50 install_req_from_parsed_requirement = None
51
52 # In 20.1 of pip, the requirements object changed
53 if hasattr(req_object, 'req'):
54 package_name = req_object.req.name
55
56 if package_name is None:
57 if install_req_from_parsed_requirement:
58 package = install_req_from_parsed_requirement(req_object)
59 package_name = package.req.name
60
61 if package_name is None:
62 # fallback for older pip
63 package_name = re.split('===|<=|!=|==|>=|~=|<|>', req_object.requirement)[0]
64
65 return package_name
39 66
40 67
41 68 if sys.version_info < (2, 7):
42 69 raise Exception('RhodeCode requires Python 2.7 or later')
43 70
44 71 here = os.path.abspath(os.path.dirname(__file__))
45 72
46 73 # defines current platform
47 74 __platform__ = platform.system()
48 75 __license__ = 'AGPLv3, and Commercial License'
49 76 __author__ = 'RhodeCode GmbH'
50 77 __url__ = 'https://code.rhodecode.com'
51 78 is_windows = __platform__ in ('Windows',)
52 79
53 80
54 81 def _get_requirements(req_filename, exclude=None, extras=None):
55 82 extras = extras or []
56 83 exclude = exclude or []
57 84
58 85 try:
59 86 parsed = parse_requirements(
60 87 os.path.join(here, req_filename), session=PipSession())
61 88 except TypeError:
62 89 # try pip < 6.0.0, that doesn't support session
63 90 parsed = parse_requirements(os.path.join(here, req_filename))
64 91
65 92 requirements = []
66 for ir in parsed:
67 if ir.req and ir.name not in exclude:
68 requirements.append(str(ir.req))
93 for int_req in parsed:
94 req_name = get_package_name(int_req)
95 if req_name not in exclude:
96 requirements.append(req_name)
69 97 return requirements + extras
70 98
71 99
72 100 # requirements extract
73 setup_requirements = ['PasteScript', 'pytest-runner']
101 setup_requirements = ['PasteScript']
74 102 install_requirements = _get_requirements(
75 103 'requirements.txt', exclude=['setuptools', 'entrypoints'])
76 104 test_requirements = _get_requirements(
77 105 'requirements_test.txt', extras=['configobj'])
78 106
79 107
80 108 def get_version():
81 109 version = pkgutil.get_data('rhodecode', 'VERSION')
82 110 return version.strip()
83 111
84 112
85 113 # additional files that goes into package itself
86 114 package_data = {
87 115 '': ['*.txt', '*.rst'],
88 116 'configs': ['*.ini'],
89 117 'rhodecode': ['VERSION', 'i18n/*/LC_MESSAGES/*.mo', ],
90 118 }
91 119
92 120 description = 'Source Code Management Platform'
93 121 keywords = ' '.join([
94 122 'rhodecode', 'mercurial', 'git', 'svn',
95 123 'code review',
96 124 'repo groups', 'ldap', 'repository management', 'hgweb',
97 125 'hgwebdir', 'gitweb', 'serving hgweb',
98 126 ])
99 127
100 128
101 129 # README/DESCRIPTION generation
102 130 readme_file = 'README.rst'
103 131 changelog_file = 'CHANGES.rst'
104 132 try:
105 133 long_description = codecs.open(readme_file).read() + '\n\n' + \
106 134 codecs.open(changelog_file).read()
107 135 except IOError as err:
108 136 sys.stderr.write(
109 137 "[WARNING] Cannot find file specified as long_description (%s)\n "
110 138 "or changelog (%s) skipping that file" % (readme_file, changelog_file))
111 139 long_description = description
112 140
113 141
114 142 setup(
115 143 name='rhodecode-enterprise-ce',
116 144 version=get_version(),
117 145 description=description,
118 146 long_description=long_description,
119 147 keywords=keywords,
120 148 license=__license__,
121 149 author=__author__,
122 150 author_email='support@rhodecode.com',
123 151 url=__url__,
124 152 setup_requires=setup_requirements,
125 153 install_requires=install_requirements,
126 154 tests_require=test_requirements,
127 155 zip_safe=False,
128 156 packages=find_packages(exclude=["docs", "tests*"]),
129 157 package_data=package_data,
130 158 include_package_data=True,
131 159 classifiers=[
132 160 'Development Status :: 6 - Mature',
133 161 'Environment :: Web Environment',
134 162 'Intended Audience :: Developers',
135 163 'Operating System :: OS Independent',
136 164 'Topic :: Software Development :: Version Control',
137 165 'License :: OSI Approved :: Affero GNU General Public License v3 or later (AGPLv3+)',
138 166 'Programming Language :: Python :: 2.7',
139 167 ],
140 168 message_extractors={
141 169 'rhodecode': [
142 170 ('**.py', 'python', None),
143 171 ('**.js', 'javascript', None),
144 172 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
145 173 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
146 174 ('public/**', 'ignore', None),
147 175 ]
148 176 },
149 177 paster_plugins=['PasteScript'],
150 178 entry_points={
151 179 'paste.app_factory': [
152 180 'main=rhodecode.config.middleware:make_pyramid_app',
153 181 ],
154 182 'paste.global_paster_command': [
155 183 'ishell=rhodecode.lib.paster_commands.ishell:Command',
156 184 'upgrade-db=rhodecode.lib.paster_commands.upgrade_db:UpgradeDb',
157 185
158 186 'setup-rhodecode=rhodecode.lib.paster_commands.deprecated.setup_rhodecode:Command',
159 187 'celeryd=rhodecode.lib.paster_commands.deprecated.celeryd:Command',
160 188 ],
161 189 'pyramid.pshell_runner': [
162 190 'ipython = rhodecode.lib.pyramid_shell:ipython_shell_runner',
163 191 ],
164 192 'pytest11': [
165 193 'pylons=rhodecode.tests.pylons_plugin',
166 194 'enterprise=rhodecode.tests.plugin',
167 195 ],
168 196 'console_scripts': [
169 197 'rc-setup-app=rhodecode.lib.rc_commands.setup_rc:main',
170 198 'rc-upgrade-db=rhodecode.lib.rc_commands.upgrade_db:main',
171 199 'rc-ishell=rhodecode.lib.rc_commands.ishell:main',
172 200 'rc-add-artifact=rhodecode.lib.rc_commands.add_artifact:main',
173 201 'rc-ssh-wrapper=rhodecode.apps.ssh_support.lib.ssh_wrapper:main',
174 202 ],
175 203 'beaker.backends': [
176 204 'memorylru_base=rhodecode.lib.memory_lru_dict:MemoryLRUNamespaceManagerBase',
177 205 'memorylru_debug=rhodecode.lib.memory_lru_dict:MemoryLRUNamespaceManagerDebug'
178 206 ]
179 207 },
180 208 )
General Comments 0
You need to be logged in to leave comments. Login now