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
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
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
))]
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
)
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
]
53 class InstallLib(install_lib
):
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
)
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',
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',
99 cmdclass
={'install_lib': InstallLib
},
101 scripts
=scripts_hack(
102 ('ranger.py', 'ranger'),
103 ('ranger/ext/rifle.py', 'rifle'),
106 ('share/applications', [
107 'doc/ranger.desktop',
113 ('share/doc/ranger', [
114 'doc/colorschemes.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')),
134 'ranger.colorschemes',
141 'ranger.gui.widgets',
146 if __name__
== '__main__':