1
1
#!/usr/bin/env python
3
from distutils import core
6
from distutils import core, cmd, dep_util, log
7
from distutils.command import sdist, build
10
# XXX this assumes the toplevel source dir is $PWD
12
class BuildProto(cmd.Command):
15
('force', 'f', 'forcibly build everything (ignore file timestamps)'),
18
boolean_options = ['force']
21
destdir = osp.join('tx11', 'proto')
23
def initialize_options(self):
26
def finalize_options(self):
27
self.set_undefined_options('build', ('force', 'force'))
30
names = [fn for fn in os.listdir(self.srcdir)
31
if osp.splitext(fn)[1] == '.xml']
32
sources = [osp.join(self.srcdir, fn) for fn in names]
33
targets = [osp.join(self.destdir, osp.splitext(fn)[0] + '.py')
36
log.info('skipping proto rebuild (no sources)')
39
stale_sources, stale_targets = dep_util.newer_pairwise(sources,
42
log.info('skipping proto rebuild (up-to-date)')
44
# Rebuild everything, not just changed files, because one xml
45
# file can refer to struct definitions in another
46
# (we would have to build a full dep graph).
47
# The pairwise comparisons above are technically bogus but
48
# should suffice in practice.
50
# Do these here so all this works with prebuilt proto files and no
51
# tpfkax/py_client from dist tarballs.
53
from tpfkax import state
55
cache = state.XMLCache()
56
for source in sources:
57
module = py_client.PyModule(source, self.destdir, cache)
63
class MySDist(sdist.sdist):
65
"""sdist extended to run build_proto first."""
67
sub_commands = [('build_proto', None)]
70
for cmd_name in self.get_sub_commands():
71
self.run_command(cmd_name)
76
class MyBuild(build.build):
78
"""build extended to run build_proto first."""
80
sub_commands = [('build_proto', None)] + build.build.sub_commands
6
83
core.setup(name='Twisted-X11',
9
86
author='Marien Zwart',
10
87
author_email='tx11@emzet.cjb.net',
11
88
packages=['tx11', 'tx11.proto', 'tx11.test'],
89
# Copied from distutils/dist.py, with build_proto added.
91
Common commands: (see '--help-commands' for more)
93
setup.py build_proto will (re)build the protocol files in place
94
setup.py build will build the package underneath 'build/'
95
setup.py install will install the package
97
cmdclass=dict(build_proto=BuildProto,