Created
September 21, 2016 13:50
-
-
Save michaelgugino/5e2163997bedcc13b4e2d61a0dcbf35a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import setuptools | |
import sys, io, os, glob | |
from setuptools import setup, find_packages, Extension | |
# In python < 2.7.4, a lazy loading of package `pbr` will break | |
# setuptools if some other modules registered functions in `atexit`. | |
# solution from: http://bugs.python.org/issue15881#msg170215 | |
try: | |
import multiprocessing # noqa | |
except ImportError: | |
pass | |
MYDIR = os.path.abspath(os.path.dirname(__file__)) | |
#Cython Support | |
try: | |
from Cython.Distutils import build_ext | |
CYTHON = True | |
except ImportError: | |
CYTHON = False | |
if CYTHON: | |
def list_modules(dirname): | |
filenames = glob.glob(os.path.join(dirname, '*.py')) | |
module_names = [] | |
for name in filenames: | |
module, ext = os.path.splitext(os.path.basename(name)) | |
if module != '__init__': | |
module_names.append(module) | |
return module_names | |
exclude_pkgs = [ | |
'keystone.tests.*', | |
'keystone.tests'] | |
package_names = setuptools.find_packages(where='.', exclude=exclude_pkgs) | |
exclude_mods = [] | |
ext_modules = [] | |
for package in package_names: | |
for module in list_modules(os.path.join(MYDIR, *package.split('.'))): | |
pkg = os.path.join(*(package.split('.') + [module + '.py'])) | |
if pkg not in exclude_mods: | |
print pkg | |
ext_modules.append(Extension(package + '.' + module, [pkg])) | |
else: | |
ext_modules = [] | |
setuptools.setup( | |
ext_modules = ext_modules, | |
setup_requires=['pbr>=1.8'], | |
pbr=True | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment