Create a project-level virtualenv.

    :raises: if virtualenv exists already
    :return: ``VirtualEnv`` object
195792
def create_project_venv():
    
    print('... creating project-level virtualenv')
    venv_dir = get_project_venv_dir()

    if os.path.exists(venv_dir):
        raise Exception('ERROR: virtualenv already exists!')

    use_venv_module = sys.version_info >= (3, 0) and 'APE_USE_VIRTUALENV' not in os.environ

    VirtualEnv.create_virtualenv(venv_dir, use_venv_module=use_venv_module)

    print('... virtualenv successfully created')
    return VirtualEnv(venv_dir)
1146204
def mkvirtualenv():
    
    root = '/'.join([deployment_root(),'env'])
    path = '/'.join([root,env.project_fullname])
    dirs_created = []
    if env.verbosity:
        print env.host,'CREATING VIRTUALENV', path
    if not exists(root): dirs_created += mkdirs(root)
    with cd(root):
        run(' '.join(["virtualenv",env.project_fullname]))
    with cd(path):
        dirs_created += mkdirs('egg_cache')
        sudo('chown -R %s:www-data egg_cache'% env.user)
        sudo('chmod -R g+w egg_cache')
        run(''.join(["echo 'cd ",path,'/','project','/',env.project_package_name,'/sitesettings',"' > bin/postactivate"]))
        sudo('chmod ugo+rwx bin/postactivate')

    #Create a state
    out = State(' '.join([env.host,'virtualenv',path,'created']))
    out.object = dirs_created + ['bin','lib','include']
    out.failed = False
    return out
290021
def create_project(self, name, description=None):
        
        description = description or ''
        data = self._run(
            url_path="projects/add",
            name=name,
            description=description
        )
        return data['result']['project']['id']
1140529
def create(cls, path_name=None, name=None, project_id=None,
               log_modified_at=None, crawlable=True):
        """"""
        result = cls(path_name, name, project_id, log_modified_at, crawlable)

        db.session.add(result)
        db.session.commit()

        crawl_result(result, True)

        return result
128746
def create_project(project_name, template="default"):
    

    project_dir = get_project_dir_path(project_name)

    run_tpl = pkg_resources.resource_string(__name__, '%s/run.py' % (SKELETON_DIR))
    init_py_tpl = pkg_resources.resource_string(__name__, '%s/init.py' % (SKELETON_DIR))
    deployapp_tpl = pkg_resources.resource_string(__name__, '%s/deployapp.yml' % (SKELETON_DIR))
    config_tpl = pkg_resources.resource_string(__name__, '%s/config.py' % (SKELETON_DIR))
    model_tpl = pkg_resources.resource_string(__name__, '%s/model.py' % (SKELETON_DIR))
    manage_tpl = pkg_resources.resource_string(__name__, '%s/manage.py' % (SKELETON_DIR))

    run_file = "%s/run_%s.py" % (CWD, project_name)
    requirements_txt = "%s/requirements.txt" % CWD
    deployapp_yml = "%s/deployapp.yml" % CWD
    config_py = "%s/config.py" % APPLICATION_DIR
    model_py = "%s/model.py" % APPLICATION_DIR
    manage_py = "%s/manage.py" % CWD

    if not os.path.isdir(APPLICATION_DIR):
        os.makedirs(APPLICATION_DIR)

    if not os.path.isdir(project_dir):
        os.makedirs(project_dir)

    _app_init_py = "%s/__init__.py" % APPLICATION_DIR
    if not os.path.isfile(_app_init_py):
        with open(_app_init_py, "wb") as f:
            f.write(init_py_tpl)

    _init_py = "%s/__init__.py" % CWD
    if not os.path.isfile(_init_py):
        with open(_init_py, "wb") as f:
            f.write("# Pylot")

    if not os.path.isfile(config_py):
        with open(config_py, "wb") as f:
            f.write(config_tpl)

    if not os.path.isfile(model_py):
        with open(model_py, "wb") as f:
            f.write(model_tpl)

    if not os.path.isfile(run_file):
        with open(run_file, "wb") as f:
            f.write(run_tpl.format(project_name=project_name))

    if not os.path.isfile(requirements_txt):
        with open(requirements_txt, "wb") as f:
            f.write("%s==%s" % (PACKAGE.NAME, PACKAGE.__version__))

    if not os.path.isfile(deployapp_yml):
        with open(deployapp_yml, "wb") as f:
            f.write(deployapp_tpl)

    if not os.path.isfile(manage_py):
        with open(manage_py, "wb") as f:
            f.write(manage_tpl)

    copy_resource("%s/%s/" % (SKELETON_DIR, template), project_dir)
