Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixbug: Now, the cmake runs during the installation of the package
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 not shown.