def run_command(self, args): proj_name = basename(args.project) proj_dir = abspath(args.project) print "Making new project '%s' [%s]..." % (proj_dir, args.python) # check that project dir and venv don't exist if not args.brew: if exists(proj_dir): print "Make Error: '{}' already exists.".format(proj_dir) return False # make pythonbrew venv venv_dir = pv_mkvenv(proj_name, args.python, args.site) if not venv_dir: print "Make Error: unable to create venv {}.".format(proj_name) return False if args.brew: return True # make project dir if not pv_mkdirs(proj_dir): print "Make Error: unable to create {}.".format(proj_dir) return False # else everything set so link venv in project dir if not pv_link_projs(venv_dir, proj_dir): print "Init Error: venv not linked to '{}'.".format(proj_name) return False # add project link to .pybrat_projects/ return pv_add_proj(proj_dir)
def run_command(self, args): # validate the project dir to target for ln in .pybrat/projects proj_dir = abspath(args.project) vname = args.virtualenv if not args.venv else basename(args.virtualenv) print "Initializing project '{}'...".format(proj_dir) if not exists(proj_dir): print "Init Error: project directory '{}' not found.".format(proj_dir) return False # do we need to import given venv to pythonbrew first? if args.wrap or args.venv: if args.wrap: venv_d = (get_project_list({'wrap':True,}))['wrap']['venv'] elif args.venv: venv_d = (get_project_list({'venv':args.virtualenv,}))['venv']['venv'] args.virtualenv = basename(args.virtualenv) if vname in venv_d.keys(): venv = venv_d[vname] # make pythonbrew venv print "Importing ({}) [{}] to pythonbrew...".format(vname, venv['python']) venv_dir = pv_mkvenv(vname, venv['python']) if not venv_dir: print "Make Error: unable to create venv {}.".format(proj_name) return False # safe to get pythonbrew venv dict now... venv_d = (get_project_list({'brew':True,}))['brew']['venv'] if args.virtualenv not in venv_d.keys(): print "Init Error: venv '{}' not found.".format(args.virtualenv) return False venv_dir = venv_d[args.virtualenv] # send to linking function if not pv_link_projs(venv_dir, proj_dir): print "Init Error: pythonbrew venv not linked to '{}'.".format(proj_dir) return False # add project link to .pybrat_projects/ return pv_add_proj(proj_dir)