forked from anilgulecha/trelby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·156 lines (129 loc) · 4.76 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
# setup.py
from distutils.command.build_scripts import build_scripts as _build_scripts
from distutils.command.bdist_rpm import bdist_rpm as _bdist_rpm
from distutils.command.install_data import install_data as _install_data
from distutils.core import setup
from distutils.util import convert_path
import fileinput
import glob
import sys
import os.path
class build_scripts(_build_scripts):
"""build_scripts command
This specific build_scripts command will modify the bin/trelby script
so that it contains information on installation prefixes afterwards.
"""
def copy_scripts(self):
_build_scripts.copy_scripts(self)
if "install" in self.distribution.command_obj:
iobj = self.distribution.command_obj["install"]
libDir = iobj.install_lib
if iobj.root:
libDir = libDir[len(iobj.root):]
script = convert_path("bin/trelby")
outfile = os.path.join(self.build_dir, os.path.basename(script))
# abuse fileinput to replace a line in bin/trelby
for line in fileinput.input(outfile, inplace = 1):
if """sys.path.insert(0, "src")""" in line:
line = """sys.path.insert(0, "%s/src")""" % libDir
print line,
class bdist_rpm(_bdist_rpm):
"""bdist_rpm command
This specific bdist_rpm command generates an RPM package that
will install to /usr/share/trelby and /usr/bin, respectively.
"""
def _make_spec_file(self):
specFile = _bdist_rpm._make_spec_file(self)
line = next(i for i, s in enumerate(specFile) if s.startswith("%install"))
specFile[line+1] += " --prefix=/usr --install-data=/usr/share --install-lib /usr/share/trelby"
return specFile
class install_data(_install_data):
"""install_data command
This specific install_data command only really installs trelby.desktop
if the target path is either /usr or /usr/local.
"""
def run(self):
dataDir = self.install_dir
if self.root:
dataDir = dataDir[len(self.root):]
if dataDir.rstrip("/") in ("/usr/share", "/usr/local/share"):
_install_data.run(self)
sys.path.append(os.path.join(os.path.split(__file__)[0], "src"))
import misc
includes = [
"encodings",
"encodings.*",
"lxml._elementpath"
]
options = {
"py2exe": {
"compressed": 1,
"optimize": 2,
"includes": includes,
}
}
if sys.platform == "win32":
import py2exe
platformOptions = dict(
zipfile = "library.zip",
windows = [{
"script" : "bin/trelby",
"icon_resources": [(1, "icon32.ico")],
}]
)
else:
platformOptions = {}
dataFiles = [
("applications", ["trelby.desktop"]),
]
setup(
name = "Trelby",
cmdclass = {
"build_scripts": build_scripts,
"bdist_rpm": bdist_rpm,
"install_data": install_data,
},
version = misc.version,
description = "Free, multiplatform, feature-rich screenwriting program",
long_description = """\
Trelby is a simple, powerful, full-featured, multi-platform program for
writing movie screenplays. It is simple, fast and elegantly laid out to
make screenwriting simple, and it is infinitely configurable.
Features:
* Screenplay editor: Enforces correct script format and pagination,
auto-completion, and spell checking.
* Multiplatform: Behaves identically on all platforms, generating the exact
same output.
* Choice of view: Multiple views, including draft view, WYSIWYG mode,
and fullscreen to suit your writing style.
* Name database: Character name database containing over 200,000 names
from various countries.
* Reporting: Scene/location/character/dialogue reports.
* Compare: Ability to compare scripts, so you know what changed between
versions.
* Import: Screenplay formatted text, Final Draft XML (.fdx)
and Celtx (.celtx).
* Export: PDF, formatted text, HTML, RTF, Final Draft XML (.fdx).
* PDF: Built-in, highly configurable PDF generator. Supports embedding your
chosen font. Also supports generating PDFs with custom watermarks,
to help track shared files.
* Free software: Licensed under the GPL, Trelby welcomes developers and
screenwriters to contribute in making it more useful.
""",
author = "Osku Salerma",
author_email = "[email protected]",
url = "http://www.trelby.org/",
license = "GPL",
packages = ["src"],
package_data = {"src": ["../resources/*",
"../names.txt.gz",
"../dict_en.dat.gz",
"../sample.trelby",
"../fileformat.txt",
"../manual.html",
"../README",
]},
data_files = dataFiles,
scripts = ["bin/trelby"],
options = options,
**platformOptions)