##// END OF EJS Templates
setup: synced with rhodecode tools with better compatability on pip versions
super-admin -
r1033:04721931 default
parent child Browse files
Show More
@@ -1,136 +1,164 b''
1 1 # -*- coding: utf-8 -*-
2
2 3 # RhodeCode VCSServer provides access to different vcs backends via network.
3 4 # Copyright (C) 2014-2019 RodeCode GmbH
4 5 #
5 6 # This program is free software; you can redistribute it and/or modify
6 7 # it under the terms of the GNU General Public License as published by
7 8 # the Free Software Foundation; either version 3 of the License, or
8 9 # (at your option) any later version.
9 10 #
10 11 # This program is distributed in the hope that it will be useful,
11 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 14 # GNU General Public License for more details.
14 15 #
15 16 # You should have received a copy of the GNU General Public License
16 17 # along with this program; if not, write to the Free Software Foundation,
17 18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 19
19 20 # Import early to make sure things are patched up properly
20 21 from setuptools import setup, find_packages
21 22
22 23 import os
24 import re
23 25 import sys
24 26 import pkgutil
25 27 import platform
26 28 import codecs
27 29
28 try: # for pip >= 10
30 import pip
31
32 pip_major_version = int(pip.__version__.split(".")[0])
33 if pip_major_version >= 20:
29 34 from pip._internal.req import parse_requirements
30 except ImportError: # for pip <= 9.0.3
35 from pip._internal.network.session import PipSession
36 elif pip_major_version >= 10:
37 from pip._internal.req import parse_requirements
38 from pip._internal.download import PipSession
39 else:
31 40 from pip.req import parse_requirements
32
33 try: # for pip >= 10
34 from pip._internal.download import PipSession
35 except ImportError: # for pip <= 9.0.3
36 41 from pip.download import PipSession
37 42
38 43
44 def get_package_name(req_object):
45 package_name = None
46 try:
47 from pip._internal.req.constructors import install_req_from_parsed_requirement
48 except ImportError:
49 install_req_from_parsed_requirement = None
50
51 # In 20.1 of pip, the requirements object changed
52 if hasattr(req_object, 'req'):
53 package_name = req_object.req.name
54
55 if package_name is None:
56 if install_req_from_parsed_requirement:
57 package = install_req_from_parsed_requirement(req_object)
58 package_name = package.req.name
59
60 if package_name is None:
61 # fallback for older pip
62 package_name = re.split('===|<=|!=|==|>=|~=|<|>', req_object.requirement)[0]
63
64 return package_name
65
39 66
40 67 if sys.version_info < (2, 7):
41 68 raise Exception('VCSServer requires Python 2.7 or later')
42 69
43 70 here = os.path.abspath(os.path.dirname(__file__))
44 71
45 72 # defines current platform
46 73 __platform__ = platform.system()
47 74 __license__ = 'GPL V3'
48 75 __author__ = 'RhodeCode GmbH'
49 76 __url__ = 'https://code.rhodecode.com'
50 77 is_windows = __platform__ in ('Windows',)
51 78
52 79
53 80 def _get_requirements(req_filename, exclude=None, extras=None):
54 81 extras = extras or []
55 82 exclude = exclude or []
56 83
57 84 try:
58 85 parsed = parse_requirements(
59 86 os.path.join(here, req_filename), session=PipSession())
60 87 except TypeError:
61 88 # try pip < 6.0.0, that doesn't support session
62 89 parsed = parse_requirements(os.path.join(here, req_filename))
63 90
64 91 requirements = []
65 for ir in parsed:
66 if ir.req and ir.name not in exclude:
67 requirements.append(str(ir.req))
92 for int_req in parsed:
93 req_name = get_package_name(int_req)
94 if req_name not in exclude:
95 requirements.append(req_name)
68 96 return requirements + extras
69 97
70 98
71 99 # requirements extract
72 setup_requirements = ['pytest-runner']
100 setup_requirements = []
73 101 install_requirements = _get_requirements(
74 102 'requirements.txt', exclude=['setuptools'])
75 103 test_requirements = _get_requirements(
76 104 'requirements_test.txt', extras=['configobj'])
77 105
78 106
79 107 def get_version():
80 108 version = pkgutil.get_data('vcsserver', 'VERSION')
81 109 return version.strip()
82 110
83 111
84 112 # additional files that goes into package itself
85 113 package_data = {
86 114 '': ['*.txt', '*.rst'],
87 115 'configs': ['*.ini'],
88 116 'vcsserver': ['VERSION'],
89 117 }
90 118
91 119 description = 'Version Control System Server'
92 120 keywords = ' '.join([
93 121 'CLI', 'RhodeCode', 'RhodeCode Enterprise', 'RhodeCode Tools'])
94 122
95 123 # README/DESCRIPTION generation
96 124 readme_file = 'README.rst'
97 125 changelog_file = 'CHANGES.rst'
98 126 try:
99 127 long_description = codecs.open(readme_file).read() + '\n\n' + \
100 128 codecs.open(changelog_file).read()
101 129 except IOError as err:
102 130 sys.stderr.write(
103 131 "[WARNING] Cannot find file specified as long_description (%s)\n "
104 132 "or changelog (%s) skipping that file" % (readme_file, changelog_file))
105 133 long_description = description
106 134
107 135
108 136 setup(
109 137 name='rhodecode-vcsserver',
110 138 version=get_version(),
111 139 description=description,
112 140 long_description=long_description,
113 141 keywords=keywords,
114 142 license=__license__,
115 143 author=__author__,
116 author_email='admin@rhodecode.com',
144 author_email='support@rhodecode.com',
117 145 url=__url__,
118 146 setup_requires=setup_requirements,
119 147 install_requires=install_requirements,
120 148 tests_require=test_requirements,
121 149 zip_safe=False,
122 150 packages=find_packages(exclude=["docs", "tests*"]),
123 151 package_data=package_data,
124 152 include_package_data=True,
125 153 classifiers=[
126 154 'Development Status :: 6 - Mature',
127 155 'Intended Audience :: Developers',
128 156 'Operating System :: OS Independent',
129 157 'Topic :: Software Development :: Version Control',
130 158 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
131 159 'Programming Language :: Python :: 2.7',
132 160 ],
133 161 entry_points={
134 162 'paste.app_factory': ['main=vcsserver.http_main:main']
135 163 },
136 164 )
General Comments 0
You need to be logged in to leave comments. Login now