This repository has been archived by the owner on Feb 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
76 lines (64 loc) · 2.65 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
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from distutils.core import setup
setup(
name = "wordaxe",
version = "1.1.0",
description = "Provide hyphenation for python programs and ReportLab paragraphs.",
long_description = "Provide hyphenation for python programs and ReportLab paragraphs.",
author = "Henning von Bargen",
author_email = "[email protected]",
maintainer = "Henning von Bargen",
maintainer_email = "[email protected]",
license = ["Apache License, version 2.0", "Free BSD License"],
platforms = ["Unix", "Windows", "generic"],
keywords = ["multi-language", "text processing", "hyphenation", "paragraphs", "reportlab"],
url = "http://deco-cow.sourceforge.net",
download_url = "http://sourceforge.net/project/platformdownload.php?group_id=105867",
packages = ["wordaxe", "wordaxe/rl", "wordaxe/plugins", "wordaxe/dict"],
package_data = {"wordaxe": ["dict/*.dic" ]},
classifiers = [
"License :: OSI Approved :: Apache Software License",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Topic :: Text Processing",
],
)
# Backup original Reportlab's file rl_codecs.py -> rl_codecs.py.bak
# and replace the original with the one in hyphenation/rl if needed.
import sys
setupCommand = sys.argv[-1]
if setupCommand == "install":
from shutil import copy2
try:
from hashlib import md5
except ImportError: # Python < 2.5
from md5 import new as md5
def fileHash(path):
"""Return MD5 hash of an entire file."""
h = md5()
h.update(open(path, "rb").read())
return h.hexdigest()
try:
import reportlab
if reportlab.Version <= "2.3":
from reportlab.pdfbase import rl_codecs
src = rl_codecs.__file__
if src.endswith(".pyc"):
src = src[:-1]
new = "wordaxe/rl/rl_codecs.py"
if fileHash(src) != fileHash(new):
bak = src + ".bak"
print("backing up %s -> %s" % (src, bak))
copy2(src, bak)
print("copying %s -> %s" % (new, src))
copy2(new, src)
else:
print("no update of '%s' needed" % src)
except ImportError:
print("Note: ReportLab is not properly installed.")