2011-05-19 08:07:25 -03:00
|
|
|
"""Subpackage containing all standard commands."""
|
2011-08-31 11:12:31 -03:00
|
|
|
import os
|
2011-05-19 08:07:25 -03:00
|
|
|
from packaging.errors import PackagingModuleError
|
|
|
|
from packaging.util import resolve_name
|
|
|
|
|
|
|
|
__all__ = ['get_command_names', 'set_command', 'get_command_class',
|
|
|
|
'STANDARD_COMMANDS']
|
|
|
|
|
2012-02-09 09:29:11 -04:00
|
|
|
|
|
|
|
STANDARD_COMMANDS = [
|
|
|
|
# packaging
|
|
|
|
'check', 'test',
|
|
|
|
# building
|
|
|
|
'build', 'build_py', 'build_ext', 'build_clib', 'build_scripts', 'clean',
|
|
|
|
# installing
|
|
|
|
'install_dist', 'install_lib', 'install_headers', 'install_scripts',
|
|
|
|
'install_data', 'install_distinfo',
|
|
|
|
# distributing
|
|
|
|
'sdist', 'bdist', 'bdist_dumb', 'bdist_wininst',
|
|
|
|
'register', 'upload', 'upload_docs',
|
|
|
|
]
|
|
|
|
|
2011-08-31 11:12:31 -03:00
|
|
|
if os.name == 'nt':
|
2012-02-09 09:29:11 -04:00
|
|
|
STANDARD_COMMANDS.insert(STANDARD_COMMANDS.index('bdist_wininst'),
|
|
|
|
'bdist_msi')
|
2011-05-19 08:07:25 -03:00
|
|
|
|
2012-02-09 09:29:11 -04:00
|
|
|
# XXX maybe we need more than one registry, so that --list-comands can display
|
|
|
|
# standard, custom and overriden standard commands differently
|
|
|
|
_COMMANDS = dict((name, 'packaging.command.%s.%s' % (name, name))
|
|
|
|
for name in STANDARD_COMMANDS)
|
2011-05-19 08:07:25 -03:00
|
|
|
|
|
|
|
|
|
|
|
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]
|
|
|
|
except KeyError:
|
|
|
|
raise PackagingModuleError("Invalid command %s" % name)
|
2011-08-29 19:45:59 -03:00
|
|
|
if isinstance(cls, str):
|
|
|
|
cls = resolve_name(cls)
|
|
|
|
_COMMANDS[name] = cls
|
|
|
|
return cls
|