Ejemplo n.º 1
0
def build_external_deps(channel, index, extras, timeout=300, verbose=False,
                        cache=None):
    # looking for a req file
    reqname = '%s-reqs.txt' % channel
    if not os.path.exists(reqname):
        return

    # if not dev, check for pinned versions.
    if channel != 'dev':
        non_pinned = get_non_pinned(reqname)
        if len(non_pinned) > 0:
            deps = ', '.join(non_pinned)
            raise DependencyError('Unpinned dependencies: %s' % deps)

    if os.path.exists('build'):
        root = 'build'
        inc = 1
        while os.path.exists(root + str(inc)):
            inc += 1
        os.rename('build', root + str(inc))

    pip = '%s install -i %s -U -r %s'
    args = (PIP, index, reqname)
    if cache is not None:
        pip += ' --download-cache %s'
        args += (cache,)
    if extras is not None:
        pip += ' --extra-index-url %s'
        args += (extras,)
    run(pip % args, timeout, verbose)
Ejemplo n.º 2
0
def build_external_deps(channel):
    # looking for a req file
    reqname = '%s-reqs.txt' % channel
    filename = os.path.join(os.path.dirname(__file__), reqname)
    if not os.path.exists(filename):
        return
    run('%s -r %s' % (PIP, filename))
def build_external_deps(channel,
                        index,
                        extras,
                        timeout=300,
                        verbose=False,
                        cache=None):
    # looking for a req file
    reqname = '%s-reqs.txt' % channel
    if not os.path.exists(reqname):
        return

    # if not dev, check for pinned versions.
    if channel != 'dev':
        non_pinned = get_non_pinned(reqname)
        if len(non_pinned) > 0:
            deps = ', '.join(non_pinned)
            raise DependencyError('Unpinned dependencies: %s' % deps)

    if os.path.exists('build'):
        root = 'build'
        inc = 1
        while os.path.exists(root + str(inc)):
            inc += 1
        os.rename('build', root + str(inc))

    pip = '%s install -i %s -U -r %s'
    args = (PIP, index, reqname)
    if cache is not None:
        pip += ' --download-cache %s'
        args += (cache, )
    if extras is not None:
        pip += ' --extra-index-url %s'
        args += (extras, )
    run(pip % args, timeout, verbose)
Ejemplo n.º 4
0
def build_rpm(project=None, dist_dir='rpms', version=None, index=PYPI):
    options = {'dist_dir': dist_dir, 'index': index}
    if version is None:
        cmd = "--index=%(index)s --dist-dir=%(dist_dir)s"
    else:
        options['version'] = version
        cmd = ("--index=%(index)s --dist-dir=%(dist_dir)s "
               "--version=%(version)s")

    run('%s %s %s' % (PYPI2RPM, cmd % options, project))
Ejemplo n.º 5
0
def updating_repo(name, channel, specific_tags, force=False, timeout=60,
                  verbose=False):
    if not force and has_changes(timeout, verbose) and channel != 'dev':
        print('The code was changed locally, aborting!')
        print('You can use --force but all uncommited '
              'changes will be discarded.')
        sys.exit(0)

    if is_git():
        run('git submodule update')

    run(update_cmd(name, channel, specific_tags, force), timeout, verbose)
Ejemplo n.º 6
0
def build_rpm(project=None, dist_dir='rpms', version=None, index=PYPI,
              download_cache=None):
    options = {'dist_dir': dist_dir, 'index': index}
    if version is None:
        cmd = "--index=%(index)s --dist-dir=%(dist_dir)s"
    else:
        options['version'] = version
        cmd = ("--index=%(index)s --dist-dir=%(dist_dir)s "
               "--version=%(version)s")

    if download_cache is not None:
        cmd += ' --download-cache=%s' % download_cache

    run('%s %s %s' % (PYPI2RPM, cmd % options, project))
