Пример #1
0
def handle_flit(data):
    """
    Handle pyproject.toml unserialized into data, using flit build
    system.
    """

    topdata = data['tool']['flit']
    metadata = topdata['metadata']
    modname = metadata['module']
    sys.path.insert(0, '.')
    mod = importlib.import_module(modname, '')

    entry_points = defaultdict(list)
    if 'scripts' in topdata:
        for name, content in topdata['scripts'].items():
            entry_points['console_scripts'].append('{} = {}'.format(
                name, content))

    if 'entrypoints' in topdata:
        for group_name, group_content in topdata['entrypoints'].items():
            for name, path in group_content.items():
                entry_points[group_name].append('{} = {}'.format(name, path))

    package_args = auto_find_packages(modname)

    setup(name=modname,
          version=mod.__version__,
          description=mod.__doc__.strip(),
          author=metadata['author'],
          author_email=metadata['author-email'],
          url=metadata.get('home-page'),
          classifiers=metadata.get('classifiers', []),
          entry_points=dict(entry_points),
          **package_args)
Пример #2
0
def handle_flit(data):
    """
    Handle pyproject.toml unserialized into data, using flit build
    system.
    """

    metadata = data['tool']['flit']['metadata']
    modname = metadata['module']
    sys.path.insert(0, '.')
    mod = importlib.import_module(modname, '')

    if 'scripts' in data['tool']['flit']:
        raise NotImplementedError('flit.scripts not supported yet')
    if 'entrypoints' in data['tool']['flit']:
        raise NotImplementedError('flit.entrypoints not supported yet')

    package_args = auto_find_packages(modname)

    setup(name=modname,
          version=mod.__version__,
          description=mod.__doc__.strip(),
          author=metadata['author'],
          author_email=metadata['author-email'],
          url=metadata.get('home-page'),
          classifiers=metadata.get('classifiers', []),
          **package_args)
Пример #3
0
    def test_module(self):
        """ Test finding a plain .py module. """

        with TestDirectory() as d:
            with open('test_module.py', 'w') as f:
                pass
            self.assertEqual(auto_find_packages('test_module'),
                             {'py_modules': ['test_module']})
Пример #4
0
    def test_package(self):
        """ Test finding a flat package. """

        with TestDirectory() as d:
            os.mkdir('test_package')
            with open('test_package/__init__.py', 'w') as f:
                pass
            self.assertEqual(auto_find_packages('test_package'),
                             {'packages': ['test_package']})
Пример #5
0
def handle_poetry(data):
    """
    Handle pyproject.toml unserialized into data, using poetry build
    system.
    """

    metadata = data['tool']['poetry']

    authors = []
    author_emails = []
    for a in metadata['authors']:
        name, addr = email.utils.parseaddr(a)
        authors.append(name)
        author_emails.append(addr)

    if 'packages' not in metadata:
        package_args = auto_find_packages(metadata['name'])
    else:
        package_args = {'packages': [], 'package_dir': {}}
        for p in metadata['packages']:
            if p.get('format', '') == 'sdist':
                continue
            subdir = p.get('from', '.')
            packages = find_packages(subdir,
                                     include=(p['include'],
                                              p['include'] + '.*'))
            package_args['packages'].extend(packages)
            if subdir != '.':
                for sp in packages:
                    package_args['package_dir'][sp] = os.path.join(
                        subdir, sp.replace('.', os.path.sep))

    entry_points = defaultdict(list)
    if 'scripts' in metadata:
        for name, content in metadata['scripts'].items():
            entry_points['console_scripts'].append('{} = {}'.format(
                name, content))

    if 'plugins' in metadata:
        for group_name, group_content in metadata['plugins'].items():
            for name, path in group_content.items():
                entry_points[group_name].append('{} = {}'.format(name, path))

    setup(
        name=metadata['name'],
        version=metadata['version'],
        description=metadata['description'],
        author=', '.join(authors),
        author_email=', '.join(author_emails),
        url=metadata.get('homepage'),
        classifiers=metadata.get('classifiers', []),
        entry_points=dict(entry_points),
        # hack stolen from flit
        package_data={'': ['*']},
        **package_args)
Пример #6
0
    def test_package_deep(self):
        """ Test finding a package with a subpackage. """

        with TestDirectory() as d:
            for subdir in ('test_package', 'test_package/subpackage'):
                os.mkdir(subdir)
                with open('{}/__init__.py'.format(subdir), 'w') as f:
                    pass
            self.assertEqual(
                auto_find_packages('test_package'),
                {'packages': ['test_package', 'test_package.subpackage']})
Пример #7
0
def handle_flit_thyself(data):
    """Handle flit_core.build_thyself backend"""
    bs = data['build-system']
    sys.path.insert(0, bs['backend-path'])
    mod = importlib.import_module(bs['build-backend'], '')
    metadata = mod.metadata_dict
    package_args = auto_find_packages(bs['build-backend'].split('.')[0])

    setup(name=mod.metadata.name,
          version=mod.metadata.version,
          description=mod.metadata.summary,
          author=metadata['author'],
          author_email=metadata['author_email'],
          url=metadata.get('home_page'),
          classifiers=metadata.get('classifiers', []),
          **package_args)