-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
104 lines (89 loc) · 2.99 KB
/
setup.py
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
#coding=utf8
__doc__ = """node_uliweb_example"""
import re
import os
from setuptools import setup, find_packages
from setuptools.command import build_py as b
def copy_dir(self, package, src, dst):
self.mkpath(dst)
for r in os.listdir(src):
if r in ['.svn', '_svn']:
continue
fpath = os.path.join(src, r)
if os.path.isdir(fpath):
copy_dir(self, package + '.' + r, fpath, os.path.join(dst, r))
else:
ext = os.path.splitext(fpath)[1]
if ext in ['.pyc', '.pyo', '.bak', '.tmp']:
continue
target = os.path.join(dst, r)
self.copy_file(fpath, target)
def find_dir(self, package, src):
for r in os.listdir(src):
if r in ['.svn', '_svn']:
continue
fpath = os.path.join(src, r)
if os.path.isdir(fpath):
for f in find_dir(self, package + '.' + r, fpath):
yield f
else:
ext = os.path.splitext(fpath)[1]
if ext in ['.pyc', '.pyo', '.bak', '.tmp']:
continue
yield fpath
def build_package_data(self):
for package in self.packages or ():
src_dir = self.get_package_dir(package)
build_dir = os.path.join(*([self.build_lib] + package.split('.')))
copy_dir(self, package, src_dir, build_dir)
setattr(b.build_py, 'build_package_data', build_package_data)
def get_source_files(self):
filenames = []
for package in self.packages or ():
src_dir = self.get_package_dir(package)
filenames.extend(list(find_dir(self, package, src_dir)))
return filenames
setattr(b.build_py, 'get_source_files', get_source_files)
def fpath(name):
return os.path.join(os.path.dirname(__file__), name)
def read(fname, default=''):
filename = fpath(fname)
if os.path.exists(filename):
return open(fpath(fname)).read()
else:
return default
def desc():
info = read('README.md', __doc__)
return info + '\n\n' + read('doc/CHANGELOG.md')
file_text = read(fpath('apps/__init__.py'))
def grep(attrname):
pattern = r"{0}\s*=\s*'([^']*)'".format(attrname)
strval, = re.findall(pattern, file_text)
return strval
setup(
name='node_uliweb_example',
version=grep('__version__'),
url=grep('__url__'),
license='BSD',
author=grep('__author__'),
author_email=grep('__email__'),
description='node_uliweb_example',
long_description=desc(),
package_dir = {'node_uliweb_example':'apps'},
packages = ["node_uliweb_example"],
include_package_data=True,
zip_safe=False,
platforms='any',
install_requires=[
'uliweb',
],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules'
],
)