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 []
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')
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')
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)
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"'
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}
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 []
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 []
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 []
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"
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 []
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"
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)]
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"'
def require(self, cfg): del cfg yield Dependency('coveralls', intent='test')
def require(self, cfg): yield Dependency('coverage', intent='test') if cfg['test']['suite_name'] == 'pytest': yield Dependency('pytest-cov', intent='test')
def require(self, cfg): del cfg yield Dependency('tox', intent='test', channel='conda-forge')
def require(self, cfg): del cfg yield Dependency('flake8', intent='dvlpt')
def require(self, cfg): if cfg['doc']['fmt'] == 'md': yield Dependency('mkdocs', intent='doc')
def require(self, cfg): del cfg yield Dependency('pkglts', intent='install', channel='revesansparole')
def require(self, cfg): del cfg yield Dependency('twine', intent='dvlpt')
def require(self, cfg): yield Dependency('sphinx', intent='doc') if cfg["sphinx"]["theme"] == "sphinx_rtd_theme": yield Dependency('sphinx_rtd_theme', intent='doc')