915055
def create(vm_):
    '''
    

    '''
    name = vm_['name']
    machine = config.get_cloud_config_value(
        'machine', vm_, __opts__, default='')
    vm_['machine'] = machine
    host = config.get_cloud_config_value(
        'host', vm_, __opts__, default=NotImplemented)
    vm_['cwd'] = config.get_cloud_config_value(
        'cwd', vm_, __opts__, default='/')
    vm_['runas'] = config.get_cloud_config_value(
        'vagrant_runas', vm_, __opts__, default=os.getenv('SUDO_USER'))
    vm_['timeout'] = config.get_cloud_config_value(
        'vagrant_up_timeout', vm_, __opts__, default=300)
    vm_['vagrant_provider'] = config.get_cloud_config_value(
        'vagrant_provider', vm_, __opts__, default='')
    vm_['grains'] = {'salt-cloud:vagrant': {'host': host, 'machine': machine}}

    log.info('sending \'vagrant.init %s machine=%s\' command to %s', name, machine, host)

    local = salt.client.LocalClient()
    ret = local.cmd(host, 'vagrant.init', [name], kwarg={'vm': vm_, 'start': True})
    log.info('response ==> %s', ret[host])

    network_mask = config.get_cloud_config_value(
        'network_mask', vm_, __opts__, default='')
    if 'ssh_host' not in vm_:
        ret = local.cmd(host,
                        'vagrant.get_ssh_config',
                        [name],
                        kwarg={'network_mask': network_mask,
                                'get_private_key': True})[host]
    with tempfile.NamedTemporaryFile() as pks:
        if 'private_key' not in vm_ and ret and ret.get('private_key', False):
            pks.write(ret['private_key'])
            pks.flush()
            log.debug('wrote private key to %s', pks.name)
            vm_['key_filename'] = pks.name
        if 'ssh_host' not in vm_:
            try:
                vm_.setdefault('ssh_username', ret['ssh_username'])
                if ret.get('ip_address'):
                    vm_['ssh_host'] = ret['ip_address']
                else:  # if probe failed or not used, use Vagrant's reported ssh info
                    vm_['ssh_host'] = ret['ssh_host']
                    vm_.setdefault('ssh_port', ret['ssh_port'])
            except (KeyError, TypeError):
                raise SaltInvocationError(
                    'Insufficient SSH addressing information for {}'.format(name))

        log.info('Provisioning machine %s as node %s using ssh %s',
                 machine, name, vm_['ssh_host'])
        ret = __utils__['cloud.bootstrap'](vm_, __opts__)
        return ret
1046606
def create_version(self, project_id_or_key, version_name, extra_request_params={}):
        
        request_params = extra_request_params
        request_params["name"] = version_name
        return self.do("POST", "projects/{project_id_or_key}/versions",
                       url_params={"project_id_or_key": project_id_or_key},
                       request_params=request_params,
                       )
424867
def create(self, project, name, **attrs):
        
        attrs.update(
            {
                'project': project, 'name': name
            }
        )
        return self._new_resource(payload=attrs)
385420
def make_venv(self, dj_version):
        
        venv_path = self._get_venv_path(dj_version)
        self.logger.info('Creating virtual environment for Django %s ...' % dj_version)
        try:
            create_venv(venv_path, **VENV_CREATE_KWARGS)
        except ValueError:
            self.logger.warning('Virtual environment directory already exists. Skipped.')
        self.venv_install('django==%s' % dj_version, venv_path)
        return venv_path
166865
def create_project(args):
    

    # Make sure given name is not already in use by another python package/module.
    try:
        __import__(args.project_name)
    except ImportError:
        pass
    else:
        sys.exit("'{}' conflicts with the name of an existing "
                 "Python module and cannot be used as a project "
                 "name. Please try another name.".format(args.project_name))

    # Get the longclaw template path
    template_path = path.join(path.dirname(longclaw.__file__), 'project_template')

    utility = ManagementUtility((
        'django-admin.py',
        'startproject',
        '--template={}'.format(template_path),
        '--extension=html,css,js,py,txt',
        args.project_name
    ))
    utility.execute()
    print("{} has been created.".format(args.project_name))
