def get_features_and_pools(container_name): """Install features and pools needed by given container""" from ape.installtools import cleanup, get_ape_venv, create_project_venv, fetch_pool, add_to_path CONTAINER_DIR = os.path.join(os.environ['APE_ROOT_DIR'], container_name) if os.path.exists(CONTAINER_DIR): os.environ['CONTAINER_DIR'] = CONTAINER_DIR else: print 'ERROR: this container does not exist!' return install_candidates = tasks.features_and_pools_to_get(container_name) cleanup() venv = create_project_venv() tmp_req_path = os.path.join(tasks.get_container_dir(container_name), 'tmp_requirements.txt') with codecs.open(tmp_req_path, 'w', encoding='utf-8') as tmp_requirements: for feature in install_candidates['features']: tmp_requirements.write(install_candidates['features'][feature]['giturl']+'\n') venv.pip_install_requirements('tmp_requirements.txt') pools = [] for pool in install_candidates['pools']: pools.append(fetch_pool(install_candidates['pools'][pool]['giturl'])) paths = venv.get_paths() for entry in pools: paths.append(entry.get_path('features')) paths.append(entry.get_path('features_exp')) add_to_path( paths )
from ape.installtools import cleanup, create_project_venv, fetch_pool, add_to_path # cleanup the installation directory (_lib/) cleanup() # create a project-level virtualenv venv = create_project_venv() # install some requirements venv.pip_install_requirements('requirements.txt') # fetch some required feature pools # fp = fetch_pool('<my git repository>') # add everything to your pypath add_to_path( venv.get_paths(), #fp.get_path(), # adds the features dir relative to your fp dir #fp.get_path('features') )
from ape.installtools import cleanup, get_ape_venv, create_project_venv, fetch_pool, add_to_path cleanup() venv = create_project_venv() venv.pip_install_requirements('requirements.txt') add_to_path(venv.get_paths(), )
from ape.installtools import cleanup, get_ape_venv, create_project_venv, fetch_pool, add_to_path cleanup() venv = create_project_venv() venv.pip_install_requirements('requirements.txt') add_to_path( venv.get_paths(), )