Merge pull request #1687 from toonn/gh-actions
[ranger.git] / setup.py
blobedf48c4a94ea158f8f08fecab01c8db42f0db88d
1 #!/usr/bin/env python
2 # This file is part of ranger, the console file manager.
3 # License: GNU GPL version 3, see the file "AUTHORS" for details.
5 from __future__ import (absolute_import, division, print_function)
7 from distutils import log # pylint: disable=import-error,no-name-in-module
8 from hashlib import sha512
9 import os
10 import shutil
12 import ranger
15 SCRIPTS_PATH = 'build_scripts'
16 EXECUTABLES_PATHS = ['/ranger/data/scope.sh']
19 # pylint: disable=import-error,no-name-in-module,ungrouped-imports
20 if os.environ.get('SETUPTOOLS_USE'):
21 from setuptools import setup
22 from setuptools.command.install_lib import install_lib
23 else:
24 from distutils.core import setup
25 from distutils.command.install_lib import install_lib
26 # pylint: enable=import-error,no-name-in-module,ungrouped-imports
29 def findall(directory):
30 return [os.path.join(directory, f) for f in os.listdir(directory)
31 if os.path.isfile(os.path.join(directory, f))]
34 def hash_file(path):
35 with open(path, 'rb') as fobj:
36 return sha512(fobj.read()).digest()
39 def scripts_hack(*scripts):
40 ''' Hack around `pip install` temporary directories '''
41 if not os.path.exists(SCRIPTS_PATH):
42 os.makedirs(SCRIPTS_PATH)
43 scripts_path = []
44 for src_path, basename in scripts:
45 dest_path = os.path.join(SCRIPTS_PATH, basename)
46 if not os.path.exists(dest_path) or \
47 (os.path.exists(src_path) and hash_file(src_path) != hash_file(dest_path)):
48 shutil.copy(src_path, dest_path)
49 scripts_path += [dest_path]
50 return scripts_path
53 class InstallLib(install_lib):
54 def run(self):
55 install_lib.run(self)
57 # Make executables executable
58 for path in self.get_outputs():
59 for exe_path in EXECUTABLES_PATHS:
60 if path.endswith(exe_path):
61 mode = ((os.stat(path).st_mode) | 0o555) & 0o7777
62 log.info('changing mode of %s to %o', path, mode)
63 os.chmod(path, mode)
66 def main():
67 setup(
68 name='ranger-fm',
69 description='Vim-like file manager',
70 long_description=ranger.__doc__,
71 version=ranger.__version__,
72 author=ranger.__author__,
73 author_email=ranger.__email__,
74 license=ranger.__license__,
75 url='https://ranger.github.io',
76 keywords='file-manager vim console file-launcher file-preview',
77 classifiers=[
78 'Environment :: Console',
79 'Environment :: Console :: Curses',
80 'Intended Audience :: Developers',
81 'Intended Audience :: End Users/Desktop',
82 'Intended Audience :: System Administrators',
83 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
84 'Operating System :: MacOS',
85 'Operating System :: POSIX',
86 'Operating System :: Unix',
87 'Programming Language :: Python :: 2.6',
88 'Programming Language :: Python :: 2.7',
89 'Programming Language :: Python :: 3.1',
90 'Programming Language :: Python :: 3.2',
91 'Programming Language :: Python :: 3.3',
92 'Programming Language :: Python :: 3.4',
93 'Programming Language :: Python :: 3.5',
94 'Programming Language :: Python :: 3.6',
95 'Topic :: Desktop Environment :: File Managers',
96 'Topic :: Utilities',
99 cmdclass={'install_lib': InstallLib},
101 scripts=scripts_hack(
102 ('ranger.py', 'ranger'),
103 ('ranger/ext/rifle.py', 'rifle'),
105 data_files=[
106 ('share/applications', [
107 'doc/ranger.desktop',
109 ('share/man/man1', [
110 'doc/ranger.1',
111 'doc/rifle.1',
113 ('share/doc/ranger', [
114 'doc/colorschemes.md',
115 'CHANGELOG.md',
116 'HACKING.md',
117 'README.md',
119 ('share/doc/ranger/config', findall('doc/config')),
120 ('share/doc/ranger/config/colorschemes', findall('doc/config/colorschemes')),
121 ('share/doc/ranger/examples', findall('examples')),
122 ('share/doc/ranger/tools', findall('doc/tools')),
124 package_data={
125 'ranger': [
126 'data/*',
127 'config/rc.conf',
128 'config/rifle.conf',
131 packages=(
132 'ranger',
133 'ranger.api',
134 'ranger.colorschemes',
135 'ranger.config',
136 'ranger.container',
137 'ranger.core',
138 'ranger.ext',
139 'ranger.ext.vcs',
140 'ranger.gui',
141 'ranger.gui.widgets',
146 if __name__ == '__main__':
147 main()