Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Remove the suite concept and do not take complete control over the py…
Browse files Browse the repository at this point in the history
…2exe options dict. Require pygtk2exe.includes in the options dict though.
  • Loading branch information
dieterv committed Feb 8, 2011
1 parent e154e4e commit 418a0f6
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 145 deletions.
10 changes: 0 additions & 10 deletions TODO
Expand Up @@ -2,16 +2,6 @@
> use distutils.spanw.find_executable() ?
> ???

* Not sure yet about py2exe options. I'm strongly leaning towards giving pygtk2exe
complete control over this dict, limiting py2exe to a "known good configuration".
Especially viewing how much incomplete and erroneous information has been spread
in the past... We could then add support for more "exotic" options if there's
sufficient interest and it's proven to work. Hey, maybe we can even gain extra
contributors this way :)

> If we decide to do this, we need to pass useful options from pygtk2exe to
py2exe. An incomplete list: dist_dir, includes, packages, ???

* Provide a "filter", so it becomes possible to filter out for example
share/locale/whetever_languages_we_dont_need.
> regex or glob?
Expand Down
40 changes: 21 additions & 19 deletions doc/examples/complex/setup.py
Expand Up @@ -14,48 +14,50 @@


from distutils.core import setup
from pygtk2exe import Suite, Extension, Console, Windows
from distutils.extension import Extension
from pygtk2exe import Console, Windows


suite = Suite(author = 'Monty Python <monty.python@localhost.localnet>',
company_name = 'Monty Corporation',
license = 'GPLv3')

