Beispiel #1
0
def test_extras_dev_conflict():
    info = read_pkg_ini(samples_dir / 'extras-dev-conflict.toml')
    with pytest.raises(ValueError, match=r'Ambiguity'):
        Metadata(
            dict(name=info['module'],
                 version='0.0',
                 summary='',
                 **info['metadata']))
Beispiel #2
0
def test_extras():
    info = read_pkg_ini(samples_dir / 'extras.toml')
    requires_dist = set(info['metadata']['requires_dist'])
    assert requires_dist == {
        'toml',
        'pytest; extra == "test"',
        'requests; extra == "custom"',
    }
Beispiel #3
0
def test_extras_dev_warning(caplog):
    info = read_pkg_ini(samples_dir / 'extras-dev-conflict.toml')
    info['metadata']['requires_extra'] = {}
    meta = Metadata(
        dict(name=info['module'],
             version='0.0',
             summary='',
             **info['metadata']))
    assert '“dev-requires = ...” is obsolete' in caplog.text
    assert set(meta.requires_dist) == {'apackage; extra == "dev"'}
Beispiel #4
0
def test_extra_conditions():
    info = read_pkg_ini(samples_dir / 'extras.toml')
    meta = Metadata(
        dict(name=info['module'],
             version='0.0',
             summary='',
             **info['metadata']))
    assert set(meta.requires_dist) == {
        'toml', 'pytest; extra == "test"', 'requests; extra == "custom"'
    }
Beispiel #5
0
 def __init__(self, ini_path, python_version, platform, bitness):
     self.ini_path = ini_path
     self.directory = ini_path.parent
     self.ini_info = ini_info = inifile.read_pkg_ini(ini_path)
     self.module = common.Module(ini_info['module'], self.directory)
     self.metadata = common.make_metadata(self.module, ini_info)
     self.python_version = python_version
     self.platform = platform
     self.bitness = bitness
     self.files = []
     self.has_prefix_files = []
Beispiel #6
0
def setup(ini_path=Path('pyproject.toml'), package_data=None):
    ini_info = inifile.read_pkg_ini(ini_path)
    module = common.Module(ini_info['module'], ini_path.parent)
    metadata = common.make_metadata(module, ini_info)

    kwargs = {}
    for field in fields_same_name:
        val = getattr(metadata, field, None)
        if val:
            kwargs[field] = val

    for st_field, metadata_field in fields_diff_name.items():
        val = getattr(metadata, metadata_field, None)
        if val:
            kwargs[st_field] = val

    if module.is_package:
        kwargs['packages'] = setuptools.find_packages(include=[module.name+'*'])
    else:
        kwargs['py_modules'] = [module.name]

    if metadata.requires_dist:
        kwargs['install_requires'] = [setuptools_requirement_format(req) for req in metadata.requires_dist]
        print(kwargs['install_requires'])

    if ini_info['scripts']:
        kwargs['entry_points'] = {'console_scipts':
            ['{} = {}:{}'.format(k, mod, func)
             for k, (mod, func) in ini_info['scripts'].items()]
        }

    if package_data is not None:
        kwargs['package_data'] = package_data

    # You're on your own from here
    setuptools.setup(**kwargs)
Beispiel #7
0
def test_missing_entrypoints():
    with pytest.raises(FileNotFoundError):
        read_pkg_ini(samples_dir / 'entrypoints_missing.ini')
Beispiel #8
0
def test_extras_dev_conflict():
    with pytest.raises(ValueError, match=r'Ambiguity'):
        read_pkg_ini(samples_dir / 'extras-dev-conflict.toml')
Beispiel #9
0
def test_classifiers_with_space():
    """
    Check that any empty lines (including the first one) for
    classifiers are stripped
    """
    read_pkg_ini(samples_dir / 'classifiers_with_space.ini')
Beispiel #10
0
def test_requires_with_empty_lines(filename, key, expected):
    ini_info = read_pkg_ini(samples_dir / filename)
    assert ini_info['metadata'][key] == expected
Beispiel #11
0
def test_load_toml():
    inf = read_pkg_ini(samples_dir / 'module1-pkg.toml')
    assert inf['module'] == 'module1'
    assert inf['metadata']['home_page'] == 'http://github.com/sirrobin/module1'
Beispiel #12
0
def test_invalid_classifier():
    with pytest.raises(ConfigError):
        read_pkg_ini(samples_dir / 'invalid_classifier.ini')
Beispiel #13
0
def test_extras_dev_conflict():
    with pytest.raises(ConfigError, match=r'dev-requires'):
        read_pkg_ini(samples_dir / 'extras-dev-conflict.toml')
Beispiel #14
0
def test_invalid_classifier():
    with pytest.raises(ConfigError):
        read_pkg_ini(samples_dir / 'invalid_classifier.ini')
Beispiel #15
0
def test_misspelled_key():
    with pytest.raises(ConfigError) as e_info:
        read_pkg_ini(samples_dir / 'misspelled-key.ini')

    assert 'description-file' in str(e_info)
Beispiel #16
0
def test_extras_dev_warning(caplog):
    info = read_pkg_ini(samples_dir / 'requires-dev.toml')
    assert '“dev-requires = ...” is obsolete' in caplog.text
    assert set(
        info['metadata']['requires_dist']) == {'apackage; extra == "dev"'}
Beispiel #17
0
def test_requires_extra_env_marker():
    info = read_pkg_ini(samples_dir / 'requires-extra-envmark.toml')
    assert info['metadata']['requires_dist'][0].startswith('pathlib2;')
Beispiel #18
0
def test_extras():
    info = read_pkg_ini(samples_dir / 'extras.toml')
    assert info['metadata']['requires_extra']['test'] == ['pytest']
    assert info['metadata']['requires_extra']['custom'] == ['requests']
Beispiel #19
0
def test_description_file():
    info = read_pkg_ini(samples_dir / 'package1-pkg.ini')
    assert info['metadata']['description'] == \
        "Sample description for test.\n"
Beispiel #20
0
def test_requires_with_empty_lines():
    ini_info = read_pkg_ini(samples_dir / 'requires_with_empty_lines.ini')
    assert ini_info['metadata']['requires_dist'] == ['foo', 'bar']
Beispiel #21
0
def test_missing_entrypoints():
    with pytest.raises(FileNotFoundError):
        read_pkg_ini(samples_dir / 'entrypoints_missing.ini')
Beispiel #22
0
def test_bad_description_extension(caplog):
    info = read_pkg_ini(samples_dir / 'bad-description-ext.toml')
    assert info['metadata']['description_content_type'] is None
    assert any((r.levelno == logging.WARN and "Unknown extension" in r.msg)
               for r in caplog.records)
Beispiel #23
0
 def __init__(self, ini_path=Path('flit.ini')):
     self.ini_path = ini_path
     self.ini_info = inifile.read_pkg_ini(ini_path)
     self.module = common.Module(self.ini_info['module'], ini_path.parent)
     self.metadata = common.make_metadata(self.module, self.ini_info)
     self.srcdir = ini_path.parent
Beispiel #24
0
def test_missing_description_file():
    with pytest.raises(ConfigError,
                       match=r"Description file .* does not exist"):
        read_pkg_ini(samples_dir / 'missing-description-file.toml')