提交 189914fc 编写于 作者: M Marius Muja

Python distutils setup.py fixes. Changed install paths to more standard locations

上级 ce204198
.PHONY: flann tests test libs doc all clean examples
all:
@-mkdir -p build
cd build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} .. && make all doc
......@@ -24,6 +25,11 @@ examples:
@-mkdir -p build
cd build && cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} && make $@
install:
@-mkdir -p build
cd build && cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} .. && make all doc install
clean:
-cd build && make clean
-rm -rf build
......
......@@ -55,6 +55,6 @@ if (EXISTS ${PDFLATEX_COMPILER} AND EXISTS ${BIBTEX_COMPILER})
install (
FILES ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.pdf
DESTINATION doc
DESTINATION share/doc/flann
)
endif()
......@@ -44,7 +44,7 @@ if(MEX_CMD AND MEXEXT_CMD)
INSTALL (
FILES ${MEX_FILE} ${MATLAB_SOURCES}
DESTINATION matlab
DESTINATION share/flann/matlab
)
else()
message("The 'mex' and 'mexext' programs have been found in different locations. It's likely that one of them is not part of the MATLAB instalation. Make sure that the 'bin' directory from the MATLAB instalation is in PATH")
......
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/setup.py.tpl
${CMAKE_CURRENT_SOURCE_DIR}/setup.py
)
INSTALL (
PROGRAMS flann
......@@ -7,17 +11,20 @@ INSTALL (
INSTALL (
FILES setup.py flann
DESTINATION python
DESTINATION share/flann/python
)
INSTALL (
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pyflann
DESTINATION python
DESTINATION share/flann/python
PATTERN *.cpp EXCLUDE
PATTERN *.so EXCLUDE
PATTERN *.a EXCLUDE
PATTERN *.dat EXCLUDE
PATTERN *.txt EXCLUDE
PATTERN *.tpl EXCLUDE
PATTERN *~ EXCLUDE
PATTERN _tests EXCLUDE
)
\ No newline at end of file
)
......@@ -123,25 +123,38 @@ allowed_types = [ float32, float64, uint8, int32]
FLANN_INDEX = c_void_p
def load_flann_library():
root_dir = os.path.abspath(os.path.dirname(__file__))
libname = 'libflann'
libname = 'libflann.so'
if sys.platform == 'win32':
libname = 'flann'
libname = 'flann.dll'
elif sys.platform == 'darwin':
libname = 'libflann.dylib'
flannlib = None
loaded = False
while (not loaded) and root_dir!="/":
while (not loaded) and root_dir!=None:
try:
# print "Trying ",os.path.join(root_dir,'lib')
flannlib = load_library(libname, os.path.join(root_dir,'lib'))
#print "Trying ",os.path.join(root_dir,'lib',libname)
flannlib = cdll[os.path.join(root_dir,'lib',libname)]
loaded = True
except Exception as e:
# print e
root_dir = os.path.dirname(root_dir)
if root_dir == '/':
root_dir = None
else:
root_dir = os.path.dirname(root_dir)
if not loaded:
try:
#print "Trying",libname
flannlib=cdll[libname]
loaded = True
except:
pass
return flannlib
......
......@@ -27,56 +27,67 @@
from __future__ import with_statement
from pyflann.exceptions import FLANNException
import h5py
import numpy
have_h5py = True
try:
import h5py
except Exception as e:
have_h5py = False
if not have_h5py:
def __missing_h5py(*args,**kwargs):
raise FLANNException("h5py library not found")
check = __missing_h5py
save = __missing_h5py
load = __missing_h5py
load_range = __missing_h5py
else:
def check(filename):
f = open(filename,"r")
header = f.read(4)
if header[1:4]=="HDF": return True
return False
def check(filename):
f = open(filename,"r")
header = f.read(4)
if header[1:4]=="HDF": return True
return False
def save(dataset, filename, **kwargs):
if not isinstance(dataset,numpy.ndarray):
raise FLANNException("Dataset must be in numpy format")
try:
if 'title' in kwargs:
title_name = kwargs['title']
else:
title_name = "Dataset saved by pyflann"
if 'dataset_name' in kwargs:
dataset_name = kwargs['dataset_name']
else:
dataset_name = 'dataset'
h5file = h5py.File(filename)
h5file.create_dataset(dataset_name, dataset)
h5file.close()
except Exception as e:
h5file.close()
raise FLANNException(e)
def save(dataset, filename, **kwargs):
if not isinstance(dataset,numpy.ndarray):
raise FLANNException("Dataset must be in numpy format")
try:
if 'title' in kwargs:
title_name = kwargs['title']
else:
title_name = "Dataset saved by pyflann"
if 'dataset_name' in kwargs:
dataset_name = kwargs['dataset_name']
else:
dataset_name = 'dataset'
h5file = h5py.File(filename)
h5file.create_dataset(dataset_name, dataset)
h5file.close()
except Exception as e:
h5file.close()
raise FLANNException(e)
def load(filename, rows = -1, cols = -1, dtype = numpy.float32, **kwargs):
try:
h5file = h5py.File(filename)
if 'dataset_name' in kwargs:
dataset_name = kwargs['dataset_name']
else:
dataset_name = 'dataset'
for node in h5file.keys():
if node == dataset_name:
data = h5file[node]
h5file.close()
return data
except Exception as e:
h5file.close()
raise FLANNException(e)
def load(filename, rows = -1, cols = -1, dtype = numpy.float32, **kwargs):
try:
def load_range(filename, array_name, range):
h5file = h5py.File(filename)
if 'dataset_name' in kwargs:
dataset_name = kwargs['dataset_name']
else:
dataset_name = 'dataset'
for node in h5file.keys():
if node == dataset_name:
data = h5file[node]
h5file.close()
return data
except Exception as e:
h5file.close()
raise FLANNException(e)
def load_range(filename, array_name, range):
h5file = h5py.File(filename)
dataset = h5file[array_name]
return dataset[range[0]:range[1]]
dataset = h5file[array_name]
return dataset[range[0]:range[1]]
#!/usr/bin/env python
from distutils.core import setup
import os.path
import sys
setup_path = os.path.dirname(os.path.abspath(sys.argv[0]))
lib_path = os.path.abspath(os.path.join(setup_path,'../../../lib'))
setup(name='flann',
version='1.2',
version='1.5.0',
description='Fast Library for Approximate Nearest Neighbors',
author='Marius Muja',
author_email='mariusm@cs.ubc.ca',
license='BSD',
url='http://www.cs.ubc.ca/~mariusm/flann/',
packages=['pyflann','pyflann.command', 'pyflann.io', 'pyflann.bindings', 'pyflann.util'],
packages=['pyflann','pyflann.command', 'pyflann.io', 'pyflann.bindings', 'pyflann.util', 'pyflann.lib'],
scripts=['flann'],
package_data={'pyflann.bindings' : ['libflann.so','flann.dll', 'libflann.dylib']},
package_dir={'pyflann.lib':lib_path},
package_data={'pyflann.lib': ['libflann.so','flann.dll', 'libflann.dylib']},
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册