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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
import os
import imp
from distutils.core import setup
from csb.build import ROOT
try:
__doc__ = open('README.txt').read()
except IOError:
pass
LOCATION = os.path.abspath(os.path.dirname(__file__))
JUNK = ['.svn', '.hg', '.hgtags']
NAME = ROOT
VERSION = imp.load_source('____csb', os.path.join(LOCATION, ROOT, '__init__.py')).Version()
AUTHOR = "Michael Habeck et al."
EMAIL = "ivan.kalev@gmail.com"
URL = "http://csb.codeplex.com"
SUMMARY = "Computational Structural Biology Toolbox"
DESCRIPTION = __doc__
LICENSE = 'MIT'
REQUIRES = ['numpy', 'scipy']
def sourcetree(root='csb', junk=JUNK):
"""
Since distutils requires to HARD CODE the entire package hierarchy here,
we need this function to load the source tree structure dynamically.
@param root: name of the root package; this is 'csb'. Must be relative!
@type root: str
@param junk: skip those directories
@type junk: tuple
@return: a list of "package" names
@rtype: list
"""
junk = set(junk)
items = []
curdir = os.path.abspath(os.curdir)
cwd = os.path.dirname(__file__) or '.'
os.chdir(cwd)
if root.startswith(os.path.sep):
raise ValueError('root must be a relative path')
elif not os.path.isdir(os.path.join('.', root)):
raise ValueError('root package "{0}" not found in {1}.'.format(root, cwd))
for entry in os.walk(root):
directory = entry[0]
parts = set(directory.split(os.path.sep))
init = os.path.join(directory, '__init__.py')
# take all packages: directories with __init__, except if a junk
# directory is found at any level in the tree
if os.path.isfile(init) and junk.isdisjoint(parts):
items.append(directory)
os.chdir(curdir)
return items
def datatree(package, dataroot, junk=JUNK, mask='*.*'):
"""
Since distutils will crash if the data root folder contains any subfolders,
we need this function to retrieve the data tree.
@param package: root "package", containing a data folder. This is a
relative path, e.g. "csb/test"
@type package: str
@param dataroot: name of the data root directory for C{package},
relative to C{package}
@type dataroot: str
@param junk: skip those directories
@type junk: tuple
@return: a list of all glob patterns with all subdirectories of the data
root, including the root itself. The paths returned are relative
to C{package}
@rtype: list
"""
junk = set(junk)
items = []
curdir = os.path.abspath(os.curdir)
cwd = os.path.dirname(__file__) or '.'
os.chdir(cwd)
if package.startswith(os.path.sep):
raise ValueError('package must be a relative path')
elif not os.path.isdir(os.path.join('.', package)):
raise ValueError('package "{0}" not found in {1}.'.format(package, cwd))
os.chdir(package)
for entry in os.walk(dataroot):
directory = entry[0]
parts = set(directory.split(os.path.sep))
# take all directories, except if a junk dir is found at any level in the tree
if junk.isdisjoint(parts):
item = os.path.join(directory, mask)
items.append(item)
os.chdir(curdir)
return items
def build():
test = os.path.join('csb', 'test')
nmr = os.path.join('csb', 'bio', 'nmr')
return setup(
name=NAME,
packages=sourcetree(NAME, JUNK),
package_data={
test: datatree(test, 'data', JUNK, '*.*'),
nmr: datatree(nmr, 'resources', JUNK, '*.*')
},
version=VERSION.short,
author=AUTHOR,
author_email=EMAIL,
url=URL,
description=SUMMARY,
long_description=DESCRIPTION,
license=LICENSE,
requires=REQUIRES,
classifiers=(
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Software Development :: Libraries'
)
)
if __name__ == '__main__':
build()
|