#!/usr/bin/env python
import sys
import os.path
import platform
import warnings

try:
    from setuptools import setup, Extension
except ImportError:
    from disutils.core import setup, Extension

extoptions = {}
pkgdata = {}

LCB_NAME = None
if sys.platform != 'win32':
    extoptions['libraries'] = ['couchbase']
else:
    warnings.warn("I'm detecting you're running windows."
                  "You might want to modify "
                  "the 'setup.py' script to use appropriate paths")


    # The layout i have here is an ..\lcb-winbuild, in which there are subdirs
    # called 'x86' and 'x64', for x86 and x64 architectures. The default
    # 'nmake install' on libcouchbase will install them to 'deps'
    bit_type = platform.architecture()[0]
    lcb_root = os.path.join(os.path.pardir, 'lcb-winbuild')

    if bit_type.startswith('32'):
        lcb_root = os.path.join(lcb_root, 'x86')
    else:
        lcb_root = os.path.join(lcb_root, 'x64')

    lcb_root = os.path.join(lcb_root, 'deps')

    extoptions['libraries'] = ['libcouchbase']
    ## Enable these lines for debug builds
    #extoptions['extra_compile_args'] = ['/Zi']
    #extoptions['extra_link_args'] = ['/DEBUG']
    extoptions['library_dirs'] = [os.path.join(lcb_root, 'lib')]
    extoptions['include_dirs'] = [os.path.join(lcb_root, 'include')]
    pkgdata['couchbase'] = ['libcouchbase.dll']


SOURCEMODS = (
        'argument',
        'exceptions',
        'ext',
        'result',
        'opresult',
        'callbacks',
        'convert',
        'connection',
        'store',
        'constants',
        'multiresult',
        'miscops',
        'typeutil',
        'oputil',
        'get',
        'arithmetic',
        'http',
        'htresult',
        'ctranscoder',
        'observe',
        os.path.join('viewrow', 'viewrow'),
        os.path.join('contrib', 'jsonsl', 'jsonsl')
        )

extoptions['sources'] = [ os.path.join("src", m + ".c") for m in SOURCEMODS ]
module = Extension('couchbase._libcouchbase', **extoptions)

setup(
    name = 'couchbase',
    version = '1.0.0-beta',
    url="https://github.com/couchbase/couchbase-python-client",
    author="Couchbase, Inc.",
    author_email="mark.nunberg@couchbase.com",
    license="Apache License 2.0",
    description="Python Client for Couchbase",
    long_description=open("README.rst", "r").read(),
    keywords=["couchbase", "nosql", "pycouchbase", "libcouchbase"],

    classifiers=[
        "Development Status :: 4 - Beta",
        "License :: OSI Approved :: Apache Software License",
        "Intended Audience :: Developers",
        "Operating System :: OS Independent",
        "Programming Language :: Python",
        "Programming Language :: Python :: 2",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: Implementation :: CPython",
        "Topic :: Database",
        "Topic :: Software Development :: Libraries",
        "Topic :: Software Development :: Libraries :: Python Modules"],

    ext_modules = [module],
    packages = ['couchbase', 'couchbase.views'],
    package_data = pkgdata
)

@@ -41,16 +41,26 @@
 os.path%0A
+import os%0A
 import p
@@ -67,16 +67,16 @@
 latform%0A
-
 import w
@@ -89,16 +89,91 @@
 s%0A%0Atry:%0A
+    if os.environ.get('PYCBC_NO_DISTRIBUTE'):%0A        raise ImportError()%0A%0A
     from
@@ -228,16 +228,16 @@
 tError:%0A
-
     from
@@ -240,16 +240,17 @@
 from dis
+t
 utils.co

Fix breakage when distribute is not installed