Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/dist.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 4b72d56cf42f |
| children |
| rev | line source |
|---|---|
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1 """distutils.dist |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
2 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
3 Provides the Distribution class, which represents the module distribution |
|
12822
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
4 being built/installed/distributed. |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
5 """ |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
6 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
7 __revision__ = "$Id$" |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
8 |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
9 import sys, os, re |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
10 from email import message_from_file |
|
25973
a68c6d62fe78
Make the Distribution() constructor forgiving of unknown keyword
Andrew M. Kuchling <amk@amk.ca>
parents:
25212
diff
changeset
|
11 |
|
a68c6d62fe78
Make the Distribution() constructor forgiving of unknown keyword
Andrew M. Kuchling <amk@amk.ca>
parents:
25212
diff
changeset
|
12 try: |
|
a68c6d62fe78
Make the Distribution() constructor forgiving of unknown keyword
Andrew M. Kuchling <amk@amk.ca>
parents:
25212
diff
changeset
|
13 import warnings |
| 25975 | 14 except ImportError: |
|
25973
a68c6d62fe78
Make the Distribution() constructor forgiving of unknown keyword
Andrew M. Kuchling <amk@amk.ca>
parents:
25212
diff
changeset
|
15 warnings = None |
|
a68c6d62fe78
Make the Distribution() constructor forgiving of unknown keyword
Andrew M. Kuchling <amk@amk.ca>
parents:
25212
diff
changeset
|
16 |
|
57847
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57603
diff
changeset
|
17 from distutils.errors import (DistutilsOptionError, DistutilsArgError, |
|
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57603
diff
changeset
|
18 DistutilsModuleError, DistutilsClassError) |
|
14832
54adb7b4f8c8
Change to use the new 'translate_longopt()' function from fancy_getopt, rather
Greg Ward <gward@python.net>
parents:
14827
diff
changeset
|
19 from distutils.fancy_getopt import FancyGetopt, translate_longopt |
|
17127
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
20 from distutils.util import check_environ, strtobool, rfc822_escape |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21267
diff
changeset
|
21 from distutils import log |
|
25212
12949eced55f
Use distutils.debug.DEBUG instead of distutils.core.DEBUG.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23681
diff
changeset
|
22 from distutils.debug import DEBUG |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
23 |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
24 # Encoding used for the PKG-INFO files |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
25 PKG_INFO_ENCODING = 'utf-8' |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
26 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
27 # Regex to define acceptable Distutils command names. This is not *quite* |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
28 # the same as a Python NAME -- I don't allow leading underscores. The fact |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
29 # that they're very similar is no coincidence; the default naming scheme is |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
30 # to look for a Python module named after the command. |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
31 command_re = re.compile (r'^[a-zA-Z]([a-zA-Z0-9_]*)$') |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
32 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
33 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
34 class Distribution: |
|
12822
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
35 """The core of the Distutils. Most of the work hiding behind 'setup' |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
36 is really done within a Distribution instance, which farms the work out |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
37 to the Distutils commands specified on the command line. |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
38 |
|
12822
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
39 Setup scripts will almost never instantiate Distribution directly, |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
40 unless the 'setup()' function is totally inadequate to their needs. |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
41 However, it is conceivable that a setup script might wish to subclass |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
42 Distribution for some specialized purpose, and then pass the subclass |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
43 to 'setup()' as the 'distclass' keyword argument. If so, it is |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
44 necessary to respect the expectations that 'setup' has of Distribution. |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
45 See the code for 'setup()', in core.py, for details. |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
46 """ |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
47 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
48 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
49 # 'global_options' describes the command-line options that may be |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
50 # supplied to the setup script prior to any actual commands. |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
51 # Eg. "./setup.py -n" or "./setup.py --quiet" both take advantage of |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
52 # these global options. This list should be kept to a bare minimum, |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
53 # since every global option is also valid as a command option -- and we |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
54 # don't want to pollute the commands with too many options that they |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
55 # have minimal control over. |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21267
diff
changeset
|
56 # The fourth entry for verbose means that it can be repeated. |
|
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21267
diff
changeset
|
57 global_options = [('verbose', 'v', "run verbosely (default)", 1), |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
58 ('quiet', 'q', "run quietly (turns verbosity off)"), |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
59 ('dry-run', 'n', "don't actually do anything"), |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
60 ('help', 'h', "show detailed help message"), |
|
56923
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
61 ('no-user-cfg', None, |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
62 'ignore pydistutils.cfg in your home directory'), |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
63 ] |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
64 |
|
34648
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
65 # 'common_usage' is a short (2-3 line) string describing the common |
|
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
66 # usage of the setup script. |
|
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
67 common_usage = """\ |
|
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
68 Common commands: (see '--help-commands' for more) |
|
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
69 |
|
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
70 setup.py build will build the package underneath 'build/' |
|
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
71 setup.py install will install the package |
|
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
72 """ |
|
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
73 |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
74 # options that are not propagated to the commands |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
75 display_options = [ |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
76 ('help-commands', None, |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
77 "list all available commands"), |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
78 ('name', None, |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
79 "print package name"), |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
80 ('version', 'V', |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
81 "print package version"), |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
82 ('fullname', None, |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
83 "print <package name>-<version>"), |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
84 ('author', None, |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
85 "print the author's name"), |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
86 ('author-email', None, |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
87 "print the author's email address"), |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
88 ('maintainer', None, |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
89 "print the maintainer's name"), |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
90 ('maintainer-email', None, |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
91 "print the maintainer's email address"), |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
92 ('contact', None, |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
93 "print the maintainer's name if known, else the author's"), |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
94 ('contact-email', None, |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
95 "print the maintainer's email address if known, else the author's"), |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
96 ('url', None, |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
97 "print the URL for this package"), |
|
19137
fb12ea9290b2
[Bug #412271, bug #449009] Use 'license' as the attribute name,
Andrew M. Kuchling <amk@amk.ca>
parents:
17271
diff
changeset
|
98 ('license', None, |
|
fb12ea9290b2
[Bug #412271, bug #449009] Use 'license' as the attribute name,
Andrew M. Kuchling <amk@amk.ca>
parents:
17271
diff
changeset
|
99 "print the license of the package"), |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
100 ('licence', None, |
|
19137
fb12ea9290b2
[Bug #412271, bug #449009] Use 'license' as the attribute name,
Andrew M. Kuchling <amk@amk.ca>
parents:
17271
diff
changeset
|
101 "alias for --license"), |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
102 ('description', None, |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
103 "print the package description"), |
|
12496
2a53a3a47962
Harry Henry Gebel: add 'long_description' to DistributionMetadata.
Greg Ward <gward@python.net>
parents:
12448
diff
changeset
|
104 ('long-description', None, |
|
2a53a3a47962
Harry Henry Gebel: add 'long_description' to DistributionMetadata.
Greg Ward <gward@python.net>
parents:
12448
diff
changeset
|
105 "print the long package description"), |
|
17127
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
106 ('platforms', None, |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
107 "print the list of platforms"), |
|
27048
554121fcbb9d
[Patch #658094] PEP 301 implementation
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
108 ('classifiers', None, |
|
554121fcbb9d
[Patch #658094] PEP 301 implementation
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
109 "print the list of classifiers"), |
|
17127
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
110 ('keywords', None, |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
111 "print the list of keywords"), |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
112 ('provides', None, |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
113 "print the list of packages/modules provided"), |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
114 ('requires', None, |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
115 "print the list of packages/modules required"), |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
116 ('obsoletes', None, |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
117 "print the list of packages/modules made obsolete") |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
118 ] |
|
14832
54adb7b4f8c8
Change to use the new 'translate_longopt()' function from fancy_getopt, rather
Greg Ward <gward@python.net>
parents:
14827
diff
changeset
|
119 display_option_names = map(lambda x: translate_longopt(x[0]), |
|
54adb7b4f8c8
Change to use the new 'translate_longopt()' function from fancy_getopt, rather
Greg Ward <gward@python.net>
parents:
14827
diff
changeset
|
120 display_options) |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
121 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
122 # negative options are options that exclude other options |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
123 negative_opt = {'quiet': 'verbose'} |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
124 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
125 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
126 # -- Creation/initialization methods ------------------------------- |
| 21267 | 127 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
128 def __init__ (self, attrs=None): |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
129 """Construct a new Distribution instance: initialize all the |
|
12822
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
130 attributes of a Distribution, and then use 'attrs' (a dictionary |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
131 mapping attribute names to values) to assign some of those |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
132 attributes their "real" values. (Any attributes not mentioned in |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
133 'attrs' will be assigned to some null value: 0, None, an empty list |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
134 or dictionary, etc.) Most importantly, initialize the |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
135 'command_obj' attribute to the empty dictionary; this will be |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
136 filled in with real command objects by 'parse_command_line()'. |
|
723df0c801d1
Reformatted and updated many docstrings.
Greg Ward <gward@python.net>
parents:
12811
diff
changeset
|
137 """ |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
138 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
139 # Default values for our command-line options |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
140 self.verbose = 1 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
141 self.dry_run = 0 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
142 self.help = 0 |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
143 for attr in self.display_option_names: |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
144 setattr(self, attr, 0) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
145 |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
146 # Store the distribution meta-data (name, version, author, and so |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
147 # forth) in a separate object -- we're getting to have enough |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
148 # information here (and enough command-line options) that it's |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
149 # worth it. Also delegate 'get_XXX()' methods to the 'metadata' |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
150 # object in a sneaky and underhanded (but efficient!) way. |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
151 self.metadata = DistributionMetadata() |
|
19669
87e8fc0a9862
Don't use dir() to find instance attribute names.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
19139
diff
changeset
|
152 for basename in self.metadata._METHOD_BASENAMES: |
|
12448
e3bb239b2dbf
Fix how we generate the meta-data query methods to include 'get_fullname()'
Greg Ward <gward@python.net>
parents:
12430
diff
changeset
|
153 method_name = "get_" + basename |
|
e3bb239b2dbf
Fix how we generate the meta-data query methods to include 'get_fullname()'
Greg Ward <gward@python.net>
parents:
12430
diff
changeset
|
154 setattr(self, method_name, getattr(self.metadata, method_name)) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
155 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
156 # 'cmdclass' maps command names to class objects, so we |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
157 # can 1) quickly figure out which class to instantiate when |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
158 # we need to create a new command object, and 2) have a way |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
159 # for the setup script to override command classes |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
160 self.cmdclass = {} |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
161 |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
162 # 'command_packages' is a list of packages in which commands |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
163 # are searched for. The factory for command 'foo' is expected |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
164 # to be named 'foo' in the module 'foo' in one of the packages |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
165 # named here. This list is searched from the left; an error |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
166 # is raised if no named package provides the command being |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
167 # searched for. (Always access using get_command_packages().) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
168 self.command_packages = None |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
169 |
|
14237
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
170 # 'script_name' and 'script_args' are usually set to sys.argv[0] |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
171 # and sys.argv[1:], but they can be overridden when the caller is |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
172 # not necessarily a setup script run from the command-line. |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
173 self.script_name = None |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
174 self.script_args = None |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
175 |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
176 # 'command_options' is where we store command options between |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
177 # parsing them (from config files, the command-line, etc.) and when |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
178 # they are actually needed -- ie. when the command in question is |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
179 # instantiated. It is a dictionary of dictionaries of 2-tuples: |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
180 # command_options = { command_name : { option : (source, value) } } |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
181 self.command_options = {} |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
182 |
|
34805
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
183 # 'dist_files' is the list of (command, pyversion, file) that |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
184 # have been created by any dist commands run so far. This is |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
185 # filled regardless of whether the run is dry or not. pyversion |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
186 # gives sysconfig.get_python_version() if the dist file is |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
187 # specific to a Python version, 'any' if it is good for all |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
188 # Python versions on the target platform, and '' for a source |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
189 # file. pyversion should not be used to specify minimum or |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
190 # maximum required Python versions; use the metainfo for that |
|
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
191 # instead. |
|
34793
3da21fdc2ee7
Add the upload command. Make all dist commands register their
Martin v. Löwis <martin@v.loewis.de>
parents:
34788
diff
changeset
|
192 self.dist_files = [] |
|
3da21fdc2ee7
Add the upload command. Make all dist commands register their
Martin v. Löwis <martin@v.loewis.de>
parents:
34788
diff
changeset
|
193 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
194 # These options are really the business of various commands, rather |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
195 # than of the Distribution itself. We provide aliases for them in |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
196 # Distribution as a convenience to the developer. |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
197 self.packages = None |
|
32328
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
31777
diff
changeset
|
198 self.package_data = {} |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
199 self.package_dir = None |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
200 self.py_modules = None |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
201 self.libraries = None |
|
12780
9335daa9ddd3
Support for the "install_headers" command: distribution option 'headers'
Greg Ward <gward@python.net>
parents:
12762
diff
changeset
|
202 self.headers = None |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
203 self.ext_modules = None |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
204 self.ext_package = None |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
205 self.include_dirs = None |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
206 self.extra_path = None |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12673
diff
changeset
|
207 self.scripts = None |
|
12704
6059a9279d99
List data files are listed in the Distribution attribute 'data_files',
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
208 self.data_files = None |
|
50637
a3f329f23b23
fixed #4394 make the storage of the password optional in .pypirc
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
209 self.password = '' |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
210 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
211 # And now initialize bookkeeping stuff that can't be supplied by |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
212 # the caller at all. 'command_obj' maps command names to |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
213 # Command instances -- that's how we enforce that every command |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
214 # class is a singleton. |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
215 self.command_obj = {} |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
216 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
217 # 'have_run' maps command names to boolean values; it keeps track |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
218 # of whether we have actually run a particular command, to make it |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
219 # cheap to "run" a command whenever we think we might need to -- if |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
220 # it's already been done, no need for expensive filesystem |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
221 # operations, we just check the 'have_run' dictionary and carry on. |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
222 # It's only safe to query 'have_run' for a command class that has |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
223 # been instantiated -- a false value will be inserted when the |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
224 # command object is created, and replaced with a true value when |
|
13725
449dd3a00bd7
Fixed a grab-bag of typos spotted by Rob Hooft.
Greg Ward <gward@python.net>
parents:
13413
diff
changeset
|
225 # the command is successfully run. Thus it's probably best to use |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
226 # '.get()' rather than a straight lookup. |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
227 self.have_run = {} |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
228 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
229 # Now we'll use the attrs dictionary (ultimately, keyword args from |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
230 # the setup script) to possibly override any or all of these |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
231 # distribution options. |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
232 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
233 if attrs: |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
234 # Pull out the set of command options and work on them |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
235 # specifically. Note that this order guarantees that aliased |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
236 # command options will override any supplied redundantly |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
237 # through the general options dictionary. |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
238 options = attrs.get('options') |
|
50366
ad20b69b18b7
Merged revisions 68033 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
48981
diff
changeset
|
239 if options is not None: |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
240 del attrs['options'] |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
241 for (command, cmd_options) in options.items(): |
|
12762
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
242 opt_dict = self.get_option_dict(command) |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
243 for (opt, val) in cmd_options.items(): |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
244 opt_dict[opt] = ("setup script", val) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
245 |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
34805
diff
changeset
|
246 if 'licence' in attrs: |
|
28155
178d19cff163
[Bug #693470] 'licence' as an alias for 'license' doesn't work.
Andrew M. Kuchling <amk@amk.ca>
parents:
27975
diff
changeset
|
247 attrs['license'] = attrs['licence'] |
|
178d19cff163
[Bug #693470] 'licence' as an alias for 'license' doesn't work.
Andrew M. Kuchling <amk@amk.ca>
parents:
27975
diff
changeset
|
248 del attrs['licence'] |
|
178d19cff163
[Bug #693470] 'licence' as an alias for 'license' doesn't work.
Andrew M. Kuchling <amk@amk.ca>
parents:
27975
diff
changeset
|
249 msg = "'licence' distribution option is deprecated; use 'license'" |
|
178d19cff163
[Bug #693470] 'licence' as an alias for 'license' doesn't work.
Andrew M. Kuchling <amk@amk.ca>
parents:
27975
diff
changeset
|
250 if warnings is not None: |
|
178d19cff163
[Bug #693470] 'licence' as an alias for 'license' doesn't work.
Andrew M. Kuchling <amk@amk.ca>
parents:
27975
diff
changeset
|
251 warnings.warn(msg) |
|
178d19cff163
[Bug #693470] 'licence' as an alias for 'license' doesn't work.
Andrew M. Kuchling <amk@amk.ca>
parents:
27975
diff
changeset
|
252 else: |
|
178d19cff163
[Bug #693470] 'licence' as an alias for 'license' doesn't work.
Andrew M. Kuchling <amk@amk.ca>
parents:
27975
diff
changeset
|
253 sys.stderr.write(msg + "\n") |
|
178d19cff163
[Bug #693470] 'licence' as an alias for 'license' doesn't work.
Andrew M. Kuchling <amk@amk.ca>
parents:
27975
diff
changeset
|
254 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
255 # Now work on the rest of the attributes. Any attribute that's |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
256 # not already defined is invalid! |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
257 for (key, val) in attrs.items(): |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
258 if hasattr(self.metadata, "set_" + key): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
259 getattr(self.metadata, "set_" + key)(val) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
260 elif hasattr(self.metadata, key): |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
261 setattr(self.metadata, key, val) |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
262 elif hasattr(self, key): |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
263 setattr(self, key, val) |
|
33745
74ceb6fcb432
oops. how did _that_ happen?
Anthony Baxter <anthonybaxter@gmail.com>
parents:
33744
diff
changeset
|
264 else: |
|
25973
a68c6d62fe78
Make the Distribution() constructor forgiving of unknown keyword
Andrew M. Kuchling <amk@amk.ca>
parents:
25212
diff
changeset
|
265 msg = "Unknown distribution option: %s" % repr(key) |
|
a68c6d62fe78
Make the Distribution() constructor forgiving of unknown keyword
Andrew M. Kuchling <amk@amk.ca>
parents:
25212
diff
changeset
|
266 if warnings is not None: |
|
a68c6d62fe78
Make the Distribution() constructor forgiving of unknown keyword
Andrew M. Kuchling <amk@amk.ca>
parents:
25212
diff
changeset
|
267 warnings.warn(msg) |
|
a68c6d62fe78
Make the Distribution() constructor forgiving of unknown keyword
Andrew M. Kuchling <amk@amk.ca>
parents:
25212
diff
changeset
|
268 else: |
|
a68c6d62fe78
Make the Distribution() constructor forgiving of unknown keyword
Andrew M. Kuchling <amk@amk.ca>
parents:
25212
diff
changeset
|
269 sys.stderr.write(msg + "\n") |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
270 |
|
56923
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
271 # no-user-cfg is handled before other command line args |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
272 # because other args override the config files, and this |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
273 # one is needed before we can load the config files. |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
274 # If attrs['script_args'] wasn't passed, assume false. |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
275 # |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
276 # This also make sure we just look at the global options |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
277 self.want_user_cfg = True |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
278 |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
279 if self.script_args is not None: |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
280 for arg in self.script_args: |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
281 if not arg.startswith('-'): |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
282 break |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
283 if arg == '--no-user-cfg': |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
284 self.want_user_cfg = False |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
285 break |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
286 |
|
17127
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
287 self.finalize_options() |
| 21267 | 288 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
289 def get_option_dict(self, command): |
|
12762
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
290 """Get the option dictionary for a given command. If that |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
291 command's option dictionary hasn't been created yet, then create it |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
292 and return the new dictionary; otherwise, return the existing |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
293 option dictionary. |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
294 """ |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
295 dict = self.command_options.get(command) |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
296 if dict is None: |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
297 dict = self.command_options[command] = {} |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
298 return dict |
|
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
299 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
300 def dump_option_dicts(self, header=None, commands=None, indent=""): |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
301 from pprint import pformat |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
302 |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
303 if commands is None: # dump all command option dicts |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
304 commands = self.command_options.keys() |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
305 commands.sort() |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
306 |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
307 if header is not None: |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
308 self.announce(indent + header) |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
309 indent = indent + " " |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
310 |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
311 if not commands: |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
312 self.announce(indent + "no commands known yet") |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
313 return |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
314 |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
315 for cmd_name in commands: |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
316 opt_dict = self.command_options.get(cmd_name) |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
317 if opt_dict is None: |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
318 self.announce(indent + |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
319 "no option dict for '%s' command" % cmd_name) |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
320 else: |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
321 self.announce(indent + |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
322 "option dict for '%s' command:" % cmd_name) |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
323 out = pformat(opt_dict) |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
324 for line in out.split('\n'): |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
325 self.announce(indent + " " + line) |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
326 |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
327 # -- Config file finding/parsing methods --------------------------- |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
328 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
329 def find_config_files(self): |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
330 """Find as many configuration files as should be processed for this |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
331 platform, and return a list of filenames in the order in which they |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
332 should be parsed. The filenames returned are guaranteed to exist |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
333 (modulo nasty race conditions). |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
334 |
|
21257
08dbf6b3c316
[Bug #459270] Fix incorrect docstring
Andrew M. Kuchling <amk@amk.ca>
parents:
19669
diff
changeset
|
335 There are three possible config files: distutils.cfg in the |
|
08dbf6b3c316
[Bug #459270] Fix incorrect docstring
Andrew M. Kuchling <amk@amk.ca>
parents:
19669
diff
changeset
|
336 Distutils installation directory (ie. where the top-level |
|
08dbf6b3c316
[Bug #459270] Fix incorrect docstring
Andrew M. Kuchling <amk@amk.ca>
parents:
19669
diff
changeset
|
337 Distutils __inst__.py file lives), a file in the user's home |
|
08dbf6b3c316
[Bug #459270] Fix incorrect docstring
Andrew M. Kuchling <amk@amk.ca>
parents:
19669
diff
changeset
|
338 directory named .pydistutils.cfg on Unix and pydistutils.cfg |
|
56923
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
339 on Windows/Mac; and setup.cfg in the current directory. |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
340 |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
341 The file in the user's home directory can be disabled with the |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
342 --no-user-cfg option. |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
343 """ |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
344 files = [] |
| 12867 | 345 check_environ() |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
346 |
|
12868
f4b487e35214
Always look for the system config file in the Distutils module directory,
Greg Ward <gward@python.net>
parents:
12867
diff
changeset
|
347 # Where to look for the system-wide Distutils config file |
|
f4b487e35214
Always look for the system config file in the Distutils module directory,
Greg Ward <gward@python.net>
parents:
12867
diff
changeset
|
348 sys_dir = os.path.dirname(sys.modules['distutils'].__file__) |
|
f4b487e35214
Always look for the system config file in the Distutils module directory,
Greg Ward <gward@python.net>
parents:
12867
diff
changeset
|
349 |
|
f4b487e35214
Always look for the system config file in the Distutils module directory,
Greg Ward <gward@python.net>
parents:
12867
diff
changeset
|
350 # Look for the system config file |
|
f4b487e35214
Always look for the system config file in the Distutils module directory,
Greg Ward <gward@python.net>
parents:
12867
diff
changeset
|
351 sys_file = os.path.join(sys_dir, "distutils.cfg") |
| 12867 | 352 if os.path.isfile(sys_file): |
| 353 files.append(sys_file) | |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
354 |
|
12868
f4b487e35214
Always look for the system config file in the Distutils module directory,
Greg Ward <gward@python.net>
parents:
12867
diff
changeset
|
355 # What to call the per-user config file |
|
f4b487e35214
Always look for the system config file in the Distutils module directory,
Greg Ward <gward@python.net>
parents:
12867
diff
changeset
|
356 if os.name == 'posix': |
|
13413
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
357 user_filename = ".pydistutils.cfg" |
|
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
358 else: |
|
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
359 user_filename = "pydistutils.cfg" |
| 15216 | 360 |
|
12868
f4b487e35214
Always look for the system config file in the Distutils module directory,
Greg Ward <gward@python.net>
parents:
12867
diff
changeset
|
361 # And look for the user config file |
|
56923
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
362 if self.want_user_cfg: |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
363 user_file = os.path.join(os.path.expanduser('~'), user_filename) |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
364 if os.path.isfile(user_file): |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
365 files.append(user_file) |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
366 |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
367 # All platforms support local setup.cfg |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
368 local_file = "setup.cfg" |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
369 if os.path.isfile(local_file): |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
370 files.append(local_file) |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
371 |
|
56923
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
372 if DEBUG: |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
373 self.announce("using config files: %s" % ', '.join(files)) |
|
fc5a7718433a
Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56435
diff
changeset
|
374 |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
375 return files |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
376 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
377 def parse_config_files(self, filenames=None): |
|
47252
e534ee0a4cd0
ConfigParser renaming reversal part 3: move module into place and adapt imports.
Georg Brandl <georg@python.org>
parents:
47078
diff
changeset
|
378 from ConfigParser import ConfigParser |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
379 |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
380 if filenames is None: |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
381 filenames = self.find_config_files() |
|
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
382 |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
383 if DEBUG: |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
384 self.announce("Distribution.parse_config_files():") |
|
12732
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
385 |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
386 parser = ConfigParser() |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
387 for filename in filenames: |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
388 if DEBUG: |
|
56158
7a7642ab11b3
#6954: Fixed crash when using DISTUTILS_DEBUG flag in Distutils.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55101
diff
changeset
|
389 self.announce(" reading %s" % filename) |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
390 parser.read(filename) |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
391 for section in parser.sections(): |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
392 options = parser.options(section) |
|
12762
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
393 opt_dict = self.get_option_dict(section) |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
394 |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
395 for opt in options: |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
396 if opt != '__name__': |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
397 val = parser.get(section,opt) |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
398 opt = opt.replace('-', '_') |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
399 opt_dict[opt] = (filename, val) |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
400 |
|
12732
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
401 # Make the ConfigParser forget everything (so we retain |
|
31546
2c8a43063d82
commentary about how bad ConfigParser is doesn't help here, and the
Fred Drake <fdrake@acm.org>
parents:
31515
diff
changeset
|
402 # the original filenames that options come from) |
|
12732
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
403 parser.__init__() |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
404 |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
405 # If there was a "global" section in the config file, use it |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
406 # to set Distribution options. |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
407 |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
34805
diff
changeset
|
408 if 'global' in self.command_options: |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
409 for (opt, (src, val)) in self.command_options['global'].items(): |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
410 alias = self.negative_opt.get(opt) |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
411 try: |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
412 if alias: |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
413 setattr(self, alias, not strtobool(val)) |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
414 elif opt in ('verbose', 'dry_run'): # ugh! |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
415 setattr(self, opt, strtobool(val)) |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
416 else: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
417 setattr(self, opt, val) |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
418 except ValueError, msg: |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
419 raise DistutilsOptionError, msg |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
420 |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
421 # -- Command-line parsing methods ---------------------------------- |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
422 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
423 def parse_command_line(self): |
|
14237
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
424 """Parse the setup script's command line, taken from the |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
425 'script_args' instance attribute (which defaults to 'sys.argv[1:]' |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
426 -- see 'setup()' in core.py). This list is first processed for |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
427 "global options" -- options that set attributes of the Distribution |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
428 instance. Then, it is alternately scanned for Distutils commands |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
429 and options for that command. Each new command terminates the |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
430 options for the previous command. The allowed options for a |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
431 command are determined by the 'user_options' attribute of the |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
432 command class -- thus, we have to be able to load command classes |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
433 in order to parse the command line. Any error in that 'options' |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
434 attribute raises DistutilsGetoptError; any error on the |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
435 command-line raises DistutilsArgError. If no Distutils commands |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
436 were found on the command line, raises DistutilsArgError. Return |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
437 true if command-line was successfully parsed and we should carry |
|
14237
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
438 on with executing commands; false if no errors but we shouldn't |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
439 execute commands (currently, this only happens if user asks for |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
440 help). |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
441 """ |
|
15880
3ea10ee91e9c
Fix from Jack Jansen for the Mac and the Metrowerks compiler, posted
Andrew M. Kuchling <amk@amk.ca>
parents:
15398
diff
changeset
|
442 # |
|
19139
4a8ab67773a9
Wrap a comment to fit in 80 columns.
Fred Drake <fdrake@acm.org>
parents:
19137
diff
changeset
|
443 # We now have enough information to show the Macintosh dialog |
|
4a8ab67773a9
Wrap a comment to fit in 80 columns.
Fred Drake <fdrake@acm.org>
parents:
19137
diff
changeset
|
444 # that allows the user to interactively specify the "command line". |
|
15880
3ea10ee91e9c
Fix from Jack Jansen for the Mac and the Metrowerks compiler, posted
Andrew M. Kuchling <amk@amk.ca>
parents:
15398
diff
changeset
|
445 # |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
446 toplevel_options = self._get_toplevel_options() |
| 21267 | 447 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
448 # We have to parse the command line a bit at a time -- global |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
449 # options, then the first command, then its options, and so on -- |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
450 # because each command will be handled by a different class, and |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
451 # the options that are valid for a particular class aren't known |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
452 # until we have loaded the command class, which doesn't happen |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
453 # until we know what the command is. |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
454 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
455 self.commands = [] |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
456 parser = FancyGetopt(toplevel_options + self.display_options) |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
457 parser.set_negative_aliases(self.negative_opt) |
|
19137
fb12ea9290b2
[Bug #412271, bug #449009] Use 'license' as the attribute name,
Andrew M. Kuchling <amk@amk.ca>
parents:
17271
diff
changeset
|
458 parser.set_aliases({'licence': 'license'}) |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
459 args = parser.getopt(args=self.script_args, object=self) |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
460 option_order = parser.get_option_order() |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21267
diff
changeset
|
461 log.set_verbosity(self.verbose) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
462 |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
463 # for display options we return immediately |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
464 if self.handle_display_options(option_order): |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
465 return |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
466 while args: |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
467 args = self._parse_command_opts(parser, args) |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
468 if args is None: # user asked for help (and got it) |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
469 return |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
470 |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
471 # Handle the cases of --help as a "global" option, ie. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
472 # "setup.py --help" and "setup.py --help command ...". For the |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
473 # former, we show global options (--verbose, --dry-run, etc.) |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
474 # and display-only options (--name, --version, etc.); for the |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
475 # latter, we omit the display-only options and show help for |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
476 # each command listed on the command line. |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
477 if self.help: |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
478 self._show_help(parser, |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
479 display_options=len(self.commands) == 0, |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
480 commands=self.commands) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
481 return |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
482 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
483 # Oops, no commands found -- an end-user error |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
484 if not self.commands: |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
485 raise DistutilsArgError, "no commands supplied" |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
486 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
487 # All is well: return true |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
488 return 1 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
489 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
490 def _get_toplevel_options(self): |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
491 """Return the non-display options recognized at the top level. |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
492 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
493 This includes options that are recognized *only* at the top |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
494 level as well as options recognized for commands. |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
495 """ |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
496 return self.global_options + [ |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
497 ("command-packages=", None, |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
498 "list of packages that provide distutils commands"), |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
499 ] |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
500 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
501 def _parse_command_opts(self, parser, args): |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
502 """Parse the command-line options for a single command. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
503 'parser' must be a FancyGetopt instance; 'args' must be the list |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
504 of arguments, starting with the current command (whose options |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
505 we are about to parse). Returns a new version of 'args' with |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
506 the next command at the front of the list; will be the empty |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
507 list if there are no more commands on the command line. Returns |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
508 None if the user asked for help on this command. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
509 """ |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
510 # late import because of mutual dependence between these modules |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
511 from distutils.cmd import Command |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
512 |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
513 # Pull the current command from the head of the command line |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
514 command = args[0] |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
515 if not command_re.match(command): |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
516 raise SystemExit, "invalid command name '%s'" % command |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
517 self.commands.append(command) |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
518 |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
519 # Dig up the command class that implements this command, so we |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
520 # 1) know that it's a valid command, and 2) know which options |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
521 # it takes. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
522 try: |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
523 cmd_class = self.get_command_class(command) |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
524 except DistutilsModuleError, msg: |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
525 raise DistutilsArgError, msg |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
526 |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
527 # Require that the command class be derived from Command -- want |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
528 # to be sure that the basic "command" interface is implemented. |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
529 if not issubclass(cmd_class, Command): |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
530 raise DistutilsClassError, \ |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
531 "command class %s must subclass Command" % cmd_class |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
532 |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
533 # Also make sure that the command object provides a list of its |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
534 # known options. |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
535 if not (hasattr(cmd_class, 'user_options') and |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
536 isinstance(cmd_class.user_options, list)): |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
537 raise DistutilsClassError, \ |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
538 ("command class %s must provide " + |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
539 "'user_options' attribute (a list of tuples)") % \ |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
540 cmd_class |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
541 |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
542 # If the command class has a list of negative alias options, |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
543 # merge it in with the global negative aliases. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
544 negative_opt = self.negative_opt |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
545 if hasattr(cmd_class, 'negative_opt'): |
|
54101
b4261da4ea50
Fix bootstrapping by removing uses of the copy module in distutils
Antoine Pitrou <solipsis@pitrou.net>
parents:
51799
diff
changeset
|
546 negative_opt = negative_opt.copy() |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
547 negative_opt.update(cmd_class.negative_opt) |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
548 |
| 15216 | 549 # Check for help_options in command class. They have a different |
| 550 # format (tuple of four) so we need to preprocess them here. | |
|
13413
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
551 if (hasattr(cmd_class, 'help_options') and |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
552 isinstance(cmd_class.help_options, list)): |
|
12997
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
553 help_options = fix_help_options(cmd_class.help_options) |
|
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
554 else: |
|
12998
86d498946868
More stylistic tweaks to the generic '--help-xxx' code.
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
555 help_options = [] |
|
12997
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
556 |
|
12869
88872791998a
Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents:
12868
diff
changeset
|
557 |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
558 # All commands support the global options too, just by adding |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
559 # in 'global_options'. |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
560 parser.set_option_table(self.global_options + |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
561 cmd_class.user_options + |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
562 help_options) |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
563 parser.set_negative_aliases(negative_opt) |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
564 (args, opts) = parser.getopt(args[1:]) |
|
12732
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
565 if hasattr(opts, 'help') and opts.help: |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
566 self._show_help(parser, display_options=0, commands=[cmd_class]) |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
567 return |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
568 |
|
13413
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
569 if (hasattr(cmd_class, 'help_options') and |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
570 isinstance(cmd_class.help_options, list)): |
|
13413
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
571 help_option_found=0 |
|
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
572 for (help_option, short, desc, func) in cmd_class.help_options: |
|
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
573 if hasattr(opts, parser.get_attr_name(help_option)): |
|
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
574 help_option_found=1 |
|
56435
57ee0793e462
replace callable()
Benjamin Peterson <benjamin@python.org>
parents:
56158
diff
changeset
|
575 if hasattr(func, '__call__'): |
|
13413
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
576 func() |
|
12998
86d498946868
More stylistic tweaks to the generic '--help-xxx' code.
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
577 else: |
|
19139
4a8ab67773a9
Wrap a comment to fit in 80 columns.
Fred Drake <fdrake@acm.org>
parents:
19137
diff
changeset
|
578 raise DistutilsClassError( |
|
31515
71a294bd7950
Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents:
28155
diff
changeset
|
579 "invalid help function %r for help option '%s': " |
|
19139
4a8ab67773a9
Wrap a comment to fit in 80 columns.
Fred Drake <fdrake@acm.org>
parents:
19137
diff
changeset
|
580 "must be a callable object (function, etc.)" |
|
31515
71a294bd7950
Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents:
28155
diff
changeset
|
581 % (func, help_option)) |
|
12998
86d498946868
More stylistic tweaks to the generic '--help-xxx' code.
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
582 |
| 21267 | 583 if help_option_found: |
|
13413
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
584 return |
|
12869
88872791998a
Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents:
12868
diff
changeset
|
585 |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
586 # Put the options from the command-line into their official |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
587 # holding pen, the 'command_options' dictionary. |
|
12762
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
588 opt_dict = self.get_option_dict(command) |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
589 for (name, value) in vars(opts).items(): |
|
12762
9e1b8050de63
Factored out code for extracting-or-creating one of the option
Greg Ward <gward@python.net>
parents:
12735
diff
changeset
|
590 opt_dict[name] = ("command line", value) |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
591 |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
592 return args |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
593 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
594 def finalize_options(self): |
|
17127
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
595 """Set final values for all the options on the Distribution |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
596 instance, analogous to the .finalize_options() method of Command |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
597 objects. |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
598 """ |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
599 for attr in ('keywords', 'platforms'): |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
600 value = getattr(self.metadata, attr) |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
601 if value is None: |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
602 continue |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
603 if isinstance(value, str): |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
604 value = [elm.strip() for elm in value.split(',')] |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
605 setattr(self.metadata, attr, value) |
|
17127
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
606 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
607 def _show_help(self, parser, global_options=1, display_options=1, |
|
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
608 commands=[]): |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
609 """Show help for the setup script command-line in the form of |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
610 several lists of command-line options. 'parser' should be a |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
611 FancyGetopt instance; do not expect it to be returned in the |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
612 same state, as its option table will be reset to make it |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
613 generate the correct help text. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
614 |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
615 If 'global_options' is true, lists the global options: |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
616 --verbose, --dry-run, etc. If 'display_options' is true, lists |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
617 the "display-only" options: --name, --version, etc. Finally, |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
618 lists per-command help for every command name or command class |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
619 in 'commands'. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
620 """ |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
621 # late import because of mutual dependence between these modules |
|
14237
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
622 from distutils.core import gen_usage |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
623 from distutils.cmd import Command |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
624 |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
625 if global_options: |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
626 if display_options: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
627 options = self._get_toplevel_options() |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
628 else: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
629 options = self.global_options |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
630 parser.set_option_table(options) |
|
34648
d48fa0afdcba
Patch #1104111: Alter setup.py --help and --help-commands.
Martin v. Löwis <martin@v.loewis.de>
parents:
33965
diff
changeset
|
631 parser.print_help(self.common_usage + "\nGlobal options:") |
|
55101
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
632 print('') |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
633 |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
634 if display_options: |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
635 parser.set_option_table(self.display_options) |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
636 parser.print_help( |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
637 "Information display options (just display " + |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
638 "information, ignore any commands)") |
|
55101
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
639 print('') |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
640 |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
641 for command in self.commands: |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
642 if isinstance(command, type) and issubclass(command, Command): |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
643 klass = command |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
644 else: |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
645 klass = self.get_command_class(command) |
|
13413
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
646 if (hasattr(klass, 'help_options') and |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
647 isinstance(klass.help_options, list)): |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
648 parser.set_option_table(klass.user_options + |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
649 fix_help_options(klass.help_options)) |
|
13413
7fea4a1af090
fix inconsistent use of tabs and spaces
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
13044
diff
changeset
|
650 else: |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
651 parser.set_option_table(klass.user_options) |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
652 parser.print_help("Options for '%s' command:" % klass.__name__) |
|
55101
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
653 print('') |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
654 |
|
55101
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
655 print(gen_usage(self.script_name)) |
| 15216 | 656 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
657 def handle_display_options(self, option_order): |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
658 """If there were any non-global "display-only" options |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
659 (--help-commands or the metadata display options) on the command |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
660 line, display the requested info and return true; else return |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
661 false. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
662 """ |
|
14237
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13725
diff
changeset
|
663 from distutils.core import gen_usage |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
664 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
665 # User just wants a list of commands -- we'll print it out and stop |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
666 # processing now (ie. if they ran "setup --help-commands foo bar", |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
667 # we ignore "foo bar"). |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
668 if self.help_commands: |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
669 self.print_commands() |
|
55101
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
670 print('') |
|
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
671 print(gen_usage(self.script_name)) |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
672 return 1 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
673 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
674 # If user supplied any of the "display metadata" options, then |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
675 # display that metadata in the order in which the user supplied the |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
676 # metadata options. |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
677 any_display_options = 0 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
678 is_display_option = {} |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
679 for option in self.display_options: |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
680 is_display_option[option[0]] = 1 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
681 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
682 for (opt, val) in option_order: |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
683 if val and is_display_option.get(opt): |
|
14832
54adb7b4f8c8
Change to use the new 'translate_longopt()' function from fancy_getopt, rather
Greg Ward <gward@python.net>
parents:
14827
diff
changeset
|
684 opt = translate_longopt(opt) |
|
17127
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
685 value = getattr(self.metadata, "get_"+opt)() |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
686 if opt in ['keywords', 'platforms']: |
|
55101
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
687 print(','.join(value)) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
688 elif opt in ('classifiers', 'provides', 'requires', |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
689 'obsoletes'): |
|
55101
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
690 print('\n'.join(value)) |
|
17127
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
691 else: |
|
55101
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
692 print(value) |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
693 any_display_options = 1 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
694 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
695 return any_display_options |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
696 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
697 def print_command_list(self, commands, header, max_length): |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
698 """Print a subset of the list of all commands -- used by |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
699 'print_commands()'. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
700 """ |
|
55101
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
701 print(header + ":") |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
702 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
703 for cmd in commands: |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
704 klass = self.cmdclass.get(cmd) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
705 if not klass: |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
706 klass = self.get_command_class(cmd) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
707 try: |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
708 description = klass.description |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
709 except AttributeError: |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
710 description = "(no description available)" |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
711 |
|
55101
d11d899aab1d
using print statements when used for user interaction
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
55094
diff
changeset
|
712 print(" %-*s %s" % (max_length, cmd, description)) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
713 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
714 def print_commands(self): |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
715 """Print out a help message listing all available commands with a |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
716 description of each. The list is divided into "standard commands" |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
717 (listed in distutils.command.__all__) and "extra commands" |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
718 (mentioned in self.cmdclass, but not a standard command). The |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
719 descriptions come from the command class attribute |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
720 'description'. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
721 """ |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
722 import distutils.command |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
723 std_commands = distutils.command.__all__ |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
724 is_std = {} |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
725 for cmd in std_commands: |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
726 is_std[cmd] = 1 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
727 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
728 extra_commands = [] |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
729 for cmd in self.cmdclass.keys(): |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
730 if not is_std.get(cmd): |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
731 extra_commands.append(cmd) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
732 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
733 max_length = 0 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
734 for cmd in (std_commands + extra_commands): |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
735 if len(cmd) > max_length: |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
736 max_length = len(cmd) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
737 |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
738 self.print_command_list(std_commands, |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
739 "Standard commands", |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
740 max_length) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
741 if extra_commands: |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
742 print |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
743 self.print_command_list(extra_commands, |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
744 "Extra commands", |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
745 max_length) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
746 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
747 def get_command_list(self): |
|
15398
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
748 """Get a list of (command, description) tuples. |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
749 The list is divided into "standard commands" (listed in |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
750 distutils.command.__all__) and "extra commands" (mentioned in |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
751 self.cmdclass, but not a standard command). The descriptions come |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
752 from the command class attribute 'description'. |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
753 """ |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
754 # Currently this is only used on Mac OS, for the Mac-only GUI |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
755 # Distutils interface (by Jack Jansen) |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
756 |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
757 import distutils.command |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
758 std_commands = distutils.command.__all__ |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
759 is_std = {} |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
760 for cmd in std_commands: |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
761 is_std[cmd] = 1 |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
762 |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
763 extra_commands = [] |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
764 for cmd in self.cmdclass.keys(): |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
765 if not is_std.get(cmd): |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
766 extra_commands.append(cmd) |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
767 |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
768 rv = [] |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
769 for cmd in (std_commands + extra_commands): |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
770 klass = self.cmdclass.get(cmd) |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
771 if not klass: |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
772 klass = self.get_command_class(cmd) |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
773 try: |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
774 description = klass.description |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
775 except AttributeError: |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
776 description = "(no description available)" |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
777 rv.append((cmd, description)) |
|
3ab7faae803a
Jack Jansen: added 'get_command_list()' method, and Mac-specific code to
Greg Ward <gward@python.net>
parents:
15216
diff
changeset
|
778 return rv |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
779 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
780 # -- Command class/object methods ---------------------------------- |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
781 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
782 def get_command_packages(self): |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
783 """Return a list of packages from which commands are loaded.""" |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
784 pkgs = self.command_packages |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
785 if not isinstance(pkgs, list): |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
786 if pkgs is None: |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
787 pkgs = '' |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
788 pkgs = [pkg.strip() for pkg in pkgs.split(',') if pkg != ''] |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
789 if "distutils.command" not in pkgs: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
790 pkgs.insert(0, "distutils.command") |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
791 self.command_packages = pkgs |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
792 return pkgs |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
793 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
794 def get_command_class(self, command): |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
795 """Return the class that implements the Distutils command named by |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
796 'command'. First we check the 'cmdclass' dictionary; if the |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
797 command is mentioned there, we fetch the class object from the |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
798 dictionary and return it. Otherwise we load the command module |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
799 ("distutils.command." + command) and fetch the command class from |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
800 the module. The loaded class is also stored in 'cmdclass' |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
801 to speed future calls to 'get_command_class()'. |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
802 |
|
12673
5646773320be
Preliminary support for config files:
Gregory P. Smith <greg@mad-scientist.com>
parents:
12602
diff
changeset
|
803 Raises DistutilsModuleError if the expected module could not be |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
804 found, or if that module does not define the expected class. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
805 """ |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
806 klass = self.cmdclass.get(command) |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
807 if klass: |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
808 return klass |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
809 |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
810 for pkgname in self.get_command_packages(): |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
811 module_name = "%s.%s" % (pkgname, command) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
812 klass_name = command |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
813 |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
814 try: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
815 __import__ (module_name) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
816 module = sys.modules[module_name] |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
817 except ImportError: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
818 continue |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
819 |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
820 try: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
821 klass = getattr(module, klass_name) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
822 except AttributeError: |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
823 raise DistutilsModuleError, \ |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
824 "invalid command '%s' (no class '%s' in module '%s')" \ |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
825 % (command, klass_name, module_name) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
826 |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
827 self.cmdclass[command] = klass |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
828 return klass |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
829 |
|
32938
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
830 raise DistutilsModuleError("invalid command '%s'" % command) |
|
8ce344f6c954
This allows additional commands to be provided for existing setup.py
Fred Drake <fdrake@acm.org>
parents:
32736
diff
changeset
|
831 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
832 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
833 def get_command_obj(self, command, create=1): |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
834 """Return the command object for 'command'. Normally this object |
|
13725
449dd3a00bd7
Fixed a grab-bag of typos spotted by Rob Hooft.
Greg Ward <gward@python.net>
parents:
13413
diff
changeset
|
835 is cached on a previous call to 'get_command_obj()'; if no command |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
836 object for 'command' is in the cache, then we either create and |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
837 return it (if 'create' is true) or return None. |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
838 """ |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
839 cmd_obj = self.command_obj.get(command) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
840 if not cmd_obj and create: |
|
12826
7d2a0063e26d
Only print debugging output if DEBUG true (and deleted some of the more
Greg Ward <gward@python.net>
parents:
12822
diff
changeset
|
841 if DEBUG: |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
842 self.announce("Distribution.get_command_obj(): " \ |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
843 "creating '%s' command object" % command) |
|
12732
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
844 |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
845 klass = self.get_command_class(command) |
|
12732
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
846 cmd_obj = self.command_obj[command] = klass(self) |
|
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
847 self.have_run[command] = 0 |
|
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
848 |
|
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
849 # Set any options that were supplied in config files |
|
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
850 # or on the command line. (NB. support for error |
|
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
851 # reporting is lame here: any errors aren't reported |
|
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
852 # until 'finalize_options()' is called, which means |
|
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
853 # we won't report the source of the error.) |
|
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
854 options = self.command_options.get(command) |
|
7954ff93ee3b
Fixed so options from config files and command lines actually work:
Greg Ward <gward@python.net>
parents:
12726
diff
changeset
|
855 if options: |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
856 self._set_command_options(cmd_obj, options) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
857 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
858 return cmd_obj |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
859 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
860 def _set_command_options(self, command_obj, option_dict=None): |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
861 """Set the options for 'command_obj' from 'option_dict'. Basically |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
862 this means copying elements of a dictionary ('option_dict') to |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
863 attributes of an instance ('command'). |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
864 |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
865 'command_obj' must be a Command instance. If 'option_dict' is not |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
866 supplied, uses the standard option dictionary for this command |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
867 (from 'self.command_options'). |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
868 """ |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
869 command_name = command_obj.get_command_name() |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
870 if option_dict is None: |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
871 option_dict = self.get_option_dict(command_name) |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
872 |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
873 if DEBUG: |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
874 self.announce(" setting options for '%s' command:" % command_name) |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
875 for (option, (source, value)) in option_dict.items(): |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
876 if DEBUG: |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
877 self.announce(" %s = %s (from %s)" % (option, value, |
|
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
878 source)) |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
879 try: |
|
14832
54adb7b4f8c8
Change to use the new 'translate_longopt()' function from fancy_getopt, rather
Greg Ward <gward@python.net>
parents:
14827
diff
changeset
|
880 bool_opts = map(translate_longopt, command_obj.boolean_options) |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
881 except AttributeError: |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
882 bool_opts = [] |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
883 try: |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
884 neg_opt = command_obj.negative_opt |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
885 except AttributeError: |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
886 neg_opt = {} |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
887 |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
888 try: |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
889 is_string = isinstance(value, str) |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
34805
diff
changeset
|
890 if option in neg_opt and is_string: |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
891 setattr(command_obj, neg_opt[option], not strtobool(value)) |
|
14886
f657930fd274
Fix '_set_command_options()' so it only calls 'strtobool()' on strings
Greg Ward <gward@python.net>
parents:
14859
diff
changeset
|
892 elif option in bool_opts and is_string: |
|
14827
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
893 setattr(command_obj, option, strtobool(value)) |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
894 elif hasattr(command_obj, option): |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
895 setattr(command_obj, option, value) |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
896 else: |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
897 raise DistutilsOptionError, \ |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
898 ("error in %s: command '%s' has no such option '%s'" |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
899 % (source, command_name, option)) |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
900 except ValueError, msg: |
|
b1a0fb554456
Fixed some bugs and mis-features in handling config files:
Greg Ward <gward@python.net>
parents:
14629
diff
changeset
|
901 raise DistutilsOptionError, msg |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
902 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
903 def reinitialize_command(self, command, reinit_subcommands=0): |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
904 """Reinitializes a command to the state it was in when first |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
905 returned by 'get_command_obj()': ie., initialized but not yet |
| 13044 | 906 finalized. This provides the opportunity to sneak option |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
907 values in programmatically, overriding or supplementing |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
908 user-supplied values from the config files and command line. |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
909 You'll have to re-finalize the command object (by calling |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
910 'finalize_options()' or 'ensure_finalized()') before using it for |
| 21267 | 911 real. |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
912 |
|
14627
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
913 'command' should be a command name (string) or command object. If |
|
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
914 'reinit_subcommands' is true, also reinitializes the command's |
|
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
915 sub-commands, as declared by the 'sub_commands' class attribute (if |
|
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
916 it has one). See the "install" command for an example. Only |
|
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
917 reinitializes the sub-commands that actually matter, ie. those |
|
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
918 whose test predicates return true. |
|
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
919 |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
920 Returns the reinitialized command object. |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
921 """ |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
922 from distutils.cmd import Command |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
923 if not isinstance(command, Command): |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
924 command_name = command |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
925 command = self.get_command_obj(command_name) |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
926 else: |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
927 command_name = command.get_command_name() |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
928 |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
929 if not command.finalized: |
|
12811
b12ada2eb312
Oops, 'reinitialize_command()' forgot to return the command object if didn't
Greg Ward <gward@python.net>
parents:
12788
diff
changeset
|
930 return command |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
931 command.initialize_options() |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
932 command.finalized = 0 |
|
12863
c0fd88f2a65a
Fix 'reinitialize_command()' so it resets the 'have_run' flag for the
Greg Ward <gward@python.net>
parents:
12826
diff
changeset
|
933 self.have_run[command_name] = 0 |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
934 self._set_command_options(command) |
|
14627
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
935 |
|
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
936 if reinit_subcommands: |
|
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
937 for sub in command.get_sub_commands(): |
| 21267 | 938 self.reinitialize_command(sub, reinit_subcommands) |
|
14627
40595017a992
Generalized 'reinitialize_command()' so it can optionally reinitialize
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
939 |
|
12788
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
940 return command |
|
8004d29c77b8
Factored '_set_command_options()' out of 'get_command_obj()'.
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
941 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
942 # -- Methods that operate on the Distribution ---------------------- |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
943 |
|
55094
52aaa77a5dbf
Fixed #6413: fixed log level in distutils.dist.announce
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54497
diff
changeset
|
944 def announce(self, msg, level=log.INFO): |
|
52aaa77a5dbf
Fixed #6413: fixed log level in distutils.dist.announce
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54497
diff
changeset
|
945 log.log(level, msg) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
946 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
947 def run_commands(self): |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
948 """Run each command that was seen on the setup script command line. |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
949 Uses the list of commands found and cache of command objects |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
950 created by 'get_command_obj()'. |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
951 """ |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
952 for cmd in self.commands: |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
953 self.run_command(cmd) |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
954 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
955 # -- Methods that operate on its Commands -------------------------- |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
956 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
957 def run_command(self, command): |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
958 """Do whatever it takes to run a command (including nothing at all, |
|
12726
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
959 if the command has already been run). Specifically: if we have |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
960 already created and run the command named by 'command', return |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
961 silently without doing anything. If the command named by 'command' |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
962 doesn't even have a command object yet, create one. Then invoke |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
963 'run()' on that command object (or an existing one). |
|
5dd3b35bfd52
Marching towards full support of config files: thoroughly overhauled the
Greg Ward <gward@python.net>
parents:
12720
diff
changeset
|
964 """ |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
965 # Already been here, done that? then return silently. |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
966 if self.have_run.get(command): |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
967 return |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
968 |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21267
diff
changeset
|
969 log.info("running %s", command) |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
970 cmd_obj = self.get_command_obj(command) |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
971 cmd_obj.ensure_finalized() |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
972 cmd_obj.run() |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
973 self.have_run[command] = 1 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
974 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
975 |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
976 # -- Distribution query methods ------------------------------------ |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
977 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
978 def has_pure_modules(self): |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
979 return len(self.packages or self.py_modules or []) > 0 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
980 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
981 def has_ext_modules(self): |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
982 return self.ext_modules and len(self.ext_modules) > 0 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
983 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
984 def has_c_libraries(self): |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
985 return self.libraries and len(self.libraries) > 0 |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
986 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
987 def has_modules(self): |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
988 return self.has_pure_modules() or self.has_ext_modules() |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
989 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
990 def has_headers(self): |
|
12780
9335daa9ddd3
Support for the "install_headers" command: distribution option 'headers'
Greg Ward <gward@python.net>
parents:
12762
diff
changeset
|
991 return self.headers and len(self.headers) > 0 |
|
9335daa9ddd3
Support for the "install_headers" command: distribution option 'headers'
Greg Ward <gward@python.net>
parents:
12762
diff
changeset
|
992 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
993 def has_scripts(self): |
|
12720
2ea98d9dc669
Added 'has_scripts()', 'has_data_files()' methods.
Greg Ward <gward@python.net>
parents:
12719
diff
changeset
|
994 return self.scripts and len(self.scripts) > 0 |
|
2ea98d9dc669
Added 'has_scripts()', 'has_data_files()' methods.
Greg Ward <gward@python.net>
parents:
12719
diff
changeset
|
995 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
996 def has_data_files(self): |
|
12720
2ea98d9dc669
Added 'has_scripts()', 'has_data_files()' methods.
Greg Ward <gward@python.net>
parents:
12719
diff
changeset
|
997 return self.data_files and len(self.data_files) > 0 |
|
2ea98d9dc669
Added 'has_scripts()', 'has_data_files()' methods.
Greg Ward <gward@python.net>
parents:
12719
diff
changeset
|
998 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
999 def is_pure(self): |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1000 return (self.has_pure_modules() and |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1001 not self.has_ext_modules() and |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1002 not self.has_c_libraries()) |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1003 |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1004 # -- Metadata query methods ---------------------------------------- |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1005 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1006 # If you're looking for 'get_name()', 'get_version()', and so forth, |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1007 # they are defined in a sneaky way: the constructor binds self.get_XXX |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1008 # to self.metadata.get_XXX. The actual code is in the |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1009 # DistributionMetadata class, below. |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1010 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1011 class DistributionMetadata: |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1012 """Dummy class to hold the distribution meta-data: name, version, |
|
14859
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
1013 author, and so forth. |
|
e97660d1f1aa
Standardize whitespace in function calls and docstrings.
Greg Ward <gward@python.net>
parents:
14832
diff
changeset
|
1014 """ |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1015 |
|
19669
87e8fc0a9862
Don't use dir() to find instance attribute names.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
19139
diff
changeset
|
1016 _METHOD_BASENAMES = ("name", "version", "author", "author_email", |
|
87e8fc0a9862
Don't use dir() to find instance attribute names.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
19139
diff
changeset
|
1017 "maintainer", "maintainer_email", "url", |
|
87e8fc0a9862
Don't use dir() to find instance attribute names.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
19139
diff
changeset
|
1018 "license", "description", "long_description", |
|
87e8fc0a9862
Don't use dir() to find instance attribute names.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
19139
diff
changeset
|
1019 "keywords", "platforms", "fullname", "contact", |
|
28155
178d19cff163
[Bug #693470] 'licence' as an alias for 'license' doesn't work.
Andrew M. Kuchling <amk@amk.ca>
parents:
27975
diff
changeset
|
1020 "contact_email", "license", "classifiers", |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1021 "download_url", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1022 # PEP 314 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1023 "provides", "requires", "obsoletes", |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1024 ) |
|
19669
87e8fc0a9862
Don't use dir() to find instance attribute names.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
19139
diff
changeset
|
1025 |
|
57601
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1026 def __init__(self, path=None): |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1027 if path is not None: |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1028 self.read_pkg_file(open(path)) |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1029 else: |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1030 self.name = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1031 self.version = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1032 self.author = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1033 self.author_email = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1034 self.maintainer = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1035 self.maintainer_email = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1036 self.url = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1037 self.license = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1038 self.description = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1039 self.long_description = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1040 self.keywords = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1041 self.platforms = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1042 self.classifiers = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1043 self.download_url = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1044 # PEP 314 |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1045 self.provides = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1046 self.requires = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1047 self.obsoletes = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1048 |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1049 def read_pkg_file(self, file): |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1050 """Reads the metadata values from a file object.""" |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1051 msg = message_from_file(file) |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1052 |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1053 def _read_field(name): |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1054 value = msg[name] |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1055 if value == 'UNKNOWN': |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1056 return None |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1057 return value |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1058 |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1059 def _read_list(name): |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1060 values = msg.get_all(name, None) |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1061 if values == []: |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1062 return None |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1063 return values |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1064 |
|
57601
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1065 metadata_version = msg['metadata-version'] |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1066 self.name = _read_field('name') |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1067 self.version = _read_field('version') |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1068 self.description = _read_field('summary') |
|
57601
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1069 # we are filling author only. |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1070 self.author = _read_field('author') |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1071 self.maintainer = None |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1072 self.author_email = _read_field('author-email') |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1073 self.maintainer_email = None |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1074 self.url = _read_field('home-page') |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1075 self.license = _read_field('license') |
|
57601
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1076 |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1077 if 'download-url' in msg: |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1078 self.download_url = _read_field('download-url') |
|
57601
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1079 else: |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1080 self.download_url = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1081 |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1082 self.long_description = _read_field('description') |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1083 self.description = _read_field('summary') |
|
57601
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1084 |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1085 if 'keywords' in msg: |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1086 self.keywords = _read_field('keywords').split(',') |
| 21267 | 1087 |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1088 self.platforms = _read_list('platform') |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1089 self.classifiers = _read_list('classifier') |
|
57601
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1090 |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1091 # PEP 314 - these fields only exist in 1.1 |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1092 if metadata_version == '1.1': |
|
57603
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1093 self.requires = _read_list('requires') |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1094 self.provides = _read_list('provides') |
|
98879c8d53f1
removed the usage of rfc822 in favor of email.message.Message
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57601
diff
changeset
|
1095 self.obsoletes = _read_list('obsoletes') |
|
57601
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1096 else: |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1097 self.requires = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1098 self.provides = None |
|
25aede62fc17
Issue #7457: added a read_pkg_file method to distutils.dist.DistributionMetadata so we can read back PKG-INFO files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56923
diff
changeset
|
1099 self.obsoletes = None |
| 21267 | 1100 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
1101 def write_pkg_info(self, base_dir): |
|
17127
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
1102 """Write the PKG-INFO file into the release tree. |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
1103 """ |
|
66008
a17b21c27a33
Merged revisions 86223-86224,86226,86234 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
58462
diff
changeset
|
1104 pkg_info = open(os.path.join(base_dir, 'PKG-INFO'), 'w') |
|
a17b21c27a33
Merged revisions 86223-86224,86226,86234 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
58462
diff
changeset
|
1105 try: |
|
a17b21c27a33
Merged revisions 86223-86224,86226,86234 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
58462
diff
changeset
|
1106 self.write_pkg_file(pkg_info) |
|
a17b21c27a33
Merged revisions 86223-86224,86226,86234 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
58462
diff
changeset
|
1107 finally: |
|
a17b21c27a33
Merged revisions 86223-86224,86226,86234 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
58462
diff
changeset
|
1108 pkg_info.close() |
|
27048
554121fcbb9d
[Patch #658094] PEP 301 implementation
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
1109 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
1110 def write_pkg_file(self, file): |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1111 """Write the PKG-INFO format data to a file object. |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1112 """ |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1113 version = '1.0' |
|
72362
4b72d56cf42f
Fix determination of Metadata version (#8933). Patch by Filip Gruszczyński.
Éric Araujo <merwok@netwok.org>
parents:
68256
diff
changeset
|
1114 if (self.provides or self.requires or self.obsoletes or |
|
4b72d56cf42f
Fix determination of Metadata version (#8933). Patch by Filip Gruszczyński.
Éric Araujo <merwok@netwok.org>
parents:
68256
diff
changeset
|
1115 self.classifiers or self.download_url): |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1116 version = '1.1' |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1117 |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1118 self._write_field(file, 'Metadata-Version', version) |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1119 self._write_field(file, 'Name', self.get_name()) |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1120 self._write_field(file, 'Version', self.get_version()) |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1121 self._write_field(file, 'Summary', self.get_description()) |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1122 self._write_field(file, 'Home-page', self.get_url()) |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1123 self._write_field(file, 'Author', self.get_contact()) |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1124 self._write_field(file, 'Author-email', self.get_contact_email()) |
|
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1125 self._write_field(file, 'License', self.get_license()) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1126 if self.download_url: |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1127 self._write_field(file, 'Download-URL', self.download_url) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1128 |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
1129 long_desc = rfc822_escape(self.get_long_description()) |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1130 self._write_field(file, 'Description', long_desc) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1131 |
|
54497
d5071d9f7408
improved distutils.dist test coverage, pep-8 compliancy
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54149
diff
changeset
|
1132 keywords = ','.join(self.get_keywords()) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1133 if keywords: |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1134 self._write_field(file, 'Keywords', keywords) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1135 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1136 self._write_list(file, 'Platform', self.get_platforms()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1137 self._write_list(file, 'Classifier', self.get_classifiers()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1138 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1139 # PEP 314 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1140 self._write_list(file, 'Requires', self.get_requires()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1141 self._write_list(file, 'Provides', self.get_provides()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1142 self._write_list(file, 'Obsoletes', self.get_obsoletes()) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1143 |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1144 def _write_field(self, file, name, value): |
|
58464
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1145 file.write('%s: %s\n' % (name, self._encode_field(value))) |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1146 |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1147 def _write_list (self, file, name, values): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1148 for value in values: |
|
48981
4c683ec4415b
Issue #2562: Fix distutils PKG-INFO writing logic to allow having
Marc-André Lemburg <mal@egenix.com>
parents:
47252
diff
changeset
|
1149 self._write_field(file, name, value) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1150 |
|
58464
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1151 def _encode_field(self, value): |
|
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1152 if value is None: |
|
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1153 return None |
|
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1154 if isinstance(value, unicode): |
|
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1155 return value.encode(PKG_INFO_ENCODING) |
|
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1156 return str(value) |
|
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1157 |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1158 # -- Metadata query methods ---------------------------------------- |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1159 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
1160 def get_name(self): |
|
12225
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1161 return self.name or "UNKNOWN" |
|
c405dbdd26c9
Reorganization: moved the Distribution class from core.py to dist.py, and
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1162 |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1163 def get_version(self): |
|
21266
4dae842aa7c5
Use a version number of 0.0.0 instead of ???. The latter leads to
Thomas Heller <theller@ctypes.org>
parents:
21257
diff
changeset
|
1164 return self.version or "0.0.0" |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1165 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
1166 def get_fullname(self): |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1167 return "%s-%s" % (self.get_name(), self.get_version()) |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1168 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1169 def get_author(self): |
|
58464
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1170 return self._encode_field(self.author) or "UNKNOWN" |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1171 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1172 def get_author_email(self): |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1173 return self.author_email or "UNKNOWN" |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1174 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1175 def get_maintainer(self): |
|
58464
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1176 return self._encode_field(self.maintainer) or "UNKNOWN" |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1177 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1178 def get_maintainer_email(self): |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1179 return self.maintainer_email or "UNKNOWN" |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1180 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1181 def get_contact(self): |
|
58464
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1182 return (self._encode_field(self.maintainer) or |
|
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1183 self._encode_field(self.author) or "UNKNOWN") |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1184 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1185 def get_contact_email(self): |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
1186 return self.maintainer_email or self.author_email or "UNKNOWN" |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1187 |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1188 def get_url(self): |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1189 return self.url or "UNKNOWN" |
|
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1190 |
|
19137
fb12ea9290b2
[Bug #412271, bug #449009] Use 'license' as the attribute name,
Andrew M. Kuchling <amk@amk.ca>
parents:
17271
diff
changeset
|
1191 def get_license(self): |
|
fb12ea9290b2
[Bug #412271, bug #449009] Use 'license' as the attribute name,
Andrew M. Kuchling <amk@amk.ca>
parents:
17271
diff
changeset
|
1192 return self.license or "UNKNOWN" |
|
fb12ea9290b2
[Bug #412271, bug #449009] Use 'license' as the attribute name,
Andrew M. Kuchling <amk@amk.ca>
parents:
17271
diff
changeset
|
1193 get_licence = get_license |
| 21267 | 1194 |
|
12427
978c9687beef
Patch, originally from Bastian Kleineidam and savagely mutilated by me,
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
1195 def get_description(self): |
|
58464
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1196 return self._encode_field(self.description) or "UNKNOWN" |
|
12496
2a53a3a47962
Harry Henry Gebel: add 'long_description' to DistributionMetadata.
Greg Ward <gward@python.net>
parents:
12448
diff
changeset
|
1197 |
|
2a53a3a47962
Harry Henry Gebel: add 'long_description' to DistributionMetadata.
Greg Ward <gward@python.net>
parents:
12448
diff
changeset
|
1198 def get_long_description(self): |
|
58464
3947fdca2f40
Merged revisions 77717 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50366
diff
changeset
|
1199 return self._encode_field(self.long_description) or "UNKNOWN" |
|
12496
2a53a3a47962
Harry Henry Gebel: add 'long_description' to DistributionMetadata.
Greg Ward <gward@python.net>
parents:
12448
diff
changeset
|
1200 |
|
17127
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
1201 def get_keywords(self): |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
1202 return self.keywords or [] |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
1203 |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
1204 def get_platforms(self): |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
1205 return self.platforms or ["UNKNOWN"] |
|
54b6d28a6878
Add 'platforms' and 'keywords' attributes to the DistributionMetadata class,
Andrew M. Kuchling <amk@amk.ca>
parents:
17064
diff
changeset
|
1206 |
|
27048
554121fcbb9d
[Patch #658094] PEP 301 implementation
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
1207 def get_classifiers(self): |
|
554121fcbb9d
[Patch #658094] PEP 301 implementation
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
1208 return self.classifiers or [] |
|
554121fcbb9d
[Patch #658094] PEP 301 implementation
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
1209 |
|
27975
cc95bb7870dc
[Patch #683939] Add download_url field to metadata
Andrew M. Kuchling <amk@amk.ca>
parents:
27048
diff
changeset
|
1210 def get_download_url(self): |
|
cc95bb7870dc
[Patch #683939] Add download_url field to metadata
Andrew M. Kuchling <amk@amk.ca>
parents:
27048
diff
changeset
|
1211 return self.download_url or "UNKNOWN" |
|
cc95bb7870dc
[Patch #683939] Add download_url field to metadata
Andrew M. Kuchling <amk@amk.ca>
parents:
27048
diff
changeset
|
1212 |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1213 # PEP 314 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1214 def get_requires(self): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1215 return self.requires or [] |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1216 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1217 def set_requires(self, value): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1218 import distutils.versionpredicate |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1219 for v in value: |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1220 distutils.versionpredicate.VersionPredicate(v) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1221 self.requires = value |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1222 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1223 def get_provides(self): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1224 return self.provides or [] |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1225 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1226 def set_provides(self, value): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1227 value = [v.strip() for v in value] |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1228 for v in value: |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1229 import distutils.versionpredicate |
|
34788
b14c8e6310e7
- rename check_provision() to split_revision()
Fred Drake <fdrake@acm.org>
parents:
34785
diff
changeset
|
1230 distutils.versionpredicate.split_provision(v) |
|
34785
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1231 self.provides = value |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1232 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1233 def get_obsoletes(self): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1234 return self.obsoletes or [] |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1235 |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1236 def set_obsoletes(self, value): |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1237 import distutils.versionpredicate |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1238 for v in value: |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1239 distutils.versionpredicate.VersionPredicate(v) |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1240 self.obsoletes = value |
|
dc6f315f1f7f
PEP 314 implementation (client side):
Fred Drake <fdrake@acm.org>
parents:
34648
diff
changeset
|
1241 |
|
54114
f1bf538786b7
pep8-fied distutils.dist module
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54101
diff
changeset
|
1242 def fix_help_options(options): |
|
12997
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
1243 """Convert a 4-tuple 'help_options' list as found in various command |
|
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
1244 classes to the 3-tuple form required by FancyGetopt. |
|
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
1245 """ |
|
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
1246 new_options = [] |
|
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
1247 for help_tuple in options: |
|
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
1248 new_options.append(help_tuple[0:3]) |
|
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
1249 return new_options |
