How to use the flit.init.TerminalIniter function in flit

To help you get started, we’ve selected a few flit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github takluyver / flit / tests / test_init.py View on Github external
def test_init():
    responses = ['foo', # Module name
                 'Test Author',      # Author
                 'test@example.com',  # Author email
                 'http://example.com/', # Home page
                 '1'    # License (1 -> MIT)
                ]
    with TemporaryDirectory() as td, \
          patch_data_dir(), \
          faking_input(responses):
        ti = init.TerminalIniter(td)
        ti.initialise()

        generated = Path(td) / 'pyproject.toml'
        assert_isfile(generated)
        with generated.open() as f:
            data = pytoml.load(f)
        assert data['tool']['flit']['metadata'][
                   'author-email'] == "test@example.com"
        license = Path(td) / 'LICENSE'
        assert_isfile(license)
        with license.open() as f:
            license_text = f.read()
        assert license_text.startswith("The MIT License (MIT)")
        assert "{year}" not in license_text
        assert "Test Author" in license_text
github takluyver / flit / tests / test_init.py View on Github external
def test_init_homepage_validator():
    responses = ['test_module_name',
                 'Test Author',
                 'test_email@example.com',
                 'www.uh-oh-spagghetti-o.com',  # fails validation
                 'https://www.example.org',  # passes
                 '4',  # Skip - choose a license later
                ]
    with TemporaryDirectory() as td, \
          patch_data_dir(), \
          faking_input(responses):
        ti = init.TerminalIniter(td)
        ti.initialise()
        with Path(td, 'pyproject.toml').open() as f:
            data = pytoml.load(f)
    metadata = data['tool']['flit']['metadata']
    assert metadata == {
        'author': 'Test Author',
        'author-email': 'test_email@example.com',
        'home-page': 'https://www.example.org',
        'module': 'test_module_name',
    }
github takluyver / flit / tests / test_init.py View on Github external
def test_init_homepage_and_license_are_optional():
    responses = ['test_module_name',
                 'Test Author',
                 'test_email@example.com',
                 '',   # Home page omitted
                 '4',  # Skip - choose a license later
                ]
    with TemporaryDirectory() as td, \
          patch_data_dir(), \
          faking_input(responses):
        ti = init.TerminalIniter(td)
        ti.initialise()
        with Path(td, 'pyproject.toml').open() as f:
            data = pytoml.load(f)
        assert not Path(td, 'LICENSE').exists()
    metadata = data['tool']['flit']['metadata']
    assert metadata == {
        'author': 'Test Author',
        'author-email': 'test_email@example.com',
        'module': 'test_module_name',
    }
github takluyver / flit / tests / test_init.py View on Github external
def test_prompt_options():
    ti = init.TerminalIniter()
    with faking_input(['4', '1']):
        res = ti.prompt_options('Pick one', [('A', 'Apple'), ('B', 'Banana')])
    assert res == 'A'

    # Test with a default
    with faking_input(['']):
        res = ti.prompt_options('Pick one', [('A', 'Apple'), ('B', 'Banana')],
                                default='B')
    assert res == 'B'
github takluyver / flit / tests / test_init.py View on Github external
def test_author_email_field_is_optional():
    responses = ['test_module_name',
                 'Test Author',
                 '',  # Author-email field is skipped
                 'https://www.example.org',
                 '4',
                ]
    with TemporaryDirectory() as td, \
          patch_data_dir(), \
          faking_input(responses):
        ti = init.TerminalIniter(td)
        ti.initialise()
        with Path(td, 'pyproject.toml').open() as f:
            data = pytoml.load(f)
        assert not Path(td, 'LICENSE').exists()
    metadata = data['tool']['flit']['metadata']
    assert metadata == {
        'author': 'Test Author',
        'module': 'test_module_name',
        'home-page': 'https://www.example.org',
    }
github takluyver / flit / flit / __init__.py View on Github external
main(args.ini_file, repository, formats=set(args.format or []),
                gen_setup_py=args.setup_py)

    elif args.subcmd == 'install':
        from .install import Installer
        try:
            python = find_python_executable(args.python)
            Installer.from_ini_path(args.ini_file, user=args.user, python=python,
                      symlink=args.symlink, deps=args.deps, extras=args.extras,
                      pth=args.pth_file).install()
        except (ConfigError, PythonNotFoundError, common.NoDocstringError, common.NoVersionError) as e:
            sys.exit(e.args[0])

    elif args.subcmd == 'init':
        from .init import TerminalIniter
        TerminalIniter().initialise()
    else:
        ap.print_help()
        sys.exit(1)
github takluyver / flit / flit / init.py View on Github external
f.write(TEMPLATE.format(metadata=toml.dumps(metadata)))

        print()
        print("Written pyproject.toml; edit that file to add optional extra info.")

TEMPLATE = """\
[build-system]
requires = ["flit_core >=2,<4"]
build-backend = "flit_core.buildapi"

[tool.flit.metadata]
{metadata}
"""

if __name__ == '__main__':
    TerminalIniter().initialise()