_cli = Extension(suite,
'_tools',
_cli = Extension('_tools',
sources=['lib/foobar/_tools.c'])

cli = Console(suite,
name = 'cli',
cli = Console(name = 'cli',
version = '0.0.1',
description = 'FooBar Administration Tool',
url = 'http://localhost/FooBar/Cli',
script = 'bin/cli.py',
icon_resources = [(1, "share/foobar/system-run.ico")])

bar = Windows(suite,
name = 'bar',
bar = Windows(name = 'bar',
version = '1.0.7',
description = 'Bar Application',
url = 'http://localhost/FooBar/Bar',
script = 'bin/bar.py',
icon_resources = [(1, "share/foobar/system-run.ico")])

foo = Windows(suite,
name = 'foo',
foo = Windows(name = 'foo',
version = '1.1.4',
description = 'Foo Application',
url = 'http://localhost/FooBar/Foo',
script = 'bin/foo.py',
icon_resources = [(1, "share/foobar/system-run.ico")])


#options = {"py2exe": {'dist_dir': 'dist',
# 'packages': 'foobar'}
options = {'pygtk2exe': {'includes': ['pygtk']}}


if __name__ == '__main__':
setup(ext_modules = [_cli],
suite = suite,
options = options)
setup(name = 'complex example',
version = '0.0.1',
description = 'complex pygtk2exe example',
author = 'Monty Python',
license = 'GPLv3',
classifiers = ['Development Status :: 1 - Planning',
'Environment :: X11 Applications :: GTK',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules'],
ext_modules = [_cli],
console = [cli],
windows = [bar, foo],
options = options)
28 changes: 18 additions & 10 deletions doc/examples/glade/setup.py
Expand Up @@ -11,25 +11,33 @@


from distutils.core import setup
from pygtk2exe import Suite, Windows
from pygtk2exe import Windows


suite = Suite(author = 'Monty Python <monty.python@localhost.localnet>',
company_name = 'Monty Corporation',
license = 'GPLv3')

test = Windows(suite,
name = 'test',
test = Windows(name = 'test',
version = '0.0.1',
description = 'Test Application',
url = 'http://localhost/Test/',
author = 'Monty Python <monty.python@localhost.localnet>',
company_name = 'Monty Corporation',
license = 'GPLv3',
script = 'test.py',
data_files = [('bin', ['test.glade'])])


options = {'pygtk2exe': {'includes': ['pygtk']}}


if __name__ == '__main__':
setup(suite = suite,
options = options)
setup(name = 'glade-example',
version = '0.0.1',
description = 'pygtk2exe example using libglade',
author = 'Monty Python',
license = 'GPLv3',
classifiers = ['Development Status :: 1 - Planning',
'Environment :: X11 Applications :: GTK',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules'],
windows = [test],
options = options)
28 changes: 18 additions & 10 deletions doc/examples/simple/setup.py
Expand Up @@ -11,24 +11,32 @@


from distutils.core import setup
from pygtk2exe import Suite, Windows
from pygtk2exe import Windows


suite = Suite(author = 'Monty Python <monty.python@localhost.localnet>',
company_name = 'Monty Corporation',
license = 'GPLv3')

test = Windows(suite,
name = 'test',
test = Windows(name = 'test',
version = '0.0.1',
description = 'Test Application',
url = 'http://localhost/Test/',
author = 'Monty Python <monty.python@localhost.localnet>',
company_name = 'Monty Corporation',
license = 'GPLv3',
script = 'test.py')


options = {'pygtk2exe': {'includes': ['pygtk']}}


if __name__ == '__main__':
setup(suite = suite,
options = options)
setup(name = 'simple-example',
version = '0.0.1',
description = 'simple pygtk2exe example',
author = 'Monty Python',
license = 'GPLv3',
classifiers = ['Development Status :: 1 - Planning',
'Environment :: X11 Applications :: GTK',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules'],
windows = [test],
options = options)
9 changes: 3 additions & 6 deletions lib/pygtk2exe/__init__.py
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-


from __future__ import absolute_import


__all__ = ['Suite', 'Extension', 'CtypesComServer', 'ComServer', 'Service', 'Windows', 'Console', 'IsapiFilter']
__version__ = '0.0.1'

Expand All @@ -27,11 +24,11 @@
from pygtk2exe.dist import Distribution
distutils.core.Distribution = Distribution

# Make everything usable in setup.py scripts available
from pygtk2exe.targets import CtypesComServer, ComServer, Service, Windows, Console, IsapiFilter

# Keep our "namespace" clean
del warnings
del py2exe_version
del distutils
del Distribution

# Make everything usable in setup.py scripts available
from pygtk2exe.targets import Suite, Extension, CtypesComServer, ComServer, Service, Windows, Console, IsapiFilter
33 changes: 32 additions & 1 deletion lib/pygtk2exe/command/build_exe.py
Expand Up @@ -5,8 +5,15 @@

from copy import copy

from distutils.extension import Extension

from py2exe.build_exe import py2exe as _py2exe
from py2exe.py2exe_util import depends
from pygtk2exe.targets import CtypesComServer, ComServer, Service, Windows, Console, IsapiFilter


class ConfigurationError(Exception):
pass


class py2exe(_py2exe):
Expand All @@ -25,11 +32,35 @@ def finalize_options(self):

self.set_undefined_options('bdist', ('plat_name', 'plat_name'))

def run(self):
def _initialize_distribution(self):
# prevent py2exe from clobbering the dist dir
exe_dist_dir = "%s.%s" % (self.distribution.get_fullname(), self.plat_name)
self.dist_dir = os.path.join(self.dist_dir, exe_dist_dir)

# Merge data_files for each Target into the data_files keyword
targets = self.distribution.ctypes_com_server + \
self.distribution.com_server + \
self.distribution.service + \
self.distribution.windows + \
self.distribution.console + \
self.distribution.isapi

for target in targets:
if hasattr(target, 'data_files'):
targetdirs = [x[0] for x in self.distribution.data_files]

for (targetdir, files) in target.data_files:
if not targetdir in targetdirs:
self.distribution.data_files.append((targetdir, files))
else:
for file in files:
index = targetdirs.index(targetdir)

if not file in self.distribution.data_files[index]:
self.distribution.data_files[index][1].append(file)

def run(self):
self._initialize_distribution()
_py2exe.run(self)

def copy_dlls(self, dlls):
Expand Down
78 changes: 20 additions & 58 deletions lib/pygtk2exe/dist.py
Expand Up @@ -6,7 +6,6 @@
from pygtk2exe.command.clean import clean
from pygtk2exe.command.build_ext import build_ext
from pygtk2exe.command.build_exe import py2exe
from pygtk2exe.targets import Extension, CtypesComServer, ComServer, Service, Windows, Console, IsapiFilter


class ConfigurationError(Exception):
Expand All @@ -33,72 +32,39 @@ def validate_keywords(self, attrs):
# pygtk2exe takes control of all py2exe specific keywords passed to
# the setup function, so we raise an error if the user mistakenly passes
# one of those keywords along with his setup() function call.
if not attrs.has_key('suite'):
raise ConfigurationError('pygtk2exe expects you to configure a suite')

if attrs.has_key('zipfile'):
raise ConfigurationError('The "zipfile" keyword should not be passed '
'directly to your setup() function. This will '
'be automatically configured by pygtk2exe.')

keywords = ['ctypes_com_server', 'com_server', 'service', 'windows', 'console', 'isapi']
def set_keywords(self, attrs):
if not attrs.has_key('data_files'):
attrs['data_files'] = []

for keyword in keywords:
if attrs.has_key(keyword):
raise ConfigurationError('The "%s" keyword should not be passed '
'directly to your setup() function. Please '
'use the pygtk2exe provided alternative.' % keyword)
# py2exe specific keywords
self.zipfile = 'bin/library.zip'

def set_keywords(self, attrs):
self.suite = attrs.pop('suite')
if not hasattr(self, 'ext_modules'):
self.ext_modules = []

# Merge data_files for each Target into the data_files keyword
if attrs.has_key('data_files'):
data_files = attrs.pop('data_files')
else:
data_files = []
if not hasattr(self, 'ctypes_com_server'):
self.ctypes_com_server = []

for target in self.suite.targets:
if hasattr(target, 'data_files'):
targetdirs = [x[0] for x in data_files]
if not hasattr(self, 'com_server'):
self.com_server = []

for (targetdir, files) in target.data_files:
if not targetdir in targetdirs:
data_files.append((targetdir, files))
else:
for file in files:
index = targetdirs.index(targetdir)
if not hasattr(self, 'service'):
self.service = []

if not file in data_files[index]:
data_files[index][1].append(file)
if not hasattr(self, 'windows'):
self.windows = []

attrs['data_files'] = data_files
if not hasattr(self, 'console'):
self.console = []

if not hasattr(self, 'isapi'):
self.isapi = []

# py2exe specific keywords
self.zipfile = 'bin/library.zip'
self.ext_modules = []
self.ctypes_com_server = []
self.com_server = []
self.service = []
self.windows = []
self.console = []
self.isapi = []

for target in self.suite.targets:
if isinstance(target, Extension):
self.ext_modules.append(target),
elif isinstance(target, CtypesComServer):
self.ctypes_com_server.append(target)
elif isinstance(target, ComServer):
self.com_server.append(target)
elif isinstance(target, Service):
self.service.append(target)
elif isinstance(target, Windows):
self.windows.append(target)
elif isinstance(target, Console):
self.console.append(target)
elif isinstance(target, IsapiFilter):
self.isapi.append(target)

def validate_options(self, attrs):
'''
Expand All @@ -108,10 +74,6 @@ def validate_options(self, attrs):
call.
'''
if attrs.has_key('options'):
if attrs['options'].has_key('py2exe'):
raise ConfigurationError('The "options" keyword should not contain '
'py2exe options. Use pygtk2exe options instead.')

if not attrs['options'].has_key('pygtk2exe'):
raise ConfigurationError('The "options" keyword should at least contain the '
'pygtk2exe "includes" option, specifying either '
Expand Down

0 comments on commit 418a0f6

Please sign in to comment.