예제 #1
0
def require(purpose, cfg):
    """List of requirements for this option for a given purpose.

    Args:
        purpose (str): either 'option', 'setup', 'install' or 'dvlpt'
        cfg (Config):  current package configuration

    Returns:
        (list of Dependency)
    """
    if purpose == 'option':
        options = ['base']
        return [Dependency(name) for name in options]

    if purpose == 'dvlpt':
        deps = [Dependency('mock')]

        test_suite = cfg['test']['suite_name']
        if test_suite == 'pytest':
            deps.append(Dependency('pytest'))
        if test_suite == 'nose':
            deps.append(Dependency('nose'))

        return deps

    return []
예제 #2
0
    def require(self, cfg):
        yield Dependency('sphinx', intent='doc')
        if cfg["sphinx"]["theme"] == "sphinx_rtd_theme":
            yield Dependency('sphinx_rtd_theme', intent='doc', pkg_mng='pip')

        if cfg['sphinx']['gallery'] != "":
            yield Dependency('sphinx-gallery', intent='doc')
예제 #3
0
 def require(self, cfg):
     test_suite = cfg['test']['suite_name']
     if test_suite == 'pytest':
         yield Dependency('pytest', intent='test')
         yield Dependency('pytest-mock', intent='test')
     elif test_suite == 'nose':
         yield Dependency('nose', intent='test')
         yield Dependency('mock', intent='test')
예제 #4
0
def test_fmt_pip_reqs_works_correctly():
    assert fmt_pip_reqs([], ['install']) == ""

    d1 = Dependency('d1')
    dex = Dependency('dex', intent='example', pkg_mng='pip')
    dconda = Dependency('dconda')
    dpip = Dependency('dpip', pkg_mng='pip')

    cmd = fmt_pip_reqs([d1, dex, dconda, dpip], ['install'])

    assert cmd.strip() == 'pip install "dpip"'

    d = Dependency('d', pkg_mng='pip', version='= 5')

    assert fmt_pip_reqs([d], ['install']) == 'pip install "d== 5"'
예제 #5
0
파일: handlers.py 프로젝트: ThT12/pkglts
def environment_extensions(cfg):
    """Add more functionality to an environment.

    Args:
        cfg (Config):  current package configuration

    Returns:
        dict of str: any
    """
    req_install = requirements(cfg, 'install')
    for dep in cfg['pysetup']['require']:
        req_install.append(Dependency(**dep))

    req_dvlpt = requirements(cfg, 'dvlpt')

    def req(name):
        if name == 'install':
            return req_install
        elif name == 'dvlpt':
            return req_dvlpt
        else:
            raise UserWarning("WTF")

    return {"pkg_url": pkg_url(cfg),
            "requirements": req}
예제 #6
0
def require(purpose, cfg):
    """List of requirements for this option for a given purpose.

    Args:
        purpose (str): either 'option', 'setup', 'install' or 'dvlpt'
        cfg (Config):  current package configuration

    Returns:
        (list of Dependency)
    """
    if purpose == 'option':
        options = ['base']
        return [Dependency(name) for name in options]

    if purpose == 'dvlpt':
        if cfg['doc']['fmt'] == 'md':
            return [Dependency('mkdocs', 'pip')]

    return []
예제 #7
0
    def require(self, purpose, cfg):
        del cfg

        if purpose == 'option':
            names = [
                'pysetup', 'sphinx', 'coverage', 'data', 'github', 'pypi',
                'conda', 'travis', 'readthedocs'
            ]
            return [Dependency(name) for name in names]

        return []
예제 #8
0
def require(purpose, cfg):
    """List of requirements for this option for a given purpose.

    Args:
        purpose (str): either 'option', 'setup', 'install' or 'dvlpt'
        cfg (Config):  current package configuration

    Returns:
        (list of Dependency)
    """
    del cfg

    if purpose == 'option':
        options = ['pysetup']
        return [Dependency(name) for name in options]

    if purpose == 'dvlpt':
        return [Dependency('twine', 'pip')]

    return []
