1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/usr/bin/env python
# This file is part of ranger, the console file manager.
# License: GNU GPL version 3, see the file "AUTHORS" for details.
from __future__ import (absolute_import, division, print_function)
from hashlib import sha512
import os
import shutil
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
import ranger
SCRIPTS_PATH = 'build_scripts'
SCRIPTS = (
('ranger.py', 'ranger'),
('ranger/ext/rifle.py', 'rifle'),
)
def findall(directory):
return [os.path.join(directory, f) for f in os.listdir(directory)
if os.path.isfile(os.path.join(directory, f))]
def hash_path(path):
with open(path, 'rb') as fobj:
return sha512(fobj.read()).digest()
def scripts_hack():
''' Hack around `pip install` temporary directories '''
if not os.path.exists(SCRIPTS_PATH):
os.makedirs(SCRIPTS_PATH)
scripts = []
for src_path, basename in SCRIPTS:
dest_path = os.path.join(SCRIPTS_PATH, basename)
if not os.path.exists(dest_path) or \
(os.path.exists(src_path) and hash_path(src_path) != hash_path(dest_path)):
shutil.copy(src_path, dest_path)
scripts += [dest_path]
return scripts
def main():
setup(
name='ranger-fm',
description='Vim-like file manager',
long_description=ranger.__doc__,
version=ranger.__version__,
author=ranger.__author__,
author_email=ranger.__email__,
license=ranger.__license__,
url='http://ranger.nongnu.org',
scripts=scripts_hack(),
data_files=[
('share/applications', [
'doc/ranger.desktop',
]),
('share/man/man1', [
'doc/ranger.1',
'doc/rifle.1',
]),
('share/doc/ranger', [
'doc/colorschemes.txt',
'CHANGELOG.md',
'HACKING.md',
'README.md',
]),
('share/doc/ranger/config', findall('doc/config')),
('share/doc/ranger/config/colorschemes', findall('doc/config/colorschemes')),
('share/doc/ranger/examples', findall('examples')),
('share/doc/ranger/tools', findall('doc/tools')),
],
package_data={
'ranger': [
'data/*',
'config/rc.conf',
'config/rifle.conf',
],
},
packages=(
'ranger',
'ranger.api',
'ranger.colorschemes',
'ranger.config',
'ranger.container',
'ranger.core',
'ranger.ext',
'ranger.ext.vcs',
'ranger.gui',
'ranger.gui.widgets',
),
)
if __name__ == '__main__':
main()
|