~ubuntu-branches/ubuntu/natty/mgltools-vision/natty

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Bazaar Package Importer
  • Author(s): Steffen Moeller
  • Date: 2008-07-31 22:00:08 UTC
  • Revision ID: james.westby@ubuntu.com-20080731220008-broax3qn6pq9ygnb
Tags: upstream-1.5.2.cvs.20080731
ImportĀ upstreamĀ versionĀ 1.5.2.cvs.20080731

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
from distutils.core import setup
 
3
from distutils.command.sdist import sdist
 
4
from distutils.command.install_data import install_data
 
5
from distutils.command.build_scripts import build_scripts
 
6
from glob import glob
 
7
import os
 
8
from string import find
 
9
 
 
10
########################################################################
 
11
# Had to overwrite the prunrefile_list method of sdist to not
 
12
# remove automatically the RCS/CVS directory from the distribution.
 
13
########################################################################
 
14
 
 
15
class modified_sdist(sdist):
 
16
    def prune_file_list(self):
 
17
        """
 
18
        Prune off branches that might slip into the file list as created
 
19
        by 'read_template()', but really don't belong there:
 
20
          * the build tree (typically 'build')
 
21
          * the release tree itself (only an issue if we ran 'sdist
 
22
            previously with --keep-temp, or it aborted)
 
23
        """
 
24
        build = self.get_finalized_command('build')
 
25
        base_dir = self.distribution.get_fullname()
 
26
        self.filelist.exclude_pattern(None, prefix=build.build_base)
 
27
        self.filelist.exclude_pattern(None, prefix=base_dir)
 
28
 
 
29
class modified_install_data(install_data):
 
30
 
 
31
    def run(self):
 
32
        install_cmd = self.get_finalized_command('install')
 
33
        self.install_dir = getattr(install_cmd, 'install_lib')
 
34
        return install_data.run(self)
 
35
 
 
36
class modified_build_scripts(build_scripts):
 
37
    
 
38
    def copy_scripts(self):
 
39
        #print "scripts:" , self.scripts
 
40
        ## copy runVision.py to runVision, inserting "#!python" line at the beginning 
 
41
        for script in self.scripts:
 
42
            fnew = open(script, "w")
 
43
            forig = open(script+".py", "r")
 
44
            txt = forig.readlines()
 
45
            forig.close()
 
46
            fnew.write("#!/usr/bin/env python2.4\n")
 
47
            fnew.writelines(txt)
 
48
            fnew.close()
 
49
        build_scripts.copy_scripts(self)
 
50
 
 
51
########################################################################
 
52
 
 
53
# list of the python packages to be included in this distribution.
 
54
# sdist doesn't go recursively into subpackages so they need to be
 
55
# explicitaly listed.
 
56
# From these packages only the python modules will be taken
 
57
packages = ['Vision',
 
58
            'Vision.Tests',
 
59
            'Vision.doc.Examples.matplotlib']
 
60
 
 
61
# list of the python modules not part of a package. Give the path and the
 
62
# filename without the extension. i.e you want to add the
 
63
# test.py module which is located in MyPack/Tests/ you give
 
64
# 'MyPack/Tests/test'
 
65
py_modules = ['Vision/bin/runVision',]
 
66
 
 
67
# list of the files that are not python packages but are included in the
 
68
# distribution and need to be installed at the proper place  by distutils.
 
69
# The list in MANIFEST.in lists is needed for including those files in
 
70
# the distribution, data_files in setup.py is needed to install them
 
71
# at the right place.
 
72
data_files = []
 
73
 
 
74
def getDataFiles(file_list, directory, names):
 
75
    fs = []
 
76
    if find(directory, "Tutorial") >= 0:
 
77
        #do not include Tutorial directory in data_files
 
78
        return
 
79
    for name in names:
 
80
        ext = os.path.splitext(name)[1]
 
81
        #print directory, name, ext, len(ext)
 
82
        if ext !=".py" and ext !=".pyc":
 
83
            fullname = os.path.join(directory,name)
 
84
            if not os.path.isdir(fullname):
 
85
                fs.append(fullname)
 
86
    if len(fs):
 
87
        file_list.append((directory, fs))
 
88
 
 
89
os.path.walk("Vision", getDataFiles, data_files)
 
90
 
 
91
 
 
92
# description of what is going to be included in the distribution and
 
93
# installed.
 
94
from version import VERSION
 
95
setup (name = 'Vision',
 
96
       version = VERSION,
 
97
       description = "Vision is a Python-based Visual Programming Environment",
 
98
       author = 'Molecular Graphics Laboratory',
 
99
       author_email = 'sanner@scripps.edu',
 
100
       download_url = 'http://www.scripps.edu/~sanner/software/packager.html',
 
101
       url = 'http://www.scripps.edu/~sanner/software/index.html',
 
102
       packages = packages,
 
103
       py_modules = py_modules,
 
104
       data_files = data_files,
 
105
       scripts = ['Vision/bin/runVision'],
 
106
       cmdclass = {'sdist': modified_sdist,
 
107
                   'install_data': modified_install_data,
 
108
                   'build_scripts': modified_build_scripts
 
109
                   },
 
110
       )