-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathsetup.py
executable file
·122 lines (110 loc) · 3.59 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import os, os.path, sys, re
from fnmatch import fnmatch
from setuptools import setup
MODULE_NAME = 'django_mako_plus'
IGNORE_PATTERNS = [
'.*',
'__pycache__',
'*.pyc',
'__dmpcache__',
'node_modules',
'.vscode',
'.DS_Store',
]
def is_ignore(fn):
for pat in IGNORE_PATTERNS:
if fnmatch(fn, pat):
return True
return False
# I can't import the version file the normal way because it loads
# __init__.py, which then imports the DMP engine.
with open('django_mako_plus/version.py') as f:
match = re.search("__version__\s=\s'(\d+\.\d+\.\d+)'", f.read())
if not match:
print('Cannot determine the DMP version. Aborting setup.py.')
sys.exit(1)
VERSION = match.group(1)
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Programming Language :: Python :: 3 :: Only',
'Framework :: Django',
'Framework :: Django :: 1.11',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.9',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Topic :: Software Development',
]
install_requires = [
'django >= 1.9.0',
'mako >= 1.0.0',
]
if len(sys.argv) >= 2 and sys.argv[1] == 'sdist':
# remove the __pycache__ directories since the ones in project_template seems to stick around
os.system('find . -name "__pycache__" -type d -exec rm -r "{}" \+')
# Compile the list of packages available
packages = []
def walk(parent):
for fname in os.listdir(parent):
fpath = os.path.join(parent, fname)
# skip hidden/cache files
if is_ignore(fname) or fname in ( 'app_template', 'project_template' ):
continue
# if a directory, walk it
elif os.path.isdir(fpath):
walk(fpath)
# if an __init__.py file, add the directory to the packages
elif fname == '__init__.py':
packages.append(os.path.dirname(fpath))
walk(MODULE_NAME)
data_files = []
# add the readme/license
data_files.extend([
('', [ 'readme.md' ]),
('', [ 'readme.txt' ]),
('', [ 'license.txt' ]),
])
# add the extra directories
# empty directories within app_template/ will cause problems with distutils, so be sure each directory has at least one file
package_data_files = []
def walk2(parent):
for fname in os.listdir(parent):
fpath = os.path.join(parent, fname)
if is_ignore(fname):
pass # ignore this one
elif os.path.isdir(fpath):
walk2(fpath)
else:
package_data_files.append(os.path.relpath(fpath, MODULE_NAME))
walk2(os.path.join(MODULE_NAME, 'app_template'))
walk2(os.path.join(MODULE_NAME, 'project_template'))
walk2(os.path.join(MODULE_NAME, 'webroot'))
# read the long description if sdist
description = 'Django+Mako: Routing by Convention, Python-Centric Template Language'
long_description = description
if len(sys.argv) > 1 and sys.argv[1] == 'sdist':
long_description = open('readme.txt').read()
# run the setup
setup(
name='django-mako-plus',
description=description,
long_description=long_description,
version=VERSION,
author='Conan Albrecht',
author_email='[email protected]',
url="http://doconix.github.io/django-mako-plus/",
download_url="https://github.com/doconix/django-mako-plus/archive/master.zip",
packages=packages,
package_data = {
MODULE_NAME: package_data_files,
},
entry_points={
'console_scripts': [
'django_mako_plus = django_mako_plus.__main__:main'
]
},
install_requires=install_requires,
classifiers=CLASSIFIERS,
license='Apache 2.0',
)