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