Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/command/install_scripts.py @ 27998:e27f58a50737 legacy-trunk
SF bug #690377: Dud footnote reference in distutils docs
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 21 Feb 2003 02:47:09 +0000 |
| parents | dd817bb3646b |
| children | 893d46576737 |
| rev | line source |
|---|---|
|
12682
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
1 """distutils.command.install_scripts |
|
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
2 |
|
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
3 Implements the Distutils 'install_scripts' command, for installing |
|
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
4 Python scripts.""" |
|
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
5 |
|
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
6 # contributed by Bastian Kleineidam |
|
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
7 |
|
26285
42bfc98d295b
Add comment to Distutil files about requiring 1.5.2 compatibility, as
Andrew M. Kuchling <amk@amk.ca>
parents:
23672
diff
changeset
|
8 # This module should be kept compatible with Python 1.5.2. |
|
42bfc98d295b
Add comment to Distutil files about requiring 1.5.2 compatibility, as
Andrew M. Kuchling <amk@amk.ca>
parents:
23672
diff
changeset
|
9 |
|
12682
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
10 __revision__ = "$Id$" |
|
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
11 |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
12 import os |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
13 from distutils.core import Command |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21852
diff
changeset
|
14 from distutils import log |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
15 from stat import ST_MODE |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
16 |
|
12778
0263a99d0eb2
Tweaked description, help text.
Greg Ward <gward@python.net>
parents:
12744
diff
changeset
|
17 class install_scripts (Command): |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
18 |
|
12778
0263a99d0eb2
Tweaked description, help text.
Greg Ward <gward@python.net>
parents:
12744
diff
changeset
|
19 description = "install scripts (Python or otherwise)" |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
20 |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
21 user_options = [ |
|
12778
0263a99d0eb2
Tweaked description, help text.
Greg Ward <gward@python.net>
parents:
12744
diff
changeset
|
22 ('install-dir=', 'd', "directory to install scripts to"), |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
23 ('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:
12783
diff
changeset
|
24 ('force', 'f', "force installation (overwrite existing files)"), |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
25 ('skip-build', None, "skip the build steps"), |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
26 ] |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
27 |
|
14829
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14540
diff
changeset
|
28 boolean_options = ['force', 'skip-build'] |
|
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14540
diff
changeset
|
29 |
|
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14540
diff
changeset
|
30 |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
31 def initialize_options (self): |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
32 self.install_dir = None |
|
14540
35ae8dff8ed0
Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
33 self.force = 0 |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
34 self.build_dir = None |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
35 self.skip_build = None |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
36 |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
37 def finalize_options (self): |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
38 self.set_undefined_options('build', ('build_scripts', 'build_dir')) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
39 self.set_undefined_options('install', |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
40 ('install_scripts', 'install_dir'), |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
41 ('force', 'force'), |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
42 ('skip_build', 'skip_build'), |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
43 ) |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
44 |
|
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
45 def run (self): |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
46 if not self.skip_build: |
|
12783
b91b35c1d4c0
Some far-reaching naming changes:
Greg Ward <gward@python.net>
parents:
12778
diff
changeset
|
47 self.run_command('build_scripts') |
|
14540
35ae8dff8ed0
Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
48 self.outfiles = self.copy_tree(self.build_dir, self.install_dir) |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
49 if os.name == 'posix': |
|
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
50 # Set the executable bits (owner, group, and world) on |
|
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
51 # all the scripts we just installed. |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
52 for file in self.get_outputs(): |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
53 if self.dry_run: |
|
23672
edc423940cd6
Fix bug in recent change to logging code.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
54 log.info("changing mode of %s", file) |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
55 else: |
|
26459
dd817bb3646b
Fix mode on scripts to have the read bit set (noted by Nicholas Riley)
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
56 mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777 |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21852
diff
changeset
|
57 log.info("changing mode of %s to %o", file, mode) |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
58 os.chmod(file, mode) |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
59 |
|
12702
58ad6196d81f
Added 'get_inputs()' methods, needed by the "install" command's
Gregory P. Smith <greg@mad-scientist.com>
parents:
12682
diff
changeset
|
60 def get_inputs (self): |
|
58ad6196d81f
Added 'get_inputs()' methods, needed by the "install" command's
Gregory P. Smith <greg@mad-scientist.com>
parents:
12682
diff
changeset
|
61 return self.distribution.scripts or [] |
|
58ad6196d81f
Added 'get_inputs()' methods, needed by the "install" command's
Gregory P. Smith <greg@mad-scientist.com>
parents:
12682
diff
changeset
|
62 |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
63 def get_outputs(self): |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
64 return self.outfiles or [] |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
65 |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
66 # class install_scripts |
