Example #1
0
def test_needs_sdist_without_options():
    """Test that a custom sdist can be used in needs() w/o options.setup"""
    _sdist.reset()

    @tasks.task
    @tasks.needs("paver.tests.test_setuputils.sdist")
    def sdist():
        assert _sdist.called

    @tasks.task
    @tasks.needs("sdist")
    def t1():
        pass

    env = _set_environment(sdist=sdist, t1=t1)
    env.options = options.Bunch()
    install_distutils_tasks()
    d = _get_distribution()
    d.cmdclass['sdist'] = _sdist

    tasks._process_commands(['t1'])
    assert sdist.called
    assert _sdist.called
    assert t1.called
    cmd = d.get_command_obj('sdist')
    assert not cmd.foo
    assert not _sdist.foo_set
Example #2
0
def test_task_with_distutils_dep():
    _sdist.reset()

    @tasks.task
    @tasks.needs("paver.tests.test_setuputils.sdist")
    def sdist():
        assert _sdist.called

    env = _set_environment(sdist=sdist)
    env.options = options.Bunch(setup=options.Bunch())
    install_distutils_tasks()
    d = _get_distribution()
    d.cmdclass['sdist'] = _sdist

    task_obj = env.get_task('sdist')
    assert task_obj == sdist
    needs_obj = env.get_task(task_obj.needs[0])
    assert isinstance(needs_obj, DistutilsTask)
    assert needs_obj.command_class == _sdist

    tasks._process_commands(['sdist', "-f"])
    assert sdist.called
    assert _sdist.called
    cmd = d.get_command_obj('sdist')
    print_("Cmd is: %s" % cmd)
    assert cmd.foo
    assert _sdist.foo_set
Example #3
0
def test_needs_sdist_without_options():
    """Test that a custom sdist can be used in needs() w/o options.setup"""
    _sdist.reset()

    @tasks.task
    @tasks.needs("paver.tests.test_setuputils.sdist")
    def sdist():
        assert _sdist.called

    @tasks.task
    @tasks.needs("sdist")
    def t1():
        pass

    env = _set_environment(sdist=sdist, t1=t1)
    env.options = options.Bunch()
    install_distutils_tasks()
    d = _get_distribution()
    d.cmdclass['sdist'] = _sdist

    tasks._process_commands(['t1'])
    assert sdist.called
    assert _sdist.called
    assert t1.called
    cmd = d.get_command_obj('sdist')
    assert not cmd.foo
    assert not _sdist.foo_set
Example #4
0
def test_task_with_distutils_dep():
    _sdist.reset()
    
    @tasks.task
    @tasks.needs("paver.tests.test_setuputils.sdist")
    def sdist():
        assert _sdist.called
        
    env = _set_environment(sdist=sdist)
    env.options = options.Bunch(setup=options.Bunch())
    install_distutils_tasks()
    d = _get_distribution()
    d.cmdclass['sdist'] = _sdist
    
    task_obj = env.get_task('sdist')
    assert task_obj == sdist
    needs_obj = env.get_task(task_obj.needs[0])
    assert isinstance(needs_obj, DistutilsTask)
    assert needs_obj.command_class == _sdist
    
    tasks._process_commands(['sdist', "-f"])
    assert sdist.called
    assert _sdist.called
    cmd = d.get_command_obj('sdist')
    print_("Cmd is: %s" % cmd)
    assert cmd.foo
    assert _sdist.foo_set
Example #5
0
def test_distutils_task_finder():
    env = _set_environment()
    env.options = options.Bunch(setup=options.Bunch())
    dist = _get_distribution()
    dutf = DistutilsTaskFinder()
    task = dutf.get_task('distutils.command.install')
    assert task
    task = dutf.get_task('install')
    assert task
    task = dutf.get_task('foo')
    assert task is None
Example #6
0
def test_distutils_task_finder():
    env = _set_environment()
    env.options = options.Bunch(setup=options.Bunch())
    dist = _get_distribution()
    dutf = DistutilsTaskFinder()
    task = dutf.get_task('distutils.command.install')
    assert task
    task = dutf.get_task('install')
    assert task
    task = dutf.get_task('foo')
    assert task is None
Example #7
0
def wheel(env):
    call_task('bdist_wheel')

    dist = _get_distribution()
    for cmd, x, file in dist.dist_files:
        if cmd == 'bdist_wheel':
            env.wheel_file = path(file).abspath()
            debug('Invented the wheel in %s', env.wheel_file)
            break
    else:
        info('Cannot invent the wheel')
Example #8
0
def test_negative_opts_handled_for_distutils():
    _sdist.reset()
    env = _set_environment()
    env.options = options.Bunch(setup=options.Bunch())
    install_distutils_tasks()
    d = _get_distribution()
    d.cmdclass['sdist'] = _sdist_with_default_foo

    tasks._process_commands(['sdist', '--no-foo'])

    assert _sdist.called
    assert not _sdist.foo_set
