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