Skip to content

Commit

Permalink
Build script improvements
Browse files Browse the repository at this point in the history
* add boost prefix style used by CentOS (e.g. boost148) for includes
* add BOOST_PREFIX to specify custom Boost installation
* add PROTOZETO_PREFIX to specify path to Protozero

See: osmcode#49
  • Loading branch information
wiktorn committed May 20, 2018
1 parent a6ed7f2 commit 8f64ba4
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,23 @@ def get_versions():

includes.append(os.path.join(boost_prefix, 'include'))
if 'BOOST_VERSION' in os.environ:
includes.append(os.path.join(boost_prefix, 'include',
"boost-%s" %os.environ['BOOST_VERSION']))
for boost_dir in ('boost-%s', 'boost%s'):
if os.path.isdir(os.path.join(boost_prefix, 'include', boost_dir % os.environ['BOOST_VERSION'])):
includes.append(os.path.join(boost_prefix, 'include', boost_dir %os.environ['BOOST_VERSION']))
break
else:
raise Exception("Cannot find boost headers")
elif 'BOOST_PREFIX' in os.environ:
if os.path.isdir(os.path.join(boost_prefix, 'include', 'boost')):
includes.append(os.path.join(boost_prefix, 'include', 'boost'))
else:
raise Exception("Cannot find boost headers")

if 'BOOST_VERSION' in os.environ:
libdirs.append(os.path.join(boost_prefix, 'lib'))
elif osplatform in ["linux", "linux2"]:
elif 'BOOST_PREFIX' in os.environ:
libdirs.append(os.path.join(boost_prefix, 'lib'))
elif osplatform in ["linux", "linux2"] and os.path.isdir('/usr/lib/x86_64-linux-gnu/'):
libdirs.append('/usr/lib/x86_64-linux-gnu/')
else:
libdirs.append(os.path.join(boost_prefix, 'lib'))
Expand Down Expand Up @@ -118,10 +129,20 @@ def cpp_compiler(compiler):
print("Using global libosmium.")

### protozero dependencies
for prefix in [ 'protozero-' + protozero_version, '../protozero' ]:
if os.path.isfile(os.path.join(prefix, 'include/protozero/version.hpp')):
print("protozero found in '%s'" % prefix)
includes.insert(0, os.path.join(prefix, 'include'))
if 'PROTOZERO_PREFIX' in os.environ:
pz_version_h = os.path.join(os.environ['PROTOZERO_PREFIX'],
'include', 'protozero', 'version.hpp')
if not os.path.isfile(pz_version_h):
raise RuntimeError("PROTOZERO_PREFIX is set but no protozero was found in '%s'" % os.environ['PROTOZERO_PREFIX'])
includes.insert(0, os.path.join(os.environ['PROTOZERO_PREFIX'], 'include'))
else:
for prefix in [ 'protozero-' + protozero_version, '../protozero', 'protozero' ]:
if os.path.isfile(os.path.join(prefix, 'include/protozero/version.hpp')):
print("protozero found in '%s'" % prefix)
includes.insert(0, os.path.join(prefix, 'include'))
break
else:
raise RuntimeError("Protozero not found")

if osplatform == "win32" :
osmium_libs = ('expat', 'zlib', 'bzip2', 'ws2_32')
Expand Down Expand Up @@ -202,4 +223,3 @@ def cpp_compiler(compiler):
cmdclass={'sdist' : My_sdist},
ext_modules = extensions)


0 comments on commit 8f64ba4

Please sign in to comment.