def updating_repo(name,
                  channel,
                  specific_tags,
                  force=False,
                  timeout=60,
                  verbose=False):
    if not force and has_changes(timeout, verbose) and channel != 'dev':
        print('The code was changed locally, aborting!')
        print('You can use --force but all uncommited '
              'changes will be discarded.')
        sys.exit(0)

    if is_git():
        run('git submodule update')

    run(update_cmd(name, channel, specific_tags, force), timeout, verbose)
def build_rpm(project=None,
              dist_dir='rpms',
              version=None,
              index=PYPI,
              download_cache=None):
    options = {'dist_dir': dist_dir, 'index': index}
    if version is None:
        cmd = "--index=%(index)s --dist-dir=%(dist_dir)s"
    else:
        options['version'] = version
        cmd = ("--index=%(index)s --dist-dir=%(dist_dir)s "
               "--version=%(version)s")

    if download_cache is not None:
        cmd += ' --download-cache=%s' % download_cache

    run('%s %s %s' % (PYPI2RPM, cmd % options, project))
def _build_rpm(channel, options):
    if has_changes() and channel != 'dev' and not options.force:
        print('The code was changed, aborting !')
        print('Use the dev channel if you change locally the code')
        sys.exit(0)

    # removing any build dir
    if os.path.exists('build'):
        shutil.rmtree('build')

    cmd_options = {'dist': options.dist_dir}
    cmd = ("--command-packages=pypi2rpm.command bdist_rpm2 "
           "--dist-dir=%(dist)s --binary-only")

    # where's the spec file ?
    spec_file = get_spec_file()

    # if there's a spec file we use it
    if spec_file is not None:
        cmd_options['spec'] = spec_file
        cmd += ' --spec-file=%(spec)s'
    else:
        # if not we define a python-name for the rpm
        # grab the name and create a normalized one
        popen = subprocess.Popen('%s setup.py --name' % sys.executable,
                                 stdout=subprocess.PIPE,
                                 shell=True)
        name = [line for line in popen.stdout.read().split('\n') if line != '']
        name = name[-1].strip().lower()

        if not name.startswith('python'):
            name = '%s-%s' % (_PYTHON, name)
        elif name.startswith('python-'):
            name = '%s-%s' % (_PYTHON, name[len('python-'):])

        cmd_options['name'] = name
        cmd += ' --name=%(name)s'

    # now running the cmd
    run('%s setup.py %s' % (PYTHON, cmd % cmd_options))
Ejemplo n.º 10
0
def _build_rpm(channel, options):
    if has_changes() and channel != 'dev':
        print('the code was changed, aborting!')
        sys.exit(0)

    # removing any build dir
    if os.path.exists('build'):
        shutil.rmtree('build')

    # where's the spec file ?
    spec_file = get_spec_file()

    if spec_file is None:
        return

    cmd_options = {'spec': spec_file, 'dist': options.dist_dir}

    # now running the cmd
    cmd = ("--command-packages=pypi2rpm.command bdist_rpm2 "
           "--spec-file=%(spec)s --dist-dir=%(dist)s")

    run('%s setup.py %s' % (PYTHON, cmd % cmd_options))
Ejemplo n.º 11
0
def _build_rpm(channel, options):
    if has_changes() and channel != 'dev' and not options.force:
        print('The code was changed, aborting !')
        print('Use the dev channel if you change locally the code')
        sys.exit(0)

    # removing any build dir
    if os.path.exists('build'):
        shutil.rmtree('build')

    cmd_options = {'dist': options.dist_dir}
    cmd = ("--command-packages=pypi2rpm.command bdist_rpm2 "
           "--dist-dir=%(dist)s --binary-only")

    # where's the spec file ?
    spec_file = get_spec_file()

    # if there's a spec file we use it
    if spec_file is not None:
        cmd_options['spec'] = spec_file
        cmd += ' --spec-file=%(spec)s'
    else:
        # if not we define a python-name for the rpm
        # grab the name and create a normalized one
        popen = subprocess.Popen('%s setup.py --name' % sys.executable,
                                 stdout=subprocess.PIPE, shell=True)
        name = [line for line in popen.stdout.read().split('\n') if line != '']
        name = name[-1].strip().lower()

        if not name.startswith('python'):
            name = '%s-%s' % (_PYTHON, name)
        elif name.startswith('python-'):
            name = '%s-%s' % (_PYTHON, name[len('python-'):])

        cmd_options['name'] = name
        cmd += ' --name=%(name)s'

    # now running the cmd
    run('%s setup.py %s' % (PYTHON, cmd % cmd_options))
