setup.py
201 lines
| 6.7 KiB
| text/x-python
|
PythonLexer
r5088 | # Copyright (C) 2010-2023 RhodeCode GmbH | |||
r1234 | # | |||
# This program is free software: you can redistribute it and/or modify | ||||
# it under the terms of the GNU Affero General Public License, version 3 | ||||
# (only), as published by the Free Software Foundation. | ||||
# | ||||
# This program is distributed in the hope that it will be useful, | ||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | ||||
# | ||||
# You should have received a copy of the GNU Affero General Public License | ||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
# | ||||
# This program is dual-licensed. If you wish to learn more about the | ||||
# RhodeCode Enterprise Edition, including its added features, Support services, | ||||
# and proprietary license terms, please see https://rhodecode.com/licenses/ | ||||
r1 | # Import early to make sure things are patched up properly | |||
r5035 | from setuptools import setup, find_packages, Extension | |||
r1 | ||||
import os | ||||
r4897 | import re | |||
r1 | import sys | |||
r1234 | import pkgutil | |||
r1 | import platform | |||
r2912 | import codecs | |||
r1 | ||||
r4897 | import pip | |||
pip_major_version = int(pip.__version__.split(".")[0]) | ||||
if pip_major_version >= 20: | ||||
r2912 | from pip._internal.req import parse_requirements | |||
r4897 | from pip._internal.network.session import PipSession | |||
elif pip_major_version >= 10: | ||||
from pip._internal.req import parse_requirements | ||||
from pip._internal.download import PipSession | ||||
else: | ||||
r2912 | from pip.req import parse_requirements | |||
r4897 | from pip.download import PipSession | |||
r1222 | ||||
r4897 | def get_package_name(req_object): | |||
package_name = None | ||||
try: | ||||
from pip._internal.req.constructors import install_req_from_parsed_requirement | ||||
except ImportError: | ||||
install_req_from_parsed_requirement = None | ||||
# In 20.1 of pip, the requirements object changed | ||||
if hasattr(req_object, 'req'): | ||||
package_name = req_object.req.name | ||||
if package_name is None: | ||||
if install_req_from_parsed_requirement: | ||||
package = install_req_from_parsed_requirement(req_object) | ||||
package_name = package.req.name | ||||
if package_name is None: | ||||
# fallback for older pip | ||||
package_name = re.split('===|<=|!=|==|>=|~=|<|>', req_object.requirement)[0] | ||||
return package_name | ||||
r1234 | ||||
r1222 | ||||
r4907 | if sys.version_info < (3, 10): | |||
raise Exception('RhodeCode requires Python 3.10 or later') | ||||
r1 | ||||
r1222 | here = os.path.abspath(os.path.dirname(__file__)) | |||
r1 | ||||
r1234 | # defines current platform | |||
__platform__ = platform.system() | ||||
__license__ = 'AGPLv3, and Commercial License' | ||||
__author__ = 'RhodeCode GmbH' | ||||
__url__ = 'https://code.rhodecode.com' | ||||
is_windows = __platform__ in ('Windows',) | ||||
r1 | ||||
r1234 | def _get_requirements(req_filename, exclude=None, extras=None): | |||
extras = extras or [] | ||||
exclude = exclude or [] | ||||
r1 | ||||
r1234 | try: | |||
parsed = parse_requirements( | ||||
os.path.join(here, req_filename), session=PipSession()) | ||||
except TypeError: | ||||
# try pip < 6.0.0, that doesn't support session | ||||
parsed = parse_requirements(os.path.join(here, req_filename)) | ||||
r1 | ||||
r1234 | requirements = [] | |||
r4897 | for int_req in parsed: | |||
req_name = get_package_name(int_req) | ||||
if req_name not in exclude: | ||||
requirements.append(req_name) | ||||
r1234 | return requirements + extras | |||
r1 | ||||
r1234 | # requirements extract | |||
r4897 | setup_requirements = ['PasteScript'] | |||
r1234 | install_requirements = _get_requirements( | |||
r2351 | 'requirements.txt', exclude=['setuptools', 'entrypoints']) | |||
r1234 | test_requirements = _get_requirements( | |||
r4975 | 'requirements_test.txt') | |||
r1 | ||||
r1234 | def get_version(): | |||
r5214 | here = os.path.abspath(os.path.dirname(__file__)) | |||
ver_file = os.path.join(here, "rhodecode", "VERSION") | ||||
with open(ver_file, "rt") as f: | ||||
version = f.read().strip() | ||||
return version | ||||
r1234 | ||||
r1 | ||||
# additional files that goes into package itself | ||||
r1234 | package_data = { | |||
'': ['*.txt', '*.rst'], | ||||
'configs': ['*.ini'], | ||||
'rhodecode': ['VERSION', 'i18n/*/LC_MESSAGES/*.mo', ], | ||||
} | ||||
r1 | ||||
r1234 | description = 'Source Code Management Platform' | |||
r1 | keywords = ' '.join([ | |||
r1234 | 'rhodecode', 'mercurial', 'git', 'svn', | |||
'code review', | ||||
'repo groups', 'ldap', 'repository management', 'hgweb', | ||||
'hgwebdir', 'gitweb', 'serving hgweb', | ||||
r1 | ]) | |||
r1234 | ||||
# README/DESCRIPTION generation | ||||
readme_file = 'README.rst' | ||||
changelog_file = 'CHANGES.rst' | ||||
r1 | try: | |||
r2912 | long_description = codecs.open(readme_file).read() + '\n\n' + \ | |||
codecs.open(changelog_file).read() | ||||
r1234 | except IOError as err: | |||
r1 | sys.stderr.write( | |||
r1234 | "[WARNING] Cannot find file specified as long_description (%s)\n " | |||
"or changelog (%s) skipping that file" % (readme_file, changelog_file)) | ||||
r1 | long_description = description | |||
setup( | ||||
name='rhodecode-enterprise-ce', | ||||
r1234 | version=get_version(), | |||
r1 | description=description, | |||
long_description=long_description, | ||||
keywords=keywords, | ||||
license=__license__, | ||||
author=__author__, | ||||
r2952 | author_email='support@rhodecode.com', | |||
r1 | url=__url__, | |||
r1234 | setup_requires=setup_requirements, | |||
install_requires=install_requirements, | ||||
r1 | tests_require=test_requirements, | |||
r1234 | zip_safe=False, | |||
packages=find_packages(exclude=["docs", "tests*"]), | ||||
package_data=package_data, | ||||
r1 | include_package_data=True, | |||
r1234 | classifiers=[ | |||
'Development Status :: 6 - Mature', | ||||
'Environment :: Web Environment', | ||||
'Intended Audience :: Developers', | ||||
'Operating System :: OS Independent', | ||||
'Topic :: Software Development :: Version Control', | ||||
'License :: OSI Approved :: Affero GNU General Public License v3 or later (AGPLv3+)', | ||||
r4907 | 'Programming Language :: Python :: 3.10', | |||
r1234 | ], | |||
r1 | message_extractors={ | |||
'rhodecode': [ | ||||
('**.py', 'python', None), | ||||
r326 | ('**.js', 'javascript', None), | |||
r1 | ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}), | |||
('templates/**.html', 'mako', {'input_encoding': 'utf-8'}), | ||||
('public/**', 'ignore', None), | ||||
] | ||||
}, | ||||
r5386 | ||||
r1 | entry_points={ | |||
'paste.app_factory': [ | ||||
'main=rhodecode.config.middleware:make_pyramid_app', | ||||
], | ||||
r2006 | 'pyramid.pshell_runner': [ | |||
'ipython = rhodecode.lib.pyramid_shell:ipython_shell_runner', | ||||
], | ||||
r1 | 'console_scripts': [ | |||
r2119 | 'rc-setup-app=rhodecode.lib.rc_commands.setup_rc:main', | |||
'rc-upgrade-db=rhodecode.lib.rc_commands.upgrade_db:main', | ||||
'rc-ishell=rhodecode.lib.rc_commands.ishell:main', | ||||
r4005 | 'rc-add-artifact=rhodecode.lib.rc_commands.add_artifact:main', | |||
r5516 | 'rc-migrate-artifact=rhodecode.lib.rc_commands.migrate_artifact:main', | |||
r5314 | 'rc-ssh-wrapper=rhodecode.apps.ssh_support.lib.ssh_wrapper_v1:main', | |||
'rc-ssh-wrapper-v2=rhodecode.apps.ssh_support.lib.ssh_wrapper_v2:main', | ||||
r1 | ], | |||
'beaker.backends': [ | ||||
r2945 | 'memorylru_base=rhodecode.lib.memory_lru_dict:MemoryLRUNamespaceManagerBase', | |||
'memorylru_debug=rhodecode.lib.memory_lru_dict:MemoryLRUNamespaceManagerDebug' | ||||
r1 | ] | |||
}, | ||||
) | ||||