예제 #9
0
파일: config.py 프로젝트: ThT12/pkglts
def require(purpose, cfg):
    """List of requirements for this option for a given purpose.

    Args:
        purpose (str): either 'option', 'setup', 'install' or 'dvlpt'
        cfg (Config):  current package configuration

    Returns:
        (list of Dependency)
    """
    del cfg

    if purpose == 'option':
        options = ['base', 'test', 'doc', 'license', 'version']
        return [Dependency(name) for name in options]

    return []
예제 #10
0
def requirements(cfg):
    """Check all requirements for installed options.

    Args:
        cfg (Config):  current package configuration

    Returns:
        (list): list of required packages
    """
    reqs = {}
    for name in cfg.installed_options():
        try:
            opt = available_options[name]
            for dep in opt.require(cfg):
                reqs[dep.name] = dep
        except KeyError:
            raise KeyError(f"option '{name}' does not exists")

    for dep_def in cfg['reqs']['require']:
        dep = Dependency(**dep_def)
        reqs[dep.name] = dep

    return [reqs[name] for name in sorted(reqs)]
예제 #11
0
def test_fmt_conda_reqs_works_correctly():
    assert fmt_conda_reqs([], ['install']) == ""

    d1 = Dependency('d1')
    dex = Dependency('dex', intent='example')
    dconda = Dependency('dconda')
    dpip = Dependency('dpip')

    cmd = fmt_conda_reqs([d1, dex, dconda, dpip], ['install'])

    assert cmd.strip() == "conda install d1 dconda dpip"

    d = Dependency('d', channel='extra')

    assert fmt_conda_reqs([d], ['install']) == "conda install -c extra d"

    d = Dependency('d', version='= 5')

    assert fmt_conda_reqs([d], ['install']) == 'conda install "d= 5"'
예제 #12
0
 def require(self, cfg):
     del cfg
     yield Dependency('coveralls', intent='test')
예제 #13
0
def test_dependency_writes_correct_conda_requirements():
    # no version specified
    dep = Dependency("toto", pkg_mng="conda")
    txt = dep.fmt_conda_requirement()
    assert txt == "toto"

    # version partially specified no comparison operator
    dep = Dependency("toto", pkg_mng="conda", version="2.18")
    txt = dep.fmt_conda_requirement()
    assert txt == "toto=2.18"

    # version fully specified no comparison operator
    dep = Dependency("toto", pkg_mng="conda", version="2.18.1")
    txt = dep.fmt_conda_requirement()
    assert txt == "toto=2.18.1"

    # version specified conda comparison operator
    dep = Dependency("toto", pkg_mng="conda", version="=2.18")
    txt = dep.fmt_conda_requirement()
    assert txt == "toto=2.18"

    # version specified pip comparison operator
    dep = Dependency("toto", pkg_mng="conda", version="==2.18")
    txt = dep.fmt_conda_requirement()
    assert txt == "toto=2.18"

    # no version specified pip pkg_mng
    dep = Dependency("toto", pkg_mng="pip")
    txt = dep.fmt_conda_requirement()
    assert txt == "toto"

    # version partially specified no comparison operator pip pkg_mng
    dep = Dependency("toto", pkg_mng="pip", version="2.18")
    txt = dep.fmt_conda_requirement()
    assert txt == "toto=2.18"

    # version partially specified pip comparison operator pip pkg_mng
    dep = Dependency("toto", pkg_mng="pip", version="==2.18")
    txt = dep.fmt_conda_requirement()
    assert txt == "toto=2.18"
