Update setup to build scikits.image.opencv.

This commit is contained in:
Stefan van der Walt
2009-10-15 07:41:37 +02:00
parent 95a2e5d11b
commit 805d9ff937
2 changed files with 21 additions and 22 deletions
+19 -22
View File
@@ -3,48 +3,50 @@
import os
import shutil
base_path = os.path.dirname(__file__)
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs
config = Configuration('opencv', parent_package, top_path)
config.add_data_dir('tests')
# since distutils/cython has problems, we'll check to see if cython is
# installed and use that to rebuild the .c files, if not, we'll just build
# since distutils/cython has problems, we'll check to see if cython is
# installed and use that to rebuild the .c files, if not, we'll just build
# directly from the included .c files
cython_files = ['opencv_backend.pyx', 'opencv_cv.pyx']
try:
import Cython
for pyxfile in cython_files:
import Cython
for pyxfile in [os.path.join(base_path, f) for f in cython_files]:
# make a backup of the good c files
c_file = pyxfile.rstrip('pyx') + 'c'
src = c_file
dst = c_file + '.bak'
shutil.copy(src, dst)
# run cython compiler
os.system('cython ' + pyxfile)
# if the file is small, cython compilation failed
size = os.path.getsize(c_file)
if size < 100:
print 'Cython compilation failed. Restoring from backup.'
# restore from backup
shutil.copy(dst, src)
shutil.copy(dst, src)
except ImportError:
# if cython is not found, we just build from the include .c files
pass
for pyxfile in cython_files:
c_file = pyxfile.rstrip('pyx') + 'c'
config.add_extension(pyxfile.rstrip('.pyx'),
sources=[c_file],
include_dirs=[get_numpy_include_dirs()])
config.add_extension(pyxfile.rstrip('.pyx'),
sources=[c_file],
include_dirs=[get_numpy_include_dirs()])
return config
if __name__ == '__main__':
@@ -57,8 +59,3 @@ if __name__ == '__main__':
license = 'SciPy License (BSD Style)',
**(configuration(top_path='').todict())
)
+2
View File
@@ -39,6 +39,8 @@ def configuration(parent_package='', top_path=None, package_name=DISTNAME):
download_url = DOWNLOAD_URL,
long_description = LONG_DESCRIPTION)
config.add_subpackage('scikits.image.opencv')
return config
if __name__ == "__main__":