Mercurial > cpython-lru_cache-weakref
annotate Lib/packaging/command/__init__.py @ 73798:6cde416ef03b
Credit Per Øyvind Karlsen for the initial implementation of the lzma module (issue #6715).
| author | Nadeem Vawda <nadeem.vawda@gmail.com> |
|---|---|
| date | Thu, 01 Dec 2011 01:18:27 +0200 |
| parents | 688c53548f6b |
| children | 699265a57211 |
| rev | line source |
|---|---|
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
1 """Subpackage containing all standard commands.""" |
|
72150
6330a08cfedf
Fix packaging command registry to let Windows machines find bdist_msi
Éric Araujo <merwok@netwok.org>
parents:
72126
diff
changeset
|
2 import os |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
3 from packaging.errors import PackagingModuleError |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
4 from packaging.util import resolve_name |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
5 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
6 __all__ = ['get_command_names', 'set_command', 'get_command_class', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
7 'STANDARD_COMMANDS'] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
8 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
9 _COMMANDS = { |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
10 'check': 'packaging.command.check.check', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
11 'test': 'packaging.command.test.test', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
12 'build': 'packaging.command.build.build', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
13 'build_py': 'packaging.command.build_py.build_py', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
14 'build_ext': 'packaging.command.build_ext.build_ext', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
15 'build_clib': 'packaging.command.build_clib.build_clib', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
16 'build_scripts': 'packaging.command.build_scripts.build_scripts', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
17 'clean': 'packaging.command.clean.clean', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
18 'install_dist': 'packaging.command.install_dist.install_dist', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
19 'install_lib': 'packaging.command.install_lib.install_lib', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
20 'install_headers': 'packaging.command.install_headers.install_headers', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
21 'install_scripts': 'packaging.command.install_scripts.install_scripts', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
22 'install_data': 'packaging.command.install_data.install_data', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
23 'install_distinfo': |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
24 'packaging.command.install_distinfo.install_distinfo', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
25 'sdist': 'packaging.command.sdist.sdist', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
26 'bdist': 'packaging.command.bdist.bdist', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
27 'bdist_dumb': 'packaging.command.bdist_dumb.bdist_dumb', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
28 'bdist_wininst': 'packaging.command.bdist_wininst.bdist_wininst', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
29 'register': 'packaging.command.register.register', |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
30 'upload': 'packaging.command.upload.upload', |
|
72150
6330a08cfedf
Fix packaging command registry to let Windows machines find bdist_msi
Éric Araujo <merwok@netwok.org>
parents:
72126
diff
changeset
|
31 'upload_docs': 'packaging.command.upload_docs.upload_docs', |
|
6330a08cfedf
Fix packaging command registry to let Windows machines find bdist_msi
Éric Araujo <merwok@netwok.org>
parents:
72126
diff
changeset
|
32 } |
|
6330a08cfedf
Fix packaging command registry to let Windows machines find bdist_msi
Éric Araujo <merwok@netwok.org>
parents:
72126
diff
changeset
|
33 |
|
6330a08cfedf
Fix packaging command registry to let Windows machines find bdist_msi
Éric Araujo <merwok@netwok.org>
parents:
72126
diff
changeset
|
34 # XXX this is crappy |
|
6330a08cfedf
Fix packaging command registry to let Windows machines find bdist_msi
Éric Araujo <merwok@netwok.org>
parents:
72126
diff
changeset
|
35 if os.name == 'nt': |
|
72375
688c53548f6b
The value is the dotted module name to the command class.
Jeremy Kloth <jeremy.kloth@gmail.com>
parents:
72150
diff
changeset
|
36 _COMMANDS['bdist_msi'] = 'packaging.command.bdist_msi.bdist_msi' |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
37 |
|
72126
e4576486544c
Cleanup: move code out of a try block
Éric Araujo <merwok@netwok.org>
parents:
70194
diff
changeset
|
38 # XXX use OrderedDict to preserve the grouping (build-related, install-related, |
|
e4576486544c
Cleanup: move code out of a try block
Éric Araujo <merwok@netwok.org>
parents:
70194
diff
changeset
|
39 # distribution-related) |
|
70194
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
40 STANDARD_COMMANDS = set(_COMMANDS) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
41 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
42 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
43 def get_command_names(): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
44 """Return registered commands""" |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
45 return sorted(_COMMANDS) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
46 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
47 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
48 def set_command(location): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
49 cls = resolve_name(location) |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
50 # XXX we want to do the duck-type checking here |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
51 _COMMANDS[cls.get_command_name()] = cls |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
52 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
53 |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
54 def get_command_class(name): |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
55 """Return the registered command""" |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
56 try: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
57 cls = _COMMANDS[name] |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
58 except KeyError: |
|
1a31c3be88b1
initial import of the packaging package in the standard library
Tarek Ziade <tarek@ziade.org>
parents:
diff
changeset
|
59 raise PackagingModuleError("Invalid command %s" % name) |
|
72126
e4576486544c
Cleanup: move code out of a try block
Éric Araujo <merwok@netwok.org>
parents:
70194
diff
changeset
|
60 if isinstance(cls, str): |
|
e4576486544c
Cleanup: move code out of a try block
Éric Araujo <merwok@netwok.org>
parents:
70194
diff
changeset
|
61 cls = resolve_name(cls) |
|
e4576486544c
Cleanup: move code out of a try block
Éric Araujo <merwok@netwok.org>
parents:
70194
diff
changeset
|
62 _COMMANDS[name] = cls |
|
e4576486544c
Cleanup: move code out of a try block
Éric Araujo <merwok@netwok.org>
parents:
70194
diff
changeset
|
63 return cls |
