3 from __future__ import with_statement
9 from distutils import core, log
12 __version__ = os.getenv('VERSION', default='9999')
16 # Bash files that need `VERSION=""` subbed, relative to this dir:
17 bash_scripts = [os.path.join(cwd, path) for path in (
22 # Python files that need `__version__ = ""` subbed, relative to this dir:
23 python_scripts = [os.path.join(cwd, path) for path in (
27 'pym/gentoolkit/equery/__init__.py'
31 class set_version(core.Command):
32 """Set python __version__ and bash VERSION to our __version__."""
33 description = "hardcode scripts' version using VERSION from environment"
34 user_options = [] # [(long_name, short_name, desc),]
36 def initialize_options (self):
39 def finalize_options (self):
43 ver = 'svn' if __version__ == '9999' else __version__
44 def sub(files, pattern):
49 newline = re.sub(pattern, '"%s"' % ver, line, 1)
51 log.info("%s: %s" % (f, newline))
52 updated_file.append(newline)
53 with open(f, 'w') as s:
54 s.writelines(updated_file)
56 bash_re = r'(?<=VERSION=)' + quote + '[^\'"]*' + quote
57 sub(bash_scripts, bash_re)
58 python_re = r'(?<=^__version__ = )' + quote + '[^\'"]*' + quote
59 sub(python_scripts, python_re)
63 """Only return the real test class if it's actually being run so that we
64 don't depend on snakeoil just to install."""
66 desc = "run the test suite"
67 if 'test' in sys.argv[1:]:
69 from snakeoil import distutils_extensions
71 sys.stderr.write("Error: We depend on dev-python/snakeoil ")
72 sys.stderr.write("to run tests.\n")
74 class test(distutils_extensions.test):
76 default_test_namespace = 'gentoolkit.test'
78 class test(core.Command):
85 '.'.join(root.split(os.sep)[1:])
86 for root, dirs, files in os.walk('pym/gentoolkit')
87 if '__init__.py' in files
93 description='Set of tools that work with and enhance portage.',
96 maintainer='Gentoo Portage Tools Team',
97 maintainer_email='tools-portage@gentoo.org',
98 url='http://www.gentoo.org/proj/en/portage/tools/index.xml',
99 download_url='http://distfiles.gentoo.org/distfiles/gentoolkit-%s.tar.gz'\
101 package_dir={'': 'pym'},
103 scripts=(glob('bin/*')),
105 ('/etc/env.d', ['data/99gentoolkit-env']),
106 ('/etc/revdep-rebuild', ['data/revdep-rebuild/99revdep-rebuild']),
107 ('/etc/eclean', glob('data/eclean/*')),
108 ('/usr/share/man/man1', glob('man/*'))
112 'set_version': set_version,
116 # vim: set ts=4 sw=4 tw=79: