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
|
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from distutils.core import setup
import os
import re
def fullsplit(path, result=None):
"""
Split a pathname into components (the opposite of os.path.join) in a
platform-neutral way.
"""
if result is None:
result = []
head, tail = os.path.split(path)
if head == '':
return [tail] + result
if head == path:
return result
return fullsplit(head, [tail] + result)
packages, data_files, package_data = [], [], {'yape': []}
root_dir = os.path.dirname(os.path.abspath(__file__))
yape_dir = os.path.join(root_dir, 'src')
for dirpath, dirnames, filenames in os.walk(yape_dir):
# Ignore dirnames that start with '.' or i18 related
for i, dirname in enumerate(dirnames):
if dirname.startswith('.'): del dirnames[i]
#Ignore i18n stuffs for now
if 'i18n' in dirpath: continue
build_dirpath = dirpath.replace(yape_dir, "")[1:]
if '__init__.py' in filenames:
packages.append('.'.join(fullsplit(build_dirpath)))
elif filenames:
build_dirpath = dirpath.replace(os.path.join(yape_dir, 'yape'), "")[1:]
for f in filenames:
package_data['yape'].append(os.path.join(build_dirpath, f))
data_files=[("/usr/share/pixmaps", ["src/yape/images/yape.svg"]),
("/usr/share/applications", ["yape.desktop"]),
("/usr/share/locale/es/LC_MESSAGES/", ["src/i18n/es/LC_MESSAGES/yape.mo"])]
yape_module_content = open(os.path.join(yape_dir, 'yape', 'main_window.py')).read()
version_re = re.compile('^__version__ = \"(.*)\"')
for line in yape_module_content.split('\n'):
match = version_re.match(line)
if match:
version = match.group(1)
break
setup(name='YaPe',
version=version,
description='Yet Another Python Editor. A Python source code editor written in Python.',
author='Israel Fernández Cabrera',
author_email='iferca@gmail.com',
url='http://launchpad.net/yape',
packages=packages,
package_dir={'yape': 'src/yape'},
package_data=package_data,
data_files=data_files,
scripts=["yape"]
)
|