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