7 from distutils import core, log
10 __version__ = os.getenv('VERSION', default='9999')
14 # Bash files that need `VERSION=""` subbed, relative to this dir:
15 bash_scripts = [os.path.join(cwd, path) for path in (
20 # Python files that need `__version__ = ""` subbed, relative to this dir:
21 python_scripts = [os.path.join(cwd, path) for path in (
25 'pym/gentoolkit/equery/__init__.py'
29 class set_version(core.Command):
30 """Set python __version__ and bash VERSION to our __version__."""
31 description = "hardcode scripts' version using VERSION from environment"
32 user_options = [] # [(long_name, short_name, desc),]
34 def initialize_options (self):
37 def finalize_options (self):
41 ver = 'svn' if __version__ == '9999' else __version__
42 def sub(files, pattern):
47 newline = re.sub(pattern, '"%s"' % ver, line, 1)
49 log.info("%s: %s" % (f, newline))
50 updated_file.append(newline)
51 with open(f, 'w') as s:
52 s.writelines(updated_file)
54 bash_re = r'(?<=VERSION=)' + quote + '[^\'"]*' + quote
55 sub(bash_scripts, bash_re)
56 python_re = r'(?<=^__version__ = )' + quote + '[^\'"]*' + quote
57 sub(python_scripts, python_re)
61 """Only return the real test class if it's actually being run so that we
62 don't depend on snakeoil just to install."""
64 desc = "run the test suite"
65 if 'test' in sys.argv[1:]:
67 from snakeoil import distutils_extensions
69 sys.stderr.write("Error: We depend on dev-python/snakeoil ")
70 sys.stderr.write("to run tests.\n")
72 class test(distutils_extensions.test):
74 default_test_namespace = 'gentoolkit.test'
76 class test(core.Command):
83 '.'.join(root.split(os.sep)[1:])
84 for root, dirs, files in os.walk('pym/gentoolkit')
85 if '__init__.py' in files
91 description='Set of tools that work with and enhance portage.',
94 maintainer='Gentoo Portage Tools Team',
95 maintainer_email='tools-portage@gentoo.org',
96 url='http://www.gentoo.org/proj/en/portage/tools/index.xml',
97 download_url='http://distfiles.gentoo.org/distfiles/gentoolkit-%s.tar.gz'\
99 package_dir={'': 'pym'},
101 scripts=(glob('bin/*')),
103 ('/etc/env.d', ['data/99gentoolkit-env']),
104 ('/etc/revdep-rebuild', ['data/revdep-rebuild/99revdep-rebuild']),
105 ('/etc/eclean', glob('data/eclean/*')),
106 ('/usr/share/man/man1', glob('man/*'))
110 'set_version': set_version,
114 # vim: set ts=4 sw=4 tw=79: