def _execute_post_build(self, post_spec, build_name): message('Running post-build commands:') with prefix(virtualenv.activate_prefix(ctx().build_path(build_name))): for desc in post_spec: f = sudo if desc.get('sudo', False) else run result = f(desc['command']) if result.failed and not desc.get('ignore_fail', False): raise HaltError('Post-build command failed: "{0}"'.format(desc['command'])) message('Completed post-build commands.')
def site_packages_dir(virtualenv_dir): _DIR_CMD = """ cat <<-EOF | python - import os, sys v=sys.version_info print(os.path.join(sys.prefix, 'lib', 'python{0}.{1}'.format(v.major, v.minor), 'site-packages')) EOF """.lstrip() with prefix(virtualenv.activate_prefix(virtualenv_dir)): result = run(_DIR_CMD, quiet=True) if result.failed: raise HaltError('Failed to retrieve Python "site-packages" location.') white_msg('Python site-packages dir: "{0}"'.format(result)) return result
def build_repo(build_env_dir, repo): full_repo_dir = ctx().repo_path(repo.dir) dist_dir = path.join(full_repo_dir, 'dist') # with the build virtualenv activated, and within the repo directory. with prefix(activate_prefix(build_env_dir)), cd(full_repo_dir): start_msg('Running "python setup.py install" for repo "{0}"'.format(repo.dir)) # first create a source distribution using setup.py in this repo. result = run('python setup.py sdist --formats=gztar') if result.failed: raise HaltError('"python setup.py sdist" failed in repo: "{0}"'.format(repo.dir)) # now use pip to install. couple of things to note: # a) pip does a "flat" (not versioned) install, no eggs, and consistent package directory names. # b) we're still allowing pip to grab packages from pypi; this should be fixed in a later version # where packages can (optionally) be picked up only from a local directory. result = run('pip install --find-links=file://{dist_dir} {repo.package_name}'.format(**locals())) if result.failed: raise HaltError('"pip install" failed in repo: "{0}"'.format(repo.dir)) succeed_msg('Build successful.')