diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-09-14 17:06:18 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-09-14 17:06:18 +0100 |
commit | 5a6c9c5cf095f2793451307f37189c875995265a (patch) | |
tree | f4a546db7fd2b9e184c81a0e1e19355d744f0872 /ybd.py | |
parent | e506bcbc8fb3471c04f65a1f7147831384117fb1 (diff) | |
download | ybd-5a6c9c5cf095f2793451307f37189c875995265a.tar.gz |
Turn YBD and KBAS into proper Python packages
This means you can now 'import ybd' from anywhere in your system and use
its functionality in other programs.
Using special __main__.py modules, you can also now do 'python -m ybd' to
execute YBD, and same for KBAS. The top-level kbas.py and ybd.py scripts
are now just wrappers, that effectively do the same as 'python -m ybd'
and 'python -m kbas'. See https://www.python.org/dev/peps/pep-0338/ for
way more information about that approach than you ever wanted.
Diffstat (limited to 'ybd.py')
-rwxr-xr-x | ybd.py | 46 |
1 files changed, 3 insertions, 43 deletions
@@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2014-2015 Codethink Limited +# Copyright (C) 2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -12,47 +12,7 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. -# -# =*= License: GPL-2 =*= - -'''A module to build a definition.''' - -import os -import sys -import fcntl -import app -from assembly import assemble -from deployment import deploy -from definitions import Definitions -import cache -import sandbox -import sandboxlib - - -print('') -app.setup(sys.argv) -app.cleanup(app.config['tmp']) - -with app.timer('TOTAL'): - lockfile = open(os.path.join(app.config['tmp'], 'lock'), 'r') - fcntl.flock(lockfile, fcntl.LOCK_SH | fcntl.LOCK_NB) - - target = os.path.join(app.config['defdir'], app.config['target']) - app.log('TARGET', 'Target is %s' % target, app.config['arch']) - with app.timer('DEFINITIONS', 'parsing %s' % app.config['def-version']): - defs = Definitions() - with app.timer('CACHE-KEYS', 'cache-key calculations'): - cache.cache_key(defs, app.config['target']) - defs.save_trees() - - sandbox.executor = sandboxlib.executor_for_platform() - app.log(app.config['target'], 'Sandbox using %s' % sandbox.executor) - if sandboxlib.chroot == sandbox.executor: - app.log(app.config['target'], 'WARNING: rogue builds in a chroot ' + - 'sandbox may overwrite your system') - if app.config.get('instances'): - app.spawn() +import runpy - assemble(defs, app.config['target']) - deploy(defs, app.config['target']) +runpy.run_module('ybd') |