-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
46 lines (37 loc) · 1.55 KB
/
setup.py
File metadata and controls
46 lines (37 loc) · 1.55 KB
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
from setuptools.command.install import install as InstallCommand
from setuptools import setup
class MyInstall(InstallCommand):
def run(self):
# Compile C code at src/cppcode
from subprocess import Popen, PIPE
import os
my_path = os.path.dirname(os.path.realpath(__file__))
print('Runing cmake at', my_path + '/src/cppcode/')
p = Popen(['cmake', '.'], stdout=PIPE, cwd=my_path + '/src/cppcode/')
print(p.stdout.read())
assert(p.wait() == 0)
if not os.path.exists(my_path + '/src/cppcode/Makefile'):
raise RuntimeError('Makefile was not generated!')
print('Runing make', my_path + '/src/cppcode/')
p = Popen(['make'], stdout=PIPE, cwd=my_path + '/src/cppcode/')
print(p.stdout.read())
assert(p.wait() == 0)
if not os.path.exists(my_path + '/src/cppcode/libpyslibtesseract.so'):
raise RuntimeError('pyslibtesseract.so was not generated!')
# Run install default
return InstallCommand.run(self)
# Python setup
setup(
name='pyslibtesseract',
version='0.0.15',
author='Bruno Macabeus',
description=('Integration of Tesseract for Python using a shared library'),
keywords='python-tesseract OCR Python',
url='https://github.com/brunomacabeusbr/pyslibtesseract',
packages=['pyslibtesseract'],
package_dir={'pyslibtesseract': 'src'},
cmdclass={
'install': MyInstall
},
package_data={'pyslibtesseract': ['cppcode/main.cpp', 'cppcode/CMakeLists.txt', 'cppcode/libpyslibtesseract.so']},
)