forked from GeyseR/django-select2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·110 lines (87 loc) · 3.17 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import codecs
import os
import sys
from setuptools import setup, find_packages, Command
def read(file_name):
file_path = os.path.join(os.path.dirname(__file__), file_name)
return codecs.open(file_path, encoding='utf-8').read()
PACKAGE = "django_select2"
NAME = "Django-Select2"
DESCRIPTION = "Select2 option fields for Django"
AUTHOR = "Nirupam Biswas"
AUTHOR_EMAIL = "[email protected]"
URL = "https://github.com/applegrew/django-select2"
VERSION = __import__(PACKAGE).__version__
def getPkgPath():
return __import__(PACKAGE).__path__[0] + '/'
def minify(files, outfile, ftype):
import requests
import io
content = ''
for filename in files:
with io.open(getPkgPath() + filename, 'r', encoding='utf8') as f:
content = f.read()
data = {
'code': content,
'type': ftype,
}
response = requests.post('http://api.applegrew.com/minify', data)
response.raise_for_status()
response = response.json()
if response['success']:
with io.open(getPkgPath() + outfile, 'w', encoding='utf8') as f:
f.write(response['compiled_code'])
else:
raise Exception('%(error_code)s: "%(error)s"' % response)
if len(sys.argv) > 1 and 'sdist' == sys.argv[1]:
minify(['static/django_select2/js/select2.js'], 'static/django_select2/js/select2.min.js', 'js')
minify(['static/django_select2/js/heavy_data.js'], 'static/django_select2/js/heavy_data.min.js', 'js')
minify(['static/django_select2/css/select2.css'], 'static/django_select2/css/select2.min.css', 'css')
minify(['static/django_select2/css/select2.css', 'static/django_select2/css/extra.css'],
'static/django_select2/css/all.min.css', 'css')
minify(['static/django_select2/css/select2.css', 'static/django_select2/css/select2-bootstrap.css'],
'static/django_select2/css/select2-bootstrapped.min.css', 'css')
minify(
[
'static/django_select2/css/select2.css',
'static/django_select2/css/extra.css',
'static/django_select2/css/select2-bootstrap.css'
], 'static/django_select2/css/all-bootstrapped.min.css', 'css')
class PyTest(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import sys
import subprocess
errno = subprocess.call([sys.executable, 'runtests.py'])
raise SystemExit(errno)
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=read("README.md"),
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license="LICENSE.txt",
url=URL,
packages=find_packages(),
include_package_data=True,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Framework :: Django",
],
install_requires=[],
zip_safe=False,
cmdclass={'test': PyTest},
)