Example #9
0
def test_negative_opts_handled_for_distutils():
    _sdist.reset()
    env = _set_environment()
    env.options = options.Bunch(setup=options.Bunch())
    install_distutils_tasks()
    d = _get_distribution()
    d.cmdclass['sdist'] = _sdist_with_default_foo

    tasks._process_commands(['sdist', '--no-foo'])

    assert _sdist.called
    assert not _sdist.foo_set
Example #10
0
def test_distutils_tasks_should_not_get_extra_options():
    _sdist.reset()
    env = _set_environment()
    env.options = options.Bunch(setup=options.Bunch())
    install_distutils_tasks()
    d = _get_distribution()
    d.cmdclass['sdist'] = _sdist
    
    tasks._process_commands(['sdist'])
    assert _sdist.called
    assert not _sdist.foo_set
    opts = d.get_option_dict('sdist')
    assert 'foo' not in opts
Example #11
0
def test_distutils_tasks_should_not_get_extra_options():
    _sdist.reset()
    env = _set_environment()
    env.options = options.Bunch(setup=options.Bunch())
    install_distutils_tasks()
    d = _get_distribution()
    d.cmdclass['sdist'] = _sdist

    tasks._process_commands(['sdist'])
    assert _sdist.called
    assert not _sdist.foo_set
    opts = d.get_option_dict('sdist')
    assert 'foo' not in opts
Example #12
0
def link_latest():
    dist = _get_distribution()
    name = dist.get_name()
    prefix = len(dist.get_fullname()) + 1

    for cmd, x, file in dist.dist_files:
        file = path(file)
        ext = file.basename()[prefix:]
        link = ROOT.joinpath('dist/{}-latest.{}'.format(name, ext))

        if link.islink():
            os.unlink(link)

        info('Link %s to %s', link, file.basename())
        file.basename().symlink(link)
Example #13
0
def replace_templates(env):
    dist = _get_distribution()
    comm_vars = get_common_variables(dist)

    build_task = env.get_task('build')
    build = build_task.command_class(build_task.distribution)
    build.set_undefined_options('build', ('build_lib', 'build_lib'))

    comm_vars['build_lib'] = build.build_lib

    replace_template_files(
        root_directory=os.curdir,
        variables=comm_vars,
        subdirs=getattr(options, "template_files_directories", None)
    )
Example #14
0
def compute_version_git(options):
    from citools.version import get_git_describe, compute_version, get_branch_suffix, retrieve_current_branch
    if not getattr(options, "accepted_tag_pattern", None):
        options.accepted_tag_pattern = "%s-[0-9]*" % options.name

    dist = _get_distribution()

    current_git_version = get_git_describe(accepted_tag_pattern=options.accepted_tag_pattern)
    branch_suffix = get_branch_suffix(dist.metadata, retrieve_current_branch())

    options.version = compute_version(current_git_version)
    dist.metadata.version = options.version_str = '.'.join(map(str, options.version))

    dist.metadata.branch_suffix = options.branch_suffix = branch_suffix

    print options.version_str
Example #15
0
def test_override_distutils_command():
    @tasks.task
    def sdist():
        pass
    
    env = _set_environment(sdist=sdist)
    env.options = options.Bunch(setup=options.Bunch())
    
    install_distutils_tasks()
    d = _get_distribution()
    
    d.cmdclass['sdist'] = _sdist
    tasks._process_commands(['sdist', 'paver.tests.test_setuputils.sdist', '-f'])
    assert sdist.called
    assert _sdist.called
    assert _sdist.foo_set
    assert isinstance(_sdist.fin, _sdist)
Example #16
0
def test_override_distutils_command():
    @tasks.task
    def sdist():
        pass

    env = _set_environment(sdist=sdist)
    env.options = options.Bunch(setup=options.Bunch())

    install_distutils_tasks()
    d = _get_distribution()

    d.cmdclass['sdist'] = _sdist
    tasks._process_commands(
        ['sdist', 'paver.tests.test_setuputils.sdist', '-f'])
    assert sdist.called
    assert _sdist.called
    assert _sdist.foo_set
    assert isinstance(_sdist.fin, _sdist)
Example #17
0
def compute_version_git_datetime(options):
    from citools.version import get_git_head_tstamp, get_branch_suffix, retrieve_current_branch

    tstamp = int(get_git_head_tstamp())
    if not tstamp:
        raise Exception("Git log parsing error")
    commit_dtime = datetime.fromtimestamp(tstamp)
    commit_version = commit_dtime.strftime("%Y.%m.%d.%H%M")#.split('.')

    dist = _get_distribution()
    branch_suffix = get_branch_suffix(dist.metadata, retrieve_current_branch())

    options.version = commit_version
    dist.metadata.version = commit_version

    dist.metadata.branch_suffix = options.branch_suffix = branch_suffix

    print options.version
Example #18
0
def rename_template_files():
    _rename_template_files(root_directory=os.curdir, variables=get_common_variables(_get_distribution()))