Skip to content

Commit

Permalink
Fixbug: Now, the cmake runs during the installation of the package
Browse files Browse the repository at this point in the history
  • Loading branch information
macabeus committed Mar 25, 2016
1 parent ec164b0 commit ecf21bf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions setup.py
@@ -1,14 +1,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.7',
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'},
package_data={'pyslibtesseract': ['cppcode/*.so']},
cmdclass={
'install': MyInstall
},
package_data={'pyslibtesseract': ['cppcode/main.cpp', 'cppcode/CMakeLists.txt', 'cppcode/libpyslibtesseract.so']},
)
Binary file removed src/cppcode/libpyslibtesseract.so
Binary file not shown.

0 comments on commit ecf21bf

Please sign in to comment.