-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·58 lines (51 loc) · 1.9 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
#!/usr/bin/env python
import sys,time,urllib,traceback,glob,os,os.path
assert sys.version_info[0]==2 and sys.version_info[1]>=7,\
"you must install and use OCRopus with Python version 2.7 or later, but not Python 3.x"
from distutils.core import setup, Extension, Command
from distutils.command.install_data import install_data
from ocrolib import default
modeldir = "models/"
modelfiles = default.installable
modelprefix = "http://iupr1.cs.uni-kl.de/~tmb/ocropus-models/"
class DownloadCommand(Command):
description = "Download OCRopus datafiles. (This needs to happen prior to installation.)"
user_options = []
def initialize_options(self): pass
def finalize_options(self): pass
def run(self):
print "Starting download of about 500Mbytes of model data."
time.sleep(3) # give them time to quit
for m in modelfiles:
dest = modeldir+m
if os.path.exists(dest):
print m,": already downloaded"
continue
url = modelprefix+m
cmd = "curl '%s' > '%s'"%(url,dest)
print "\n#",cmd,"\n"
if os.system(cmd)!=0:
print "download failed"
sys.exit(1)
for m in modelfiles:
if not os.path.exists(modeldir+m):
print
print "warning:",modeldir+m,"does not exist"
print 'run "python setup.py download_models"'
print
break
setup(
name = 'ocropy',
version = '0.6',
author = "Thomas Breuel",
description = "The core of the OCRopus OCR system.",
packages = ["ocrolib"],
data_files=
[('share/ocropus', glob.glob("*.glade")),
('share/ocropus', [modeldir+m for m in modelfiles])],
scripts =
[c for c in glob.glob("ocropus-*") if "." not in c and "~" not in c],
cmdclass = {
"download_models" : DownloadCommand,
}
)