1361794
def do_init(
    dev=False,
    requirements=False,
    allow_global=False,
    ignore_pipfile=False,
    skip_lock=False,
    system=False,
    concurrent=True,
    deploy=False,
    pre=False,
    keep_outdated=False,
    requirements_dir=None,
    pypi_mirror=None,
):
    """"""
    from .environments import (
        PIPENV_VIRTUALENV, PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_PYTHON, PIPENV_USE_SYSTEM
    )
    python = None
    if PIPENV_PYTHON is not None:
        python = PIPENV_PYTHON
    elif PIPENV_DEFAULT_PYTHON_VERSION is not None:
        python = PIPENV_DEFAULT_PYTHON_VERSION

    if not system and not PIPENV_USE_SYSTEM:
        if not project.virtualenv_exists:
            try:
                do_create_virtualenv(python=python, three=None, pypi_mirror=pypi_mirror)
            except KeyboardInterrupt:
                cleanup_virtualenv(bare=False)
                sys.exit(1)
    # Ensure the Pipfile exists.
    if not deploy:
        ensure_pipfile(system=system)
    if not requirements_dir:
        requirements_dir = vistir.path.create_tracked_tempdir(
            suffix="-requirements", prefix="pipenv-"
        )
    # Write out the lockfile if it doesn't exist, but not if the Pipfile is being ignored
    if (project.lockfile_exists and not ignore_pipfile) and not skip_lock:
        old_hash = project.get_lockfile_hash()
        new_hash = project.calculate_pipfile_hash()
        if new_hash != old_hash:
            if deploy:
                click.echo(
                    crayons.red(
                        "Your Pipfile.lock ({0}) is out of date. Expected: ({1}).".format(
                            old_hash[-6:], new_hash[-6:]
                        )
                    )
                )
                raise exceptions.DeployException
                sys.exit(1)
            elif (system or allow_global) and not (PIPENV_VIRTUALENV):
                click.echo(
                    crayons.red(fix_utf8(
                        "Pipfile.lock ({0}) out of date, but installation "
                        "uses {1}… re-building lockfile must happen in "
                        "isolation. Please rebuild lockfile in a virtualenv. "
                        "Continuing anyway…".format(
                            crayons.white(old_hash[-6:]), crayons.white("--system")
                        )),
                        bold=True,
                    ),
                    err=True,
                )
            else:
                if old_hash:
                    msg = fix_utf8("Pipfile.lock ({0}) out of date, updating to ({1})…")
                else:
                    msg = fix_utf8("Pipfile.lock is corrupted, replaced with ({1})…")
                click.echo(
                    crayons.red(msg.format(old_hash[-6:], new_hash[-6:]), bold=True),
                    err=True,
                )
                do_lock(
                    system=system,
                    pre=pre,
                    keep_outdated=keep_outdated,
                    write=True,
                    pypi_mirror=pypi_mirror,
                )
    # Write out the lockfile if it doesn't exist.
    if not project.lockfile_exists and not skip_lock:
        # Unless we're in a virtualenv not managed by pipenv, abort if we're
        # using the system's python.
        if (system or allow_global) and not (PIPENV_VIRTUALENV):
            raise exceptions.PipenvOptionsError(
                "--system",
                "--system is intended to be used for Pipfile installation, "
                "not installation of specific packages. Aborting.\n"
                "See also: --deploy flag."
            )
        else:
            click.echo(
                crayons.normal(fix_utf8("Pipfile.lock not found, creating…"), bold=True),
                err=True,
            )
            do_lock(
                system=system,
                pre=pre,
                keep_outdated=keep_outdated,
                write=True,
                pypi_mirror=pypi_mirror,
            )
    do_install_dependencies(
        dev=dev,
        requirements=requirements,
        allow_global=allow_global,
        skip_lock=skip_lock,
        concurrent=concurrent,
        requirements_dir=requirements_dir,
        pypi_mirror=pypi_mirror,
    )

    # Hint the user what to do to activate the virtualenv.
    if not allow_global and not deploy and "PIPENV_ACTIVE" not in os.environ:
        click.echo(
            "To activate this project's virtualenv, run {0}.\n"
            "Alternatively, run a command "
            "inside the virtualenv with {1}.".format(
                crayons.red("pipenv shell"), crayons.red("pipenv run")
            )
        )
