forked from chrisspen/django-database-files-3000
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
132 lines (116 loc) · 4.13 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
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from setuptools import setup, find_packages, Command
import database_files
try:
from pypandoc import convert
read_md = lambda f: convert(f, 'rst')
except:
print("Warning: pypandoc module not found, could not convert "
"Markdown to RST")
read_md = lambda f: open(f, 'r').read()
def get_reqs(test=False, pv=None):
reqs = [
'Django>=1.4',
'six>=1.7.2',
]
if test:
#TODO:remove once Django 1.7 south integration becomes main-stream?
if not pv:
reqs.append('South>=1.0')
elif pv <= 3.2:
# Note, South dropped Python3 support after 0.8.4...
reqs.append('South==0.8.4')
return reqs
class TestCommand(Command):
description = "Runs unittests."
user_options = [
('name=', None,
'Name of the specific test to run.'),
('virtual-env-dir=', None,
'The location of the virtual environment to use.'),
('pv=', None,
'The version of Python to use. e.g. 2.7 or 3'),
]
def initialize_options(self):
self.name = None
self.virtual_env_dir = '.env%s'
self.pv = 0
self.versions = [
2.7,
3,
#3.3,#TODO?
]
def finalize_options(self):
pass
def build_virtualenv(self, pv):
virtual_env_dir = self.virtual_env_dir % pv
kwargs = dict(virtual_env_dir=virtual_env_dir, pv=pv)
if not os.path.isdir(virtual_env_dir):
cmd = 'virtualenv -p /usr/bin/python{pv} {virtual_env_dir}'.format(**kwargs)
print(cmd)
os.system(cmd)
cmd = '{virtual_env_dir}/bin/easy_install -U distribute'.format(**kwargs)
print(cmd)
os.system(cmd)
for package in get_reqs(test=True, pv=float(pv)):
kwargs['package'] = package
cmd = '{virtual_env_dir}/bin/pip install -U {package}'.format(**kwargs)
print(cmd)
os.system(cmd)
def run(self):
versions = self.versions
if self.pv:
versions = [self.pv]
for pv in versions:
self.build_virtualenv(pv)
kwargs = dict(
pv=pv,
virtual_env_dir=self.virtual_env_dir % pv,
name=self.name)
if self.name:
cmd = '{virtual_env_dir}/bin/django-admin.py test --pythonpath=. --settings=database_files.tests.settings database_files.tests.tests.{name}'.format(**kwargs)
else:
cmd = '{virtual_env_dir}/bin/django-admin.py test --pythonpath=. --settings=database_files.tests.settings database_files.tests'.format(**kwargs)
print(cmd)
ret = os.system(cmd)
if ret:
return
try:
long_description = read_md('README.md')
except:
long_description = ''
setup(
name='django-database-files-3000',
version=database_files.__version__,
description='A storage system for Django that stores uploaded files in both the database and file system.',
long_description=long_description,
author='Chris Spencer',
author_email='chrisspen@gmail.com',
url='http://github.com/chrisspen/django-database-files-3000',
packages=[
'database_files',
'database_files.management',
'database_files.management.commands',
'database_files.migrations',
'database_files.south_migrations',
],
#https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 4 - Beta',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.0',
'Programming Language :: Python :: 3.2',
],
install_requires = get_reqs(),
cmdclass={
'test': TestCommand,
},
)