File: setup.py

package info (click to toggle)
wxglade 0.6.5-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,348 kB
  • sloc: python: 24,679; xml: 1,022; makefile: 135; sh: 4
file content (194 lines) | stat: -rw-r--r-- 6,206 bytes parent folder | download | duplicates (2)
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# -*- coding: Latin-1 -*-
#
# License: MIT (see license.txt)
# THIS PROGRAM COMES WITH NO WARRANTY

from distutils.core import setup
import distutils.command.sdist
from distutils.util import convert_path

import os
from types import *
from glob import glob
import common

# distutils sdisk command is broken because it doesn't copy data_files
# Bug: http://bugs.python.org/issue2279
def add_defaults_fixed(self):
    """Add all the default files to self.filelist:
      - README or README.txt
      - setup.py
      - test/test*.py
      - all pure Python modules mentioned in setup script
      - all files pointed by package_data (build_py)
      - all files defined in data_files.
      - all files defined as scripts.
      - all C sources listed as part of extensions or C libraries
        in the setup script (doesn't catch C headers!)
    Warns if (README or README.txt) or setup.py are missing; everything
    else is optional.
    """
    standards = [('README', 'README.txt'), self.distribution.script_name]
    for fn in standards:
        if isinstance(fn, tuple):
            alts = fn
            got_it = False
            for fn in alts:
                if os.path.exists(fn):
                    got_it = True
                    self.filelist.append(fn)
                    break

            if not got_it:
                self.warn("standard file not found: should have one of " +
                          ', '.join(alts))
        else:
            if os.path.exists(fn):
                self.filelist.append(fn)
            else:
                self.warn("standard file '%s' not found" % fn)

    optional = ['test/test*.py', 'setup.cfg']
    for pattern in optional:
        files = filter(os.path.isfile, glob(pattern))
        self.filelist.extend(files)

    # build_py is used to get:
    #  - python modules
    #  - files defined in package_data
    build_py = self.get_finalized_command('build_py')

    # getting python files
    if self.distribution.has_pure_modules():
        self.filelist.extend(build_py.get_source_files())

    # getting package_data files
    # (computed in build_py.data_files by build_py.finalize_options)
    for pkg, src_dir, build_dir, filenames in build_py.data_files:
        for filename in filenames:
            self.filelist.append(os.path.join(src_dir, filename))

    # getting distribution.data_files
    if self.distribution.has_data_files():
        for item in self.distribution.data_files:
            if isinstance(item, str): # plain file
                item = convert_path(item)
                if os.path.isfile(item):
                    self.filelist.append(item)
            else:    # a (dirname, filenames) tuple
                dirname, filenames = item
                for f in filenames:
                    f = convert_path(f)
                    if os.path.isfile(f):
                        self.filelist.append(f)

    if self.distribution.has_ext_modules():
        build_ext = self.get_finalized_command('build_ext')
        self.filelist.extend(build_ext.get_source_files())

    if self.distribution.has_c_libraries():
        build_clib = self.get_finalized_command('build_clib')
        self.filelist.extend(build_clib.get_source_files())

    if self.distribution.has_scripts():
        build_scripts = self.get_finalized_command('build_scripts')
        self.filelist.extend(build_scripts.get_source_files())


# Replace old implementation by the new own
distutils.command.sdist.sdist.add_defaults = add_defaults_fixed

def is_package(path):
    return (
        os.path.isdir(path) and
        os.path.isfile(os.path.join(path, '__init__.py'))
        )

def find_packages(path, base="" ):
    """ Find all packages in path """
    packages = {}
    for item in os.listdir(path):
        dir = os.path.join(path, item)
        if is_package( dir ):
            if base:
                module_name = "%(base)s.%(item)s" % vars()
            else:
                module_name = item
            packages[module_name] = dir
            packages.update(find_packages(dir, module_name))
    return packages

classifiers = """\
Development Status :: 4 - Beta
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Natural Language :: English
Operating System :: OS Independent (Written in an interpreted language)
Programming Language :: Python :: 2
Topic :: Software Development :: Code Generators
User Interface :: Textual :: Command-line
User Interface :: Toolkits/Libraries :: wxWidgets"""

description = \
    'GUI designer written in Python with the popular GUI toolkit wxPython'

data_files = [[
        'share/doc/wxglade',
        ['CHANGES.txt', 'credits.txt', 'epydoc.conf', 'license.txt',
         'Makefile', 'NEWS.txt', 'README.txt', 'TODO.txt',],
    ],[
       'share/doc/wxglade/doc',
       glob('docs/*.html'),
    ],[
       'share/doc/wxglade/doc/img',
       glob('docs/img/*.*'),
    ],[
       'share/doc/wxglade/doc',
       glob('docs/*.txt'),
    ],[
       'share/doc/wxglade/doc/html',
       glob('docs/html/*.*'),
    ],[
       'share/doc/wxglade/doc/pdf',
       glob('docs/pdf/*.pdf'),
    ],[
       'share/man/man1',
       ['docs/man/wxglade.1'],
    # documentation source files :-)
    ],[
       'share/doc/wxglade',
       ['docs/man/manpage.xml'],
    ],[
       'share/doc/wxglade',
       ['docs/src/manual.xml'],
    ]]


scripts = ['wxglade',]

packages = find_packages(path=".", base='wxglade').keys()
packages.append('wxglade')

version = common.version

setup(
    name='wxGlade',
    version=version,
    author='Alberto Griggio',
    author_email='agriggio@users.sourceforge.net',
    url='http://wxglade.sourceforge.net/',
    classifiers=classifiers.split("\n"),
    description=description,
    license='MIT License',
    platforms = ['WIN32', 'OSX', 'POSIX'],
    scripts=scripts,
    packages=packages,
    package_dir={'wxglade': '.'},
    package_data={'wxglade.widgets': ['widgets.txt'],
                  'wxglade' : ['icons/*.*', 
                              'icons/gtk/*.*',
                              'icons/msw/*.*',
                              'res/*.*',
                              ]},
    data_files=data_files,
    )