3 from __future__ import print_function
9 from distutils import core, log
14 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'pym'))
15 from gentoolkit.helpers import walk
17 __version__ = os.getenv('VERSION', default='9999')
21 # Bash files that need `VERSION=""` subbed, relative to this dir:
22 bash_scripts = [os.path.join(cwd, path) for path in (
27 # Python files that need `__version__ = ""` subbed, relative to this dir:
28 python_scripts = [os.path.join(cwd, path) for path in (
32 'pym/gentoolkit/eclean/cli.py',
33 'pym/gentoolkit/analyse/__init__.py',
34 'pym/gentoolkit/equery/__init__.py'
38 class set_version(core.Command):
39 """Set python __version__ and bash VERSION to our __version__."""
40 description = "hardcode scripts' version using VERSION from environment"
41 user_options = [] # [(long_name, short_name, desc),]
43 def initialize_options (self):
46 def finalize_options (self):
50 ver = 'svn' if __version__ == '9999' else __version__
51 print("Settings version to %s" % ver)
52 def sub(files, pattern):
57 newline = re.sub(pattern, '"%s"' % ver, line, 1)
59 log.info("%s: %s" % (f, newline))
60 updated_file.append(newline)
61 with open(f, 'w') as s:
62 s.writelines(updated_file)
64 bash_re = r'(?<=VERSION=)' + quote + '[^\'"]*' + quote
65 sub(bash_scripts, bash_re)
66 python_re = r'(?<=^__version__ = )' + quote + '[^\'"]*' + quote
67 sub(python_scripts, python_re)
71 """Only return the real test class if it's actually being run so that we
72 don't depend on snakeoil just to install."""
74 desc = "run the test suite"
75 if 'test' in sys.argv[1:]:
77 from snakeoil import distutils_extensions
79 sys.stderr.write("Error: We depend on dev-python/snakeoil ")
80 sys.stderr.write("to run tests.\n")
82 class test(distutils_extensions.test):
84 default_test_namespace = 'gentoolkit.test'
86 class test(core.Command):
93 str('.'.join(root.split(os.sep)[1:]))
94 for root, dirs, files in walk('pym/gentoolkit')
95 if '__init__.py' in files
101 description='Set of tools that work with and enhance portage.',
104 maintainer='Gentoo Portage Tools Team',
105 maintainer_email='tools-portage@gentoo.org',
106 url='http://www.gentoo.org/proj/en/portage/tools/index.xml',
107 download_url='http://distfiles.gentoo.org/distfiles/gentoolkit-%s.tar.gz'\
109 package_dir={'': 'pym'},
111 scripts=(glob('bin/*')),
113 ('/etc/env.d', ['data/99gentoolkit-env']),
114 ('/etc/revdep-rebuild', ['data/revdep-rebuild/99revdep-rebuild']),
115 ('/etc/eclean', glob('data/eclean/*')),
116 ('/usr/share/man/man1', glob('man/*'))
120 'set_version': set_version,
124 # vim: set ts=4 sw=4 tw=79: