-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
executable file
·159 lines (126 loc) · 4.55 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# -*- encoding: utf-8 -*-
import os
import sys
from distutils.command.build import build as _build
from setuptools import Command, setup
from setuptools.command.install_lib import install_lib as _install_lib
class compile_translations(Command):
description = "compile message catalogs to MO files via django compilemessages"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
curdir = os.getcwd()
os.chdir(os.path.join(os.path.dirname(__file__), "multiseek"))
from django.core.management import call_command
call_command("compilemessages")
os.chdir(curdir)
class build(_build):
sub_commands = [("compile_translations", None)] + _build.sub_commands
class install_lib(_install_lib):
def run(self):
self.run_command("compile_translations")
_install_lib.run(self)
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
class RunTests(Command):
description = "Run the django test suite from the testproj dir."
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
this_dir = os.getcwd()
testproj_dir = os.path.join(this_dir, "test_project")
os.chdir(testproj_dir)
sys.path.append(testproj_dir)
from django.core.management import execute_manager
os.environ["DJANGO_SETTINGS_MODULE"] = "test_project.settings"
settings_file = os.environ["DJANGO_SETTINGS_MODULE"]
settings_mod = __import__(settings_file, {}, {}, [""])
execute_manager(
settings_mod, argv=[__file__, "test", "multiseek", "--traceback"]
)
os.chdir(this_dir)
if "sdist" in sys.argv:
# clear compiled mo files before building the distribution
walk = os.walk(os.path.join(os.getcwd(), "multiseek/locale"))
for dirpath, dirnames, filenames in walk:
if not filenames:
continue
for fn in ["django.mo", "djangojs.mo"]:
if fn in filenames:
os.unlink(os.path.join(dirpath, fn))
else:
# Always try to build messages, fail if django not present
# (I hate incomplete releases)
cwd = os.getcwd()
os.chdir(os.path.join(os.path.dirname(__file__), "multiseek"))
if "DJANGO_SETTINGS_MODULE" in os.environ:
del os.environ["DJANGO_SETTINGS_MODULE"]
os.system("django-admin compilemessages")
os.chdir(cwd)
def reqs(f):
f = os.path.join(os.path.dirname(__file__), f)
for elem in open(f).readlines():
elem = elem.strip()
if not elem:
continue
if elem.find("#egg=") > 0:
ign, egg = elem.split("#egg=")
yield egg
continue
if elem.startswith("#") or elem.startswith("-r"):
continue
yield elem
setup(
name="django-multiseek",
version="0.9.47",
description="Build a form to seek records using multiple parameters",
author=u"Michał Pasternak",
author_email="[email protected]",
url="http://TODO",
packages=["multiseek"],
package_data={
"multiseek": [
"locale/*/LC_MESSAGES/*",
"static/multiseek/*.js",
"static/multiseek/*.css",
"templates/multiseek/*.html",
]
},
include_package_data=True,
zip_safe=False,
long_description=read("README.md"),
license="MIT",
keywords="django multiseek",
install_requires=["Django>=1.11"] + list(reqs("requirements.txt")),
tests_require=["Django>=1.11"] + list(reqs("requirements_dev.txt")),
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries :: Python Modules",
],
cmdclass={
"build": build,
"install_lib": install_lib,
"compile_translations": compile_translations,
"test": RunTests,
},
)