1124138
private function createEnv(): void
    {
        if (file_exists(base_dir('.env'))) {
            $dotEnv = new Dotenv();
            $dotEnv->load(base_dir('.env'));
            $this->env = $dotEnv;
        }
    }
683952
def setproject_cmd(argv):
    """"""
    args = dict(enumerate(argv))
    project = os.path.abspath(args.get(1, '.'))
    env = args.get(0, os.environ.get('VIRTUAL_ENV'))
    if not env:
        sys.exit('pew setproject [virtualenv] [project_path]')
    if not (workon_home / env).exists():
        sys.exit("Environment '%s' doesn't exist." % env)
    if not os.path.isdir(project):
        sys.exit('pew setproject: %s does not exist' % project)
    setvirtualenvproject(env, project)
118259
def create_new_project(self):
        """"""
        self.switch_to_plugin()
        active_project = self.current_active_project
        dlg = ProjectDialog(self)
        dlg.sig_project_creation_requested.connect(self._create_project)
        dlg.sig_project_creation_requested.connect(self.sig_project_created)
        if dlg.exec_():
            if (active_project is None
                    and self.get_option('visible_if_project_open')):
                self.show_explorer()
            self.sig_pythonpath_changed.emit()
            self.restart_consoles()
525236
def setup():
    ""
    parent, project = os.path.split(env.path)

    if not exists(parent):
        run('mkdir -p {0}'.format(parent))
        run('virtualenv {0}'.format(parent))

    with cd(parent):
        if not exists(project):
            run('git clone {repo_url} {project}'.format(project=project, **env))
131662
def _build_new_virtualenv(self):
        ''''''
        if self._virtualenv is None:
            # virtualenv was "None" which means "do default"
            self._pkg_venv = os.path.join(self._temp_workspace, 'venv')
            self._venv_pip = 'bin/pip'
            if sys.platform == 'win32' or sys.platform == 'cygwin':
                self._venv_pip = 'Scripts\pip.exe'

            python_exe = self._python_executable()

            proc = Popen(["virtualenv", "-p", python_exe,
                          self._pkg_venv], stdout=PIPE, stderr=PIPE)
            stdout, stderr = proc.communicate()
            LOG.debug("Virtualenv stdout: %s" % stdout)
            LOG.debug("Virtualenv stderr: %s" % stderr)

            if proc.returncode is not 0:
                raise Exception('virtualenv returned unsuccessfully')

        else:
            raise Exception('cannot build a new virtualenv when asked to omit')
996237
def create_venv(requested_deps, interpreter, is_current, options, pip_options):
    """"""
    # create virtualenv
    env = _FadesEnvBuilder()
    env_path, env_bin_path, pip_installed = env.create_env(interpreter, is_current, options)
    venv_data = {}
    venv_data['env_path'] = env_path
    venv_data['env_bin_path'] = env_bin_path
    venv_data['pip_installed'] = pip_installed

    # install deps
    installed = {}
    for repo in requested_deps.keys():
        if repo in (REPO_PYPI, REPO_VCS):
            mgr = PipManager(env_bin_path, pip_installed=pip_installed, options=pip_options)
        else:
            logger.warning("Install from %r not implemented", repo)
            continue
        installed[repo] = {}

        repo_requested = requested_deps[repo]
        logger.debug("Installing dependencies for repo %r: requested=%s", repo, repo_requested)
        for dependency in repo_requested:
            try:
                mgr.install(dependency)
            except Exception:
                logger.debug("Installation Step failed, removing virtualenv")
                destroy_venv(env_path)
                raise FadesError('Dependency installation failed')

            if repo == REPO_VCS:
                # no need to request the installed version, as we'll always compare
                # to the url itself
                project = dependency.url
                version = None
            else:
                # always store the installed dependency, as in the future we'll select the venv
                # based on what is installed, not what used requested (remember that user may
                # request >, >=, etc!)
                project = dependency.project_name
                version = mgr.get_version(project)
            installed[repo][project] = version

        logger.debug("Installed dependencies: %s", installed)
    return venv_data, installed