File: setup.py

package info (click to toggle)
mgltools-utpackages 1.5.6~rc3~cvs.20120601-1
  • links: PTS, VCS
  • area: non-free
  • in suites: wheezy
  • size: 34,376 kB
  • sloc: cpp: 688,785; ansic: 2,335; python: 2,308; makefile: 224; sh: 72
file content (142 lines) | stat: -rw-r--r-- 4,963 bytes parent folder | download | duplicates (4)
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
from distutils.core import setup, Extension
from distutils.cmd import Command
from distutils.command.install import install
from distutils.command.build import build
from distutils.command.sdist import sdist
from distutils import log
from glob import glob
from distutils.command.build_ext import build_ext
import sys, os
from os import path
import string
import traceback

pack_name = "UTpackages"
packages = ["UTpackages","UTpackages.Tests"]
subpackages = ["UTblur", "UTisocontour", "UTvolrend", "UTmesh", "UTsdf", "UTmolderivatives"]
## if sys.platform == "linux2":
##     subpackages.append("UTimposter")
currdir = os.getcwd()
status=[]


#Overwrite run() method of Distutils build class to loop over
# subpackages and execute their setup.py

class modified_build(build):
    sub_commands = [('build_clib',    build.has_c_libraries),
                    ('build_ext',     build.has_ext_modules),
                    ('build_py',      build.has_pure_modules),
                    ('build_scripts', build.has_scripts),
                   ]
    def run(self):
        args = sys.argv
        if args[1] != "install":
            for pack in subpackages:
                os.chdir(pack+"DIST")
                log.info("Current directory : %s"%os.getcwd() )
                cmd = "%s setup.py build"%sys.executable
                st = os.system(cmd)
                if st != 0:
                    status.append([pack,cmd])
                os.chdir(currdir)
        log.info("Current directory : %s"%os.getcwd())
        #sys.argv = args
        build.run(self)
        

class modified_sdist(sdist):

    def prune_file_list(self):
        """Overvrite the 'sdist' method to not remove automatically the RCS/CVS
        directories from the distribution. """
        build = self.get_finalized_command('build')
        base_dir = self.distribution.get_fullname()
        self.filelist.exclude_pattern(None, prefix=build.build_base)
        self.filelist.exclude_pattern(None, prefix=base_dir)
        
    def run(self):
        for pack in subpackages:
            os.chdir(pack+"DIST")
            log.info("Current directory : %s"%os.getcwd() )
            cmd = "%s setup.py sdist --manifest-only"%sys.executable
            #print "running command: ", cmd
            st = os.system(cmd)
            if st != 0:
                status.append([pack, cmd])
            os.chdir(currdir)
        log.info("Current directory : %s"%os.getcwd() )
        sdist.run(self)

    def read_manifest (self, dirname =None):
        """Read the manifest file (named by 'self.manifest') and use it to
        fill in 'self.filelist', the list of files to include in the source
        distribution.
        """
        log.info("reading manifest file '%s'", self.manifest)
        manifest = open(self.manifest)
        while 1:
            line = manifest.readline()
            if line == '':              # end of file
                break
            if line[-1] == '\n':
                line = line[0:-1]
            if dirname:
                line = path.join(dirname, line)
            self.filelist.append(line)


    def write_manifest (self):
        currmanifest = self.manifest
        for pack in subpackages:
            self.manifest = path.join(pack+"DIST", "MANIFEST")
            self.read_manifest(dirname = pack+"DIST")
        self.manifest = currmanifest
        #print self.filelist.files
        sdist.write_manifest(self)
        
#Overwrite run() method of Distutils install class to loop over
# subpackages and execute their setup.py

class modified_install(install):

    def run(self):
        args = sys.argv
        cmd = "%s"%sys.executable
        for e in args:
            cmd = cmd + " " + e
        print "command: ", cmd
        for pack in subpackages:
            os.chdir(pack+"DIST")
            log.info("Current directory : %s"%os.getcwd() )
            #sys.argv = args 
            #print "args:" , sys.argv
            st = os.system(cmd)
            if st != 0:
                status.append([pack, cmd])
            os.chdir(currdir)
        log.info("Current directory : %s"%os.getcwd() )
        install.run(self)
        
try:   
    from version import VERSION
except:
    VERSION = "1.0"
    
dist = setup(name=pack_name,
             version=VERSION,
             description = "UT Austin software Python extensions",
             author = 'Molecular Graphics Laboratory',
             author_email = "mgltools@scripps.edu",
             download_url = "http://www.scripps.edu/~sanner/python/packager.html",
             url = 'http://www.scripps.edu/~sanner/software/index.html',
             
             packages = packages,
             cmdclass = {'build':modified_build,
                         'sdist':modified_sdist,
                         'install': modified_install},
             
             )
if len(status):
    for i in status:
        print "Error in  package %s , command: '%s' "%(i[0], i[1])