コード例 #1
0
def create_docs(path, name, author):
    """ Create a project documentation.

    Parameters
    ----------
    path: str or Pathlib path
        Path of the project root. Folder 'docs' will be created as subfolder.

    name: str
        Name of the project

    author:
        Author of the project
    """

    os.makedirs(path / 'docs')
    render(path / 'docs' / 'requirements.txt', 'sphinx\nsphinx_rtd_theme\n')

    shell(find_python() + ' -m pip install -r requirements.txt',
          root=str(path / 'docs'))

    cmd = find_python(
    ) + ' -m sphinx.cmd.quickstart -p %s -a "%s" -v 0.0.1 --no-sep -l en -r 0.0.1 docs' % (
        name,
        author,
    )
    shell(cmd, str(path), silent=False)

    replace(path / 'docs' / 'conf.py', {'alabaster': 'sphinx_rtd_theme'})
コード例 #2
0
ファイル: run.py プロジェクト: pythusiac/manati
def run_flake8(dirs):
    """Run flake8 style enforcement in specified directories.

    Parameters
    ----------
    dirs: list of str
        The directories to scan for style violations.
    """

    shell(find_python() + ' -m pip install --upgrade flake8')
    shell(find_python() + ' -m flake8 ' + ' '.join(dirs) + ' --max-line-length=120', silent=False)
コード例 #3
0
ファイル: run.py プロジェクト: pythusiac/manati
def run_tests(test_folder, runner):

    if not exists(test_folder):
        raise click.BadParameter('No such folder %s' % test_folder)

    if runner == 'unittest':
        shell(find_python() +' -m unittest discover ' + str(test_folder), silent=False)
    elif runner == 'pytest':
        shell(find_python() + ' -m pip install --upgrade pytest')
        shell(find_python() + ' -m pytest ' + str(test_folder), silent=False)
    else:
        raise click.BadParameter('No such test runner: %s' % runner)
コード例 #4
0
ファイル: manati.py プロジェクト: maroba/manati
def info_command():
    """Scan for project data."""

    info = find_project_data()
    info['python'] = utils.find_python()
    info['sphinx-quickstart'] = utils.find_sphinx_quickstart()
    info['sphinx-build'] = utils.find_sphinx_build()

    def echo_warning(title, key):
        value = info.get(key, 'NOT FOUND')
        if value is None:
            value = 'NOT FOUND'
        if value == 'NOT FOUND':
            click.echo(title + value, nl=False)
            click.secho(' [!]', fg='red')
        else:
            click.echo(title + value)

    echo_warning('Project name: ', 'name')
    echo_warning('Package: ', 'package')
    echo_warning('Test directory: ', 'tests')
    echo_warning('Version: ', 'version')
    echo_warning('Author: ', 'author')
    echo_warning('Email: ', 'email')
    echo_warning('URL: ', 'url')
    echo_warning('Python: ', 'python')
    echo_warning('sphinx-quickstart: ', 'sphinx-quickstart')
    echo_warning('sphinx-build: ', 'sphinx-build')
コード例 #5
0
ファイル: run.py プロジェクト: pythusiac/manati
def run_docs():
    """Build the documentation and show it in the browser."""

    cwd = Path.cwd()
    if not exists(cwd / 'docs'):
        raise click.BadParameter('Cannot find docs folder.')

    shell('make clean', root=str(cwd / 'docs'), silent=False)
    shell(find_python() + ' -m sphinx.cmd.build -M html . _build', root=str(cwd / 'docs'), silent=False)
    click.launch(str(cwd / 'docs' / '_build' / 'html' / 'index.html'))
コード例 #6
0
ファイル: run.py プロジェクト: pythusiac/manati
def run_coverage(source, test_dir, runner):

    if not exists(test_dir):
        raise click.BadParameter('No such folder or file: %s' % test_dir)

    if not exists(source):
        raise click.BadParameter('No such folder %s' % source)

    if runner == 'unittest':
        shell(find_python() + ' -m pip install --upgrade coverage')
        shell(find_python() + ' -m coverage run --source=%s -m unittest discover %s' %
              (source, test_dir), silent=False)
    elif runner == 'pytest':
        shell(find_python() + ' -m pip install --upgrade coverage pytest')
        shell(find_python() + ' -m coverage run --source=%s -m pytest %s' %
              (source, test_dir), silent=False)
    else:
        raise click.BadParameter('No such test runner: %s' % runner)

    shell(find_python() + ' -m coverage report -m', silent=False)
コード例 #7
0
def deploy_pypi():
    """Deploy project in current directory to PyPi."""

    cwd = Path.cwd()

    if not exists(cwd / 'setup.py'):
        raise click.UsageError(
            'No setup.py found. Is this really a project root?')

    if exists(cwd / 'build') or exists(cwd / 'dist'):
        if click.confirm(
                'build and/or dist folder found which will be deleted. Continue?'
        ):
            shutil.rmtree(cwd / 'build')
            shutil.rmtree(cwd / 'dist')
        else:
            click.Abort()
            return

    shell(find_python() + ' -m pip install --upgrade wheel twine',
          silent=False)
    shell(find_python() + ' setup.py sdist bdist_wheel', silent=False)

    do_twine()
コード例 #8
0
    def test_run_tests(self):
        runner = CliRunner()
        with runner.isolated_filesystem() as fs:
            create_project_structure('test_project', Path('test_project'), {
                'PROJECT_NAME': 'test_project',
                'MODULE_NAME': 'test_project'
            })

            os.chdir(Path.cwd() / 'test_project')
            shell(find_python() + ' -m pip install -e .')
            result = runner.invoke(
                cli, ['run', 'tests', '-r', 'unittest', '-t', 'tests'])
            assert result.exit_code == 0

            result = runner.invoke(
                cli, ['run', 'tests', '-r', 'pytest', '-t', 'tests'])
            assert result.exit_code == 0
コード例 #9
0
def do_twine():
    """Login and upload to PyPi."""
    click.echo('Log in to PyPi...')
    shell(find_python() + ' -m twine upload *', 'dist', silent=False)
コード例 #10
0
def pip_install_project(name):
    shell(find_python() + ' -m pip install -e .', root=name)
コード例 #11
0
def build_documentation(name):
    shell(find_python() + ' -m sphinx.cmd.build -M html . _build',
          root=str(Path.cwd() / name / 'docs'))