예제 #14
0
def test_dependency_writes_correct_pip_requirements():
    # no version specified
    dep = Dependency("toto", pkg_mng="pip")
    txt = dep.fmt_pip_requirement()
    assert txt == "toto"
    txt = dep.fmt_pip_requirement(extended=True)
    assert txt == "toto  # pip install toto"

    # version fully specified without comparison indicator
    dep = Dependency("toto", pkg_mng="pip", version="2.18.0")
    txt = dep.fmt_pip_requirement()
    assert txt == "toto==2.18.0"
    txt = dep.fmt_pip_requirement(extended=True)
    assert txt == "toto==2.18.0  # pip install toto==2.18.0"

    # version partially specified without comparison indicator
    dep = Dependency("toto", pkg_mng="pip", version="2.18")
    txt = dep.fmt_pip_requirement()
    assert txt == "toto>=2.18, <2.19"
    txt = dep.fmt_pip_requirement(extended=True)
    assert txt == "toto>=2.18, <2.19  # pip install toto>=2.18, <2.19"

    # version specified with comparison indicator
    dep = Dependency("toto", pkg_mng="pip", version="==2.18")
    txt = dep.fmt_pip_requirement()
    assert txt == "toto==2.18"
    txt = dep.fmt_pip_requirement(extended=True)
    assert txt == "toto==2.18  # pip install toto==2.18"

    # no version specified conda manager
    dep = Dependency("toto", pkg_mng="conda")
    txt = dep.fmt_pip_requirement()
    assert txt == "toto"
    txt = dep.fmt_pip_requirement(extended=True)
    assert txt == "toto  # conda install toto"

    # version fully specified without comparison indicator conda manager
    dep = Dependency("toto", pkg_mng="conda", version="2.18.1")
    txt = dep.fmt_pip_requirement()
    assert txt == "toto==2.18.1"
    txt = dep.fmt_pip_requirement(extended=True)
    assert txt == "toto==2.18.1  # conda install toto=2.18.1"
    
    # version partially specified without comparison indicator conda manager
    dep = Dependency("toto", pkg_mng="conda", version="2.18")
    txt = dep.fmt_pip_requirement()
    assert txt == "toto>=2.18, <2.19"
    txt = dep.fmt_pip_requirement(extended=True)
    assert txt == "toto>=2.18, <2.19  # conda install toto=2.18"
예제 #15
0
def test_dependency_respect_strict_pkg_mng():
    # conda
    dep = Dependency("toto", pkg_mng="conda")
    assert dep.is_conda(strict=True)
    assert dep.is_conda(strict=False)
    dep = Dependency("toto", pkg_mng=None)
    assert not dep.is_conda(strict=True)
    assert dep.is_conda(strict=False)
    dep = Dependency("toto", pkg_mng="pip")
    assert not dep.is_conda(strict=True)
    assert not dep.is_conda(strict=False)
    dep = Dependency("toto", pkg_mng="git+https://")
    assert not dep.is_conda(strict=True)
    assert not dep.is_conda(strict=False)
    
    # pip
    dep = Dependency("toto", pkg_mng="pip")
    assert dep.is_pip(strict=True)
    assert dep.is_pip(strict=False)
    dep = Dependency("toto", pkg_mng=None)
    assert not dep.is_pip(strict=True)
    assert dep.is_pip(strict=False)
    dep = Dependency("toto", pkg_mng="conda")
    assert not dep.is_pip(strict=True)
    assert not dep.is_pip(strict=False)
    dep = Dependency("toto", pkg_mng="git+https://")
    assert not dep.is_pip(strict=True)
    assert not dep.is_pip(strict=False)
예제 #16
0
 def require(self, cfg):
     del cfg
     yield Dependency('tox', intent='test', channel='conda-forge')
예제 #17
0
파일: option.py 프로젝트: pradal/pkglts
 def require(self, cfg):
     yield Dependency('coverage', intent='test')
     if cfg['test']['suite_name'] == 'pytest':
         yield Dependency('pytest-cov', intent='test')
예제 #18
0
 def require(self, cfg):
     del cfg
     yield Dependency('flake8', intent='dvlpt')
예제 #19
0
 def require(self, cfg):
     if cfg['doc']['fmt'] == 'md':
         yield Dependency('mkdocs', intent='doc')
예제 #20
0
 def require(self, cfg):
     del cfg
     yield Dependency('pkglts', intent='install', channel='revesansparole')
예제 #21
0
 def require(self, cfg):
     del cfg
     yield Dependency('twine', intent='dvlpt')
예제 #22
0
 def require(self, cfg):
     yield Dependency('sphinx', intent='doc')
     if cfg["sphinx"]["theme"] == "sphinx_rtd_theme":
         yield Dependency('sphinx_rtd_theme', intent='doc')