Ejemplo n.º 12
0
def build_dep(dep=None, deps_dir=None, channel='prod', specific_tags=False):
    repo = REPO_ROOT + dep
    target = os.path.join(deps_dir, dep)
    if os.path.exists(target):
        os.chdir(target)
        if is_git():
            run('git fetch')
        else:
            run('hg pull')
    else:
        # let's try to detect the repo kind with a few heuristics
        if _is_git_repo(repo):
            run('git clone %s %s' % (repo, target))
        else:
            run('hg clone %s %s' % (repo, target))

        os.chdir(target)

    if has_changes():
        if channel != 'dev':
            print('the code was changed, aborting!')
            sys.exit(0)
        else:
            print('Warning: the code was changed/')

    cmd = update_cmd(dep, channel, specific_tags)
    run(cmd)
    run('%s setup.py develop' % PYTHON)
Ejemplo n.º 13
0
def build_core_app():
    run('%s setup.py develop' % PYTHON)
Ejemplo n.º 14
0
def build_dep(dep=None, deps_dir=None, channel='prod', specific_tags=False,
              timeout=300, verbose=False):

    # using REPO_ROOT if the provided dep is not an URL
    is_url = False
    for scheme in _REPO_SCHEMES:
        if dep.startswith(scheme):
            is_url = True
            break

    if not is_url:
        repo = REPO_ROOT + dep
    else:
        repo = dep

    target = os.path.join(deps_dir, os.path.basename(dep))
    if os.path.exists(target):
        os.chdir(target)
        if is_git():
            run('git fetch')
        else:
            run('hg pull')
    else:
        # let's try to detect the repo kind with a few heuristics
        if _is_git_repo(repo):
            run('git clone %s %s' % (repo, target))
        else:
            run('hg clone %s %s' % (repo, target))

        os.chdir(target)

    if has_changes(timeout, verbose):
        if channel != 'dev':
            print('The code was changed, aborting !')
            print('Use the dev channel if you change locally the code')
            sys.exit(0)
        else:
            print('Warning: the code was changed.')

    cmd = update_cmd(dep, channel, specific_tags)
    run(cmd, timeout, verbose)
    run('%s setup.py develop' % PYTHON, timeout, verbose)
Ejemplo n.º 15
0
def build_core_app(timeout=300, verbose=False):
    run('%s setup.py develop' % PYTHON, timeout, verbose)
def build_dep(dep=None,
              deps_dir=None,
              channel='prod',
              specific_tags=False,
              timeout=300,
              verbose=False):

    # using REPO_ROOT if the provided dep is not an URL
    is_url = False
    for scheme in _REPO_SCHEMES:
        if dep.startswith(scheme):
            is_url = True
            break

    if not is_url:
        repo = REPO_ROOT + dep
    else:
        repo = dep

    target = os.path.join(deps_dir, os.path.basename(dep))
    if os.path.exists(target):
        os.chdir(target)
        if is_git():
            run('git fetch')
        else:
            run('hg pull')
    else:
        # let's try to detect the repo kind with a few heuristics
        if _is_git_repo(repo):
            run('git clone %s %s' % (repo, target))
        else:
            run('hg clone %s %s' % (repo, target))

        os.chdir(target)

    if has_changes(timeout, verbose):
        if channel != 'dev':
            print('The code was changed, aborting !')
            print('Use the dev channel if you change locally the code')
            sys.exit(0)
        else:
            print('Warning: the code was changed.')

    cmd = update_cmd(dep, channel, specific_tags)
    run(cmd, timeout, verbose)
    run('%s setup.py develop' % PYTHON, timeout, verbose)
def build_core_app(timeout=300, verbose=False):
    run('%s setup.py develop' % PYTHON, timeout, verbose)