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'))
16 __version__ = os.getenv('VERSION', default='9999')
20 # Load EPREFIX from Portage, fall back to the empty string if it fails
22 from portage.const import EPREFIX
27 # Bash files that need `VERSION=""` subbed, relative to this dir:
28 bash_scripts = [os.path.join(cwd, path) for path in (
33 # Python files that need `__version__ = ""` subbed, relative to this dir:
34 python_scripts = [os.path.join(cwd, path) for path in (
38 'pym/gentoolkit/eclean/cli.py',
39 'pym/gentoolkit/analyse/__init__.py',
40 'pym/gentoolkit/equery/__init__.py',
41 'pym/gentoolkit/eshowkw/__init__.py'
45 class set_version(core.Command):
46 """Set python __version__ and bash VERSION to our __version__."""
47 description = "hardcode scripts' version using VERSION from environment"
48 user_options = [] # [(long_name, short_name, desc),]
50 def initialize_options (self):
53 def finalize_options (self):
57 ver = 'svn' if __version__ == '9999' else __version__
58 print("Settings version to %s" % ver)
59 def sub(files, pattern):
64 newline = re.sub(pattern, '"%s"' % ver, line, 1)
66 log.info("%s: %s" % (f, newline))
67 updated_file.append(newline)
68 with open(f, 'w') as s:
69 s.writelines(updated_file)
71 bash_re = r'(?<=VERSION=)' + quote + '[^\'"]*' + quote
72 sub(bash_scripts, bash_re)
73 python_re = r'(?<=^__version__ = )' + quote + '[^\'"]*' + quote
74 sub(python_scripts, python_re)
78 """Only return the real test class if it's actually being run so that we
79 don't depend on snakeoil just to install."""
81 desc = "run the test suite"
82 if 'test' in sys.argv[1:]:
84 from snakeoil import distutils_extensions
86 sys.stderr.write("Error: We depend on dev-python/snakeoil ")
87 sys.stderr.write("to run tests.\n")
89 class test(distutils_extensions.test):
91 default_test_namespace = 'gentoolkit.test'
93 class test(core.Command):
99 str('.'.join(root.split(os.sep)[1:]))
100 for root, dirs, files in os.walk('pym/gentoolkit')
101 if '__init__.py' in files
106 'test/eclean/Packages',
107 'test/eclean/testdistfiles.tar.gz',
108 'test/eclean/distfiles.exclude'
115 description='Set of tools that work with and enhance portage.',
118 maintainer='Gentoo Portage Tools Team',
119 maintainer_email='tools-portage@gentoo.org',
120 url='http://www.gentoo.org/proj/en/portage/tools/index.xml',
121 download_url='http://distfiles.gentoo.org/distfiles/gentoolkit-%s.tar.gz'\
123 package_dir={'': 'pym'},
125 package_data = test_data,
126 scripts=(glob('bin/*')),
128 (os.path.join(EPREFIX, 'etc/env.d'), ['data/99gentoolkit-env']),
129 (os.path.join(EPREFIX, 'etc/revdep-rebuild'), ['data/revdep-rebuild/99revdep-rebuild']),
130 (os.path.join(EPREFIX, 'etc/eclean'), glob('data/eclean/*')),
131 (os.path.join(EPREFIX, 'usr/share/man/man1'), glob('man/*')),
135 'set_version': set_version,
139 # vim: set ts=4 sw=4 tw=79: