Permalink
Browse files

Fixed build errors on MacOS

setup.py now detects proper include dir for ImageMagick.
Using subprocess instead of deprecated os.popen.
Fixed c++ build errors according to this issue
#66

Tested on 10.9.5 with Homebrew ImageMagick, swig and pkg-config.
  • Loading branch information...
anti1869 committed Feb 17, 2015
1 parent 2c6a4d7 commit 090b1fc85df4cd5db8ed19395554af773e7c3164
Showing with 24 additions and 17 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 src/core/imgdbapi.py
  3. +2 −2 src/imgSeekLib/imgdb.cpp
  4. +20 −14 src/setup.py
View
@@ -45,3 +45,4 @@ classes
deploy
Iskdaemon_admin
gwt-unitCache
.idea
View
@@ -42,7 +42,7 @@
pbFactory = None # perspective factory
daemonStartTime = time.time()
hasShutdown = False
iskVersion = "0.9.3"
iskVersion = "0.9.5"
# misc daemon inits
rootLog = logging.getLogger('imgdbapi')
View
@@ -990,7 +990,7 @@ std::vector<double> queryImgID(const int dbId, long int id, int numres, int sket
long int sz = dbSpace[dbId]->sigs.size();
int_hashset includedIds;
sigIterator it = dbSpace[dbId]->sigs.begin();
for (int var = 0; var < min(sz, numres); ) { // var goes from 0 to numres
for (int var = 0; var < min<unsigned long>(sz, numres); ) { // var goes from 0 to numres
long int rint = rand()%(sz);
for(int pqp =0; pqp < rint; pqp++) {
it ++;
@@ -1313,7 +1313,7 @@ std::vector<double> queryImgIDKeywords(const int dbId, long int id, int numres,
vector<double> Vres;
for (int var = 0; var < min(V.size()/2, numres); ) { // var goes from 0 to numres
for (int var = 0; var < min<unsigned long>(V.size()/2, numres); ) { // var goes from 0 to numres
int rint = rand()%(V.size()/2);
if (V[rint*2] > 0) { // havent added this random result yet
Vres.insert(Vres.end(), V[rint*2] );
View
@@ -4,6 +4,7 @@
# win/linux diffs
import os
import subprocess
# reuse README as package long description
with open('README.txt') as file:
@@ -46,28 +47,33 @@
# extra_compile_args += ["-DNeedFunctionPrototypes"]
# extra_compile_args += ["-D_DLL"]
extra_compile_args += ["-D_MAGICKMOD_"]
else: # *nix
else: # *nix
hasIMagick=0
extra_compile_args += [ "-DLinuxBuild","-g"]
extra_link_args += ["-g"]
print "#################################### Check ImageMagick"
try:
fnd=0
pathvar=os.environ["PATH"]
for pv in split(pathvar,':'):
if os.path.exists(pv+'/Magick++-config') or os.path.exists(pv+'Magick++-config'):
fnd=1
fnd = False
pathvar = os.environ["PATH"]
for pv in split(pathvar, ':'):
if os.path.exists(pv + '/Magick++-config') or os.path.exists(pv + 'Magick++-config'):
fnd = True
break # pv now holds directory in which Magick++-config was found
if fnd:
IMagCFlag=os.popen("Magick++-config --cxxflags --cppflags").read()
if find(IMagCFlag,"-I") != -1:
IMagCFlag=replace(IMagCFlag,"\n"," ")
IMagCFlag=split(IMagCFlag,' ')
IMagCLib=os.popen("Magick++-config --ldflags --libs").read()
IMagCLib=replace(IMagCLib,"\n"," ")
IMagCLib=split(IMagCLib,' ')
hasIMagick=1
#IMagCFlag = os.popen("Magick++-config --cxxflags --cppflags").read() # That's deprecated now
IMagCFlag = subprocess.check_output(["Magick++-config", "--cxxflags", "--cppflags"])
if find(IMagCFlag, "-I") != -1:
if len(include_dirs) == 0: # Extract include dir from latter command output and append to include_dirs
include_dirs.append([i[2:] for i in IMagCFlag.split(' ') if i.startswith("-I")][0])
IMagCFlag = replace(IMagCFlag, "\n", " ")
IMagCFlag = split(IMagCFlag, ' ')
IMagCLib = subprocess.check_output(["Magick++-config", "--ldflags", "--libs"])
IMagCLib = replace(IMagCLib, "\n", " ")
IMagCLib = split(IMagCLib, ' ')
hasIMagick = 1
else:
print "--- WARNING ---\nUnable to find Magick++-config. Are you sure you have ImageMagick and it's development files installed correctly?"
except:
traceback.print_exc()

0 comments on commit 090b1fc

Please sign in to comment.