summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/command/__init__.py
blob: 6a3785061b9dc0b99f66c47d4060da46fa96e7e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Subpackage containing all standard commands."""

from packaging.errors import PackagingModuleError
from packaging.util import resolve_name

__all__ = ['get_command_names', 'set_command', 'get_command_class',
           'STANDARD_COMMANDS']

_COMMANDS = {
    'check': 'packaging.command.check.check',
    'test': 'packaging.command.test.test',
    'build': 'packaging.command.build.build',
    'build_py': 'packaging.command.build_py.build_py',
    'build_ext': 'packaging.command.build_ext.build_ext',
    'build_clib': 'packaging.command.build_clib.build_clib',
    'build_scripts': 'packaging.command.build_scripts.build_scripts',
    'clean': 'packaging.command.clean.clean',
    'install_dist': 'packaging.command.install_dist.install_dist',
    'install_lib': 'packaging.command.install_lib.install_lib',
    'install_headers': 'packaging.command.install_headers.install_headers',
    'install_scripts': 'packaging.command.install_scripts.install_scripts',
    'install_data': 'packaging.command.install_data.install_data',
    'install_distinfo':
        'packaging.command.install_distinfo.install_distinfo',
    'sdist': 'packaging.command.sdist.sdist',
    'bdist': 'packaging.command.bdist.bdist',
    'bdist_dumb': 'packaging.command.bdist_dumb.bdist_dumb',
    'bdist_wininst': 'packaging.command.bdist_wininst.bdist_wininst',
    'register': 'packaging.command.register.register',
    'upload': 'packaging.command.upload.upload',
    'upload_docs': 'packaging.command.upload_docs.upload_docs'}

STANDARD_COMMANDS = set(_COMMANDS)


def get_command_names():
    """Return registered commands"""
    return sorted(_COMMANDS)


def set_command(location):
    cls = resolve_name(location)
    # XXX we want to do the duck-type checking here
    _COMMANDS[cls.get_command_name()] = cls


def get_command_class(name):
    """Return the registered command"""
    try:
        cls = _COMMANDS[name]
        if isinstance(cls, str):
            cls = resolve_name(cls)
            _COMMANDS[name] = cls
        return cls
    except KeyError:
        raise PackagingModuleError("Invalid command %s" % name)