Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/command/install_lib.py @ 51749:1408feec0084 3.0
Merged revisions 69798 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r69798 | benjamin.peterson | 2009-02-19 22:02:38 -0600 (Thu, 19 Feb 2009) | 13 lines
Merged revisions 69769,69776 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69769 | georg.brandl | 2009-02-19 02:30:06 -0600 (Thu, 19 Feb 2009) | 1 line
#5310, #3558: fix operator precedence table.
........
r69776 | georg.brandl | 2009-02-19 10:34:51 -0600 (Thu, 19 Feb 2009) | 2 lines
#5317: update IronPython URL.
........
................
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Fri, 20 Feb 2009 04:05:32 +0000 |
| parents | a6d3930b5613 |
| children | 258219646e3a e67dc4db964c |
| rev | line source |
|---|---|
|
11897
017e592c0fd2
Changed '__rcsid__' to '__revision__'.
Greg Ward <gward@python.net>
parents:
11859
diff
changeset
|
1 __revision__ = "$Id$" |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
2 |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
34082
diff
changeset
|
3 import sys, os |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
4 from distutils.core import Command |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
5 from distutils.errors import DistutilsOptionError |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
6 |
|
32841
0856d98e2a68
Since build_py handles package data installation, the list of outputs
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
7 |
|
0856d98e2a68
Since build_py handles package data installation, the list of outputs
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
8 # Extension for Python source files. |
| 42622 | 9 PYTHON_SOURCE_EXTENSION = ".py" |
|
32841
0856d98e2a68
Since build_py handles package data installation, the list of outputs
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
10 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
11 class install_lib(Command): |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
12 |
| 12730 | 13 description = "install all Python modules (extensions and pure Python)" |
|
11683
47f75a17b103
Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents:
11680
diff
changeset
|
14 |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
15 # The byte-compilation options are a tad confusing. Here are the |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
16 # possible scenarios: |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
17 # 1) no compilation at all (--no-compile --no-optimize) |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
18 # 2) compile .pyc only (--compile --no-optimize; default) |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
19 # 3) compile .pyc and "level 1" .pyo (--compile --optimize) |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
20 # 4) compile "level 1" .pyo only (--no-compile --optimize) |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
21 # 5) compile .pyc and "level 2" .pyo (--compile --optimize-more) |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
22 # 6) compile "level 2" .pyo only (--no-compile --optimize-more) |
| 21268 | 23 # |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
24 # The UI for this is two option, 'compile' and 'optimize'. |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
25 # 'compile' is strictly boolean, and only decides whether to |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
26 # generate .pyc files. 'optimize' is three-way (0, 1, or 2), and |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
27 # decides both whether to generate .pyo files and what level of |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
28 # optimization to use. |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
29 |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
30 user_options = [ |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
31 ('install-dir=', 'd', "directory to install to"), |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
32 ('build-dir=','b', "build directory (where to install from)"), |
|
14540
35ae8dff8ed0
Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
33 ('force', 'f', "force installation (overwrite existing files)"), |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
34 ('compile', 'c', "compile .py to .pyc [default]"), |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
35 ('no-compile', None, "don't compile .py files"), |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
36 ('optimize=', 'O', |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
37 "also compile with optimization: -O1 for \"python -O\", " |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
38 "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"), |
|
12680
b89da202d18d
Added --skip-build option, so lazy debuggers/testers (mainly me) don't
Gregory P. Smith <greg@mad-scientist.com>
parents:
12603
diff
changeset
|
39 ('skip-build', None, "skip the build steps"), |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
40 ] |
| 21268 | 41 |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
42 boolean_options = ['force', 'compile', 'skip-build'] |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
43 negative_opt = {'no-compile' : 'compile'} |
|
14829
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14780
diff
changeset
|
44 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
45 def initialize_options(self): |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
46 # let the 'install' command dictate our installation directory |
|
11338
42941e2eb9d8
Renamed many options to be consistent across commands.
Greg Ward <gward@python.net>
parents:
11283
diff
changeset
|
47 self.install_dir = None |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
48 self.build_dir = None |
|
14540
35ae8dff8ed0
Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents:
13871
diff
changeset
|
49 self.force = 0 |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
50 self.compile = None |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
51 self.optimize = None |
|
12680
b89da202d18d
Added --skip-build option, so lazy debuggers/testers (mainly me) don't
Gregory P. Smith <greg@mad-scientist.com>
parents:
12603
diff
changeset
|
52 self.skip_build = None |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
53 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
54 def finalize_options(self): |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
55 |
|
11283
cdd928d2293c
Changed selection of installation directories (in 'set_final_options()')
Greg Ward <gward@python.net>
parents:
11248
diff
changeset
|
56 # Get all the information we need to install pure Python modules |
|
cdd928d2293c
Changed selection of installation directories (in 'set_final_options()')
Greg Ward <gward@python.net>
parents:
11248
diff
changeset
|
57 # from the umbrella 'install' command -- build (source) directory, |
|
cdd928d2293c
Changed selection of installation directories (in 'set_final_options()')
Greg Ward <gward@python.net>
parents:
11248
diff
changeset
|
58 # install (target) directory, and whether to compile .py files. |
| 14779 | 59 self.set_undefined_options('install', |
| 60 ('build_lib', 'build_dir'), | |
| 61 ('install_lib', 'install_dir'), | |
| 62 ('force', 'force'), | |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
63 ('compile', 'compile'), |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
64 ('optimize', 'optimize'), |
| 14779 | 65 ('skip_build', 'skip_build'), |
| 66 ) | |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
67 |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
68 if self.compile is None: |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
69 self.compile = True |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
70 if self.optimize is None: |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
71 self.optimize = False |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
72 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
73 if not isinstance(self.optimize, int): |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
74 try: |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
75 self.optimize = int(self.optimize) |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
76 assert 0 <= self.optimize <= 2 |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
77 except (ValueError, AssertionError): |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
78 raise DistutilsOptionError("optimize must be 0, 1, or 2") |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
79 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
80 def run(self): |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
81 # Make sure we have built everything we need first |
|
14780
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
82 self.build() |
| 21268 | 83 |
|
14780
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
84 # Install everything: simply dump the entire contents of the build |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
85 # directory to the installation directory (that's the beauty of |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
86 # having a build directory!) |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
87 outfiles = self.install() |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
88 |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
89 # (Optionally) compile .py to .pyc |
|
14959
b031abca3e91
From 'run()', only call 'bytecompile()' if we actually have
Greg Ward <gward@python.net>
parents:
14952
diff
changeset
|
90 if outfiles is not None and self.distribution.has_pure_modules(): |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
91 self.byte_compile(outfiles) |
|
14780
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
92 |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
93 |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
94 # -- Top-level worker functions ------------------------------------ |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
95 # (called from 'run()') |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
96 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
97 def build(self): |
|
12680
b89da202d18d
Added --skip-build option, so lazy debuggers/testers (mainly me) don't
Gregory P. Smith <greg@mad-scientist.com>
parents:
12603
diff
changeset
|
98 if not self.skip_build: |
|
b89da202d18d
Added --skip-build option, so lazy debuggers/testers (mainly me) don't
Gregory P. Smith <greg@mad-scientist.com>
parents:
12603
diff
changeset
|
99 if self.distribution.has_pure_modules(): |
| 14779 | 100 self.run_command('build_py') |
|
12680
b89da202d18d
Added --skip-build option, so lazy debuggers/testers (mainly me) don't
Gregory P. Smith <greg@mad-scientist.com>
parents:
12603
diff
changeset
|
101 if self.distribution.has_ext_modules(): |
| 14779 | 102 self.run_command('build_ext') |
| 21268 | 103 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
104 def install(self): |
|
12721
a598ace01943
Check if the claimed build directory doesn't exist, and warn that we don't
Greg Ward <gward@python.net>
parents:
12696
diff
changeset
|
105 if os.path.isdir(self.build_dir): |
| 14779 | 106 outfiles = self.copy_tree(self.build_dir, self.install_dir) |
|
12721
a598ace01943
Check if the claimed build directory doesn't exist, and warn that we don't
Greg Ward <gward@python.net>
parents:
12696
diff
changeset
|
107 else: |
|
a598ace01943
Check if the claimed build directory doesn't exist, and warn that we don't
Greg Ward <gward@python.net>
parents:
12696
diff
changeset
|
108 self.warn("'%s' does not exist -- no Python modules to install" % |
|
a598ace01943
Check if the claimed build directory doesn't exist, and warn that we don't
Greg Ward <gward@python.net>
parents:
12696
diff
changeset
|
109 self.build_dir) |
|
a598ace01943
Check if the claimed build directory doesn't exist, and warn that we don't
Greg Ward <gward@python.net>
parents:
12696
diff
changeset
|
110 return |
|
14780
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
111 return outfiles |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
112 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
113 def byte_compile(self, files): |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
114 from distutils.util import byte_compile |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
115 |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
116 # Get the "--root" directory supplied to the "install" command, |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
117 # and use it as a prefix to strip off the purported filename |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
118 # encoded in bytecode files. This is far from complete, but it |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
119 # should at least generate usable bytecode in RPM distributions. |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
120 install_root = self.get_finalized_command('install').root |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
121 |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
122 if self.compile: |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
123 byte_compile(files, optimize=0, |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23587
diff
changeset
|
124 force=self.force, prefix=install_root, |
|
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23587
diff
changeset
|
125 dry_run=self.dry_run) |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
126 if self.optimize > 0: |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
127 byte_compile(files, optimize=self.optimize, |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23587
diff
changeset
|
128 force=self.force, prefix=install_root, |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
129 verbose=self.verbose, dry_run=self.dry_run) |
|
14780
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
130 |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
131 |
|
14780
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
132 # -- Utility methods ----------------------------------------------- |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
133 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
134 def _mutate_outputs(self, has_any, build_cmd, cmd_option, output_dir): |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
135 if not has_any: |
|
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
136 return [] |
|
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
137 |
| 14779 | 138 build_cmd = self.get_finalized_command(build_cmd) |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
139 build_files = build_cmd.get_outputs() |
| 14779 | 140 build_dir = getattr(build_cmd, cmd_option) |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
141 |
| 14779 | 142 prefix_len = len(build_dir) + len(os.sep) |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
143 outputs = [] |
|
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
144 for file in build_files: |
| 14779 | 145 outputs.append(os.path.join(output_dir, file[prefix_len:])) |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
146 |
|
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
147 return outputs |
|
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
148 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
149 def _bytecode_filenames(self, py_filenames): |
|
12696
a49e450688e2
Added '_bytecode_filenames()' method, and use it in 'get_outputs()'
Gregory P. Smith <greg@mad-scientist.com>
parents:
12680
diff
changeset
|
150 bytecode_files = [] |
|
a49e450688e2
Added '_bytecode_filenames()' method, and use it in 'get_outputs()'
Gregory P. Smith <greg@mad-scientist.com>
parents:
12680
diff
changeset
|
151 for py_file in py_filenames: |
|
32841
0856d98e2a68
Since build_py handles package data installation, the list of outputs
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
152 # Since build_py handles package data installation, the |
|
0856d98e2a68
Since build_py handles package data installation, the list of outputs
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
153 # list of outputs can contain more than just .py files. |
|
0856d98e2a68
Since build_py handles package data installation, the list of outputs
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
154 # Make sure we only report bytecode for the .py files. |
|
0856d98e2a68
Since build_py handles package data installation, the list of outputs
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
155 ext = os.path.splitext(os.path.normcase(py_file))[1] |
|
0856d98e2a68
Since build_py handles package data installation, the list of outputs
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
156 if ext != PYTHON_SOURCE_EXTENSION: |
|
0856d98e2a68
Since build_py handles package data installation, the list of outputs
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
157 continue |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
158 if self.compile: |
|
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
159 bytecode_files.append(py_file + "c") |
| 14964 | 160 if self.optimize > 0: |
|
14961
ebaeb19e0380
Finished the overhaul of byte-compilation options: there's now a 6-way
Greg Ward <gward@python.net>
parents:
14959
diff
changeset
|
161 bytecode_files.append(py_file + "o") |
|
12696
a49e450688e2
Added '_bytecode_filenames()' method, and use it in 'get_outputs()'
Gregory P. Smith <greg@mad-scientist.com>
parents:
12680
diff
changeset
|
162 |
|
a49e450688e2
Added '_bytecode_filenames()' method, and use it in 'get_outputs()'
Gregory P. Smith <greg@mad-scientist.com>
parents:
12680
diff
changeset
|
163 return bytecode_files |
| 21268 | 164 |
|
14780
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
165 |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
166 # -- External interface -------------------------------------------- |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
167 # (called by outsiders) |
|
064e434e744f
Split 'run()' up into 'build()', 'install()', and 'bytecompile()' (for
Greg Ward <gward@python.net>
parents:
14779
diff
changeset
|
168 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
169 def get_outputs(self): |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
170 """Return the list of files that would be installed if this command |
|
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
171 were actually run. Not affected by the "dry-run" flag or whether |
| 14779 | 172 modules have actually been built yet. |
| 173 """ | |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
174 pure_outputs = \ |
| 14779 | 175 self._mutate_outputs(self.distribution.has_pure_modules(), |
| 176 'build_py', 'build_lib', | |
| 177 self.install_dir) | |
|
12696
a49e450688e2
Added '_bytecode_filenames()' method, and use it in 'get_outputs()'
Gregory P. Smith <greg@mad-scientist.com>
parents:
12680
diff
changeset
|
178 if self.compile: |
|
a49e450688e2
Added '_bytecode_filenames()' method, and use it in 'get_outputs()'
Gregory P. Smith <greg@mad-scientist.com>
parents:
12680
diff
changeset
|
179 bytecode_outputs = self._bytecode_filenames(pure_outputs) |
|
a49e450688e2
Added '_bytecode_filenames()' method, and use it in 'get_outputs()'
Gregory P. Smith <greg@mad-scientist.com>
parents:
12680
diff
changeset
|
180 else: |
|
a49e450688e2
Added '_bytecode_filenames()' method, and use it in 'get_outputs()'
Gregory P. Smith <greg@mad-scientist.com>
parents:
12680
diff
changeset
|
181 bytecode_outputs = [] |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
182 |
|
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
183 ext_outputs = \ |
| 14779 | 184 self._mutate_outputs(self.distribution.has_ext_modules(), |
| 185 'build_ext', 'build_lib', | |
| 186 self.install_dir) | |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
187 |
|
12696
a49e450688e2
Added '_bytecode_filenames()' method, and use it in 'get_outputs()'
Gregory P. Smith <greg@mad-scientist.com>
parents:
12680
diff
changeset
|
188 return pure_outputs + bytecode_outputs + ext_outputs |
|
12098
881257d1e854
Be sure to run both 'build_py' and 'build_ext', now that this command
Greg Ward <gward@python.net>
parents:
12042
diff
changeset
|
189 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42622
diff
changeset
|
190 def get_inputs(self): |
| 12154 | 191 """Get the list of files that are input to this command, ie. the |
| 192 files that get installed as they are named in the build tree. | |
| 193 The files in this list correspond one-to-one to the output | |
| 14779 | 194 filenames returned by 'get_outputs()'. |
| 195 """ | |
| 12154 | 196 inputs = [] |
| 21268 | 197 |
| 12154 | 198 if self.distribution.has_pure_modules(): |
| 14779 | 199 build_py = self.get_finalized_command('build_py') |
| 200 inputs.extend(build_py.get_outputs()) | |
| 12154 | 201 |
| 202 if self.distribution.has_ext_modules(): | |
| 14779 | 203 build_ext = self.get_finalized_command('build_ext') |
| 204 inputs.extend(build_ext.get_outputs()) | |
| 12154 | 205 |
| 206 return inputs |
