Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 112 lines (92 sloc) 3.809 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
import sys

try:
  import setuptools as distutils
except ImportError:
  print 'Could not find setuptools, bailing.'
  sys.exit(1)

import errno
import glob
import os
import shutil

from distutils.core import setup, Extension

abs_top_srcdir = '@abs_top_srcdir@'
abs_top_builddir = '@abs_top_builddir@'

src_python_dist = os.path.join('src', 'python', 'dist')
src_python_native = os.path.join('src', 'python', 'native')

protobuf = os.path.join('third_party', 'protobuf-2.4.1')
glog = os.path.join('third_party', 'glog-0.3.1')
leveldb = os.path.join('third_party', 'leveldb')
zookeeper = os.path.join('third_party', 'zookeeper-3.3.4', 'src', 'c')
libprocess = os.path.join('third_party', 'libprocess')

# Even though a statically compiled libprocess should include libev,
# before installation this isn't the case, so while a libtool managed
# build will correctly pull in libev when building the final result,
# we need to explicitely include libev here (or more precisely, down
# where we actually include libev.a).
libev = os.path.join(libprocess, 'third_party', 'libev-3.8')

# We need to execute from the same directory as this script.
os.chdir(os.path.abspath(os.path.dirname(__file__)))

# Copy the native source files if we are building in a remote build
# directory. This is necessary because the sources list must be
# relative to the directory where this script resides.
# $ cp -rf abs_top_srcdir/native abs_top_builddir/native
if os.path.abspath(abs_top_srcdir) != os.path.abspath(abs_top_builddir):
  try:
    shutil.rmtree(os.path.join(abs_top_builddir, src_python_native), ignore_errors=True)
    shutil.copytree(os.path.join(abs_top_srcdir, src_python_native),
                    os.path.join(abs_top_builddir, src_python_native))
  except OSError, e:
    if e.errno != errno.EEXIST:
      raise


# Build the list of source files. Note that each source must be
# relative to our current directory (where this script lives).
SOURCES = [
  os.path.join('native', file)
    for file in os.listdir(os.path.join(abs_top_srcdir, src_python_native))
      if file.endswith('.cpp')
]

INCLUDE_DIRS = [
   os.path.join(abs_top_srcdir, 'include'),
   os.path.join(abs_top_builddir, 'include'),
   os.path.join(abs_top_builddir, 'src'),
   os.path.join(abs_top_builddir, src_python_native),
   os.path.join(abs_top_builddir, 'third_party', 'protobuf-2.4.1', 'src'),
]

LIBRARY_DIRS = []

EXTRA_OBJECTS = [
  os.path.join(abs_top_builddir, 'src', '.libs', 'libmesos_no_third_party.a'),
  os.path.join(abs_top_builddir, protobuf, 'src', '.libs', 'libprotobuf.a'),
  os.path.join(abs_top_builddir, glog, '.libs', 'libglog.a'),
  os.path.join(abs_top_builddir, leveldb, 'libleveldb.a'),
  os.path.join(abs_top_builddir, zookeeper, '.libs', 'libzookeeper_mt.a'),
  os.path.join(abs_top_builddir, libprocess, '.libs', 'libprocess.a'),
  os.path.join(abs_top_builddir, libev, '.libs', 'libev.a'),
]

EXTRA_LINK_ARGS = []

# Add any libraries from LIBS.
if 'LIBS' in os.environ:
  for library in os.environ['LIBS'].split():
    EXTRA_LINK_ARGS.append(library)

DEPENDS = [
  os.path.join(abs_top_srcdir, 'src', 'python', source)
    for source in SOURCES
]

# Note that we add EXTRA_OBJECTS to our dependency list to make sure
# that we rebuild this module when one of them changes (e.g.,
# libprocess).
mesos_module = \
  Extension('_mesos',
            sources = SOURCES,
            include_dirs = INCLUDE_DIRS,
            library_dirs = LIBRARY_DIRS,
            extra_objects = EXTRA_OBJECTS,
            extra_link_args = EXTRA_LINK_ARGS,
            depends = EXTRA_OBJECTS,
            language = 'c++',
            )

setup(name = 'mesos',
      version = '@PACKAGE_VERSION@',
      description = 'Mesos',
      package_dir = { '': 'src' },
      packages = ['.'],
      ext_modules = [mesos_module])
Something went wrong with that request. Please try again.