~ubuntu-branches/ubuntu/lucid/pytagsfs/lucid

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Bazaar Package Importer
  • Author(s): Y Giridhar Appaji Nag
  • Date: 2009-01-28 22:11:56 UTC
  • mfrom: (1.1.3 upstream) (3.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090128221156-tbhq0bau1tke233i
Tags: 0.9.0~rc1-1
* New upstream release
  + Needs python-fuse to build add to Build-Depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
 
3
 
# Author: Forest Bond <forest.bond@alittletooquiet.net>
 
3
# Author: Forest Bond <forest@alittletooquiet.net>
4
4
# This file is in the public domain.
5
5
 
6
6
import os, sys, commands, glob, inspect
19
19
sys.path.insert(0, modules_dir)
20
20
sys.path.insert(0, project_dir)
21
21
 
22
 
from tests.common import TEST_DIR, TEST_DATA_DIR
 
22
from pytagsfs.fs import UMOUNT_COMMAND
 
23
from tests.common import TEST_DATA_DIR
23
24
 
24
25
 
25
26
################################################################################
105
106
                log.warn("failed to remove '%s'" % dirname)
106
107
 
107
108
    def clean_test_data(self):
108
 
        status, output = commands.getstatusoutput(
109
 
          'test -x $(which fusermount) && which fusermount')
110
 
        if status == 0:
111
 
            umount_cmd = '%s -u' % output.strip()
112
 
        else:
113
 
            status, output = commands.getstatusoutput(
114
 
              'test -x $(which umount) && which umount')
115
 
            if status == 0:
116
 
                umount_cmd = output.strip()
117
 
            else:
118
 
                raise AssertionError("can't find a umount command")
119
 
 
120
 
        test_tree_root = os.path.join(TEST_DIR, 'test-trees')
121
109
        try:
122
 
            dirs = os.listdir(test_tree_root)
 
110
            dirs = os.listdir(TEST_DATA_DIR)
123
111
        except (IOError, OSError):
124
112
            log.warn(
125
 
              "not cleaning '%s': failed to read directory" % test_tree_root)
 
113
              "not cleaning '%s': failed to read directory" % TEST_DATA_DIR)
126
114
        else:
127
115
            for dir in dirs:
128
 
                full_dir = os.path.join(test_tree_root, dir)
 
116
                full_dir = os.path.join(TEST_DATA_DIR, dir)
129
117
                mnt_dir = os.path.join(full_dir, 'mnt')
130
118
 
131
119
                log.info("unmounting '%s'" % mnt_dir)
132
120
                status, output = commands.getstatusoutput(
133
 
                  '%s %s' % (umount_cmd, mnt_dir))
 
121
                  UMOUNT_COMMAND % mnt_dir)
134
122
                if status != 0:
135
123
                    print >>sys.stderr, output
136
124
 
137
125
                self.clean_dir(full_dir)
138
126
 
139
 
            os.rmdir(test_tree_root)
140
 
 
141
127
        self.clean_dir(TEST_DATA_DIR)
142
128
 
143
129
    def run(self):
176
162
    description = 'Build manual pages from docbook XML.'
177
163
    user_options = []
178
164
    man_build_dir = 'build/man'
 
165
    stylesheet = find_docbook_manpage_stylesheet()
179
166
 
180
167
    def initialize_options(self):
181
168
        pass
182
169
 
183
170
    def finalize_options(self):
184
 
        self.stylesheet = find_docbook_manpage_stylesheet()
185
171
        if self.distribution.manpage_sources is not None:
186
172
            self.docbook_files = [
187
173
              os.path.abspath(p) for p in self.distribution.manpage_sources
189
175
            ]
190
176
 
191
177
    def build_manpage_from_docbook(self, docbook_file):
 
178
        assert self.stylesheet is not None, 'failed to find stylesheet'
 
179
 
192
180
        command = self.xsltproc + [self.stylesheet, docbook_file]
193
181
        orig_wd = os.getcwd()
194
182
        os.chdir(self.man_build_dir)
198
186
            os.chdir(orig_wd)
199
187
 
200
188
    def run(self):
 
189
        if self.stylesheet is None:
 
190
            log.warn(
 
191
              'Warning: missing docbook XSL stylesheets; '
 
192
              'manpages will not be built.\n'
 
193
              'Please install the docbook XSL stylesheets from '
 
194
              'http://docbook.org/.'
 
195
            )
 
196
 
201
197
        manpage_sources = self.docbook_files
202
198
        if manpage_sources:
203
199
            if not os.path.exists(self.man_build_dir):
280
276
 
281
277
################################################################################
282
278
 
283
 
manpage_sources = ['pytagsfs.xml', 'pytags.xml']
284
 
manpages = [
285
 
  os.path.join(
286
 
    'build',
287
 
    'man',
288
 
    s.replace('xml', '1'),
289
 
  )
290
 
  for s in manpage_sources
291
 
]
 
279
data_files = []
 
280
manpage_sources = []
 
281
 
 
282
if build_manpages.stylesheet is not None:
 
283
    manpage_sources = ['pytagsfs.xml', 'pytags.xml']
 
284
    manpages = [
 
285
      os.path.join(
 
286
        'build',
 
287
        'man',
 
288
        s.replace('xml', '1'),
 
289
      )
 
290
      for s in manpage_sources
 
291
    ]
 
292
    data_files.append(('share/man/man1', manpages))
292
293
 
293
294
setup(
294
295
  cmdclass = {
305
306
  },
306
307
  packages = [
307
308
    'pytagsfs',
 
309
    'pytagsfs.fs',
308
310
    'pytagsfs.metastore',
309
311
    'pytagsfs.pathstore',
310
312
    'pytagsfs.sourcetreemon',
313
315
  ],
314
316
  scripts = [
315
317
    'pytagsfs',
316
 
    'pytags'
 
318
    'pytags',
317
319
  ],
318
320
  manpage_sources = manpage_sources,
319
321
  release_file = 'release',
320
 
  data_files = [('share/man/man1', manpages)],
 
322
  data_files = data_files,
321
323
)