Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/command/install_scripts.py @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | a5229237eb50 |
| children |
| 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 |
|
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
8 __revision__ = "$Id$" |
|
7c89ee40730f
Added comment/docstring/revision header.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12678
diff
changeset
|
9 |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
10 import os |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
11 from distutils.core import Command |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21852
diff
changeset
|
12 from distutils import log |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
13 from stat import ST_MODE |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
14 |
|
12778
0263a99d0eb2
Tweaked description, help text.
Greg Ward <gward@python.net>
parents:
12744
diff
changeset
|
15 class install_scripts (Command): |
|
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 description = "install scripts (Python or otherwise)" |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
18 |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
19 user_options = [ |
|
12778
0263a99d0eb2
Tweaked description, help text.
Greg Ward <gward@python.net>
parents:
12744
diff
changeset
|
20 ('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
|
21 ('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
|
22 ('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
|
23 ('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
|
24 ] |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
25 |
|
14829
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14540
diff
changeset
|
26 boolean_options = ['force', 'skip-build'] |
|
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14540
diff
changeset
|
27 |
|
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14540
diff
changeset
|
28 |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
29 def initialize_options (self): |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
30 self.install_dir = None |
|
14540
35ae8dff8ed0
Added --force (-f) option to force installation (including bytecode
Greg Ward <gward@python.net>
parents:
12783
diff
changeset
|
31 self.force = 0 |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
32 self.build_dir = None |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
33 self.skip_build = None |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
34 |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
35 def finalize_options (self): |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
36 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
|
37 self.set_undefined_options('install', |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
38 ('install_scripts', 'install_dir'), |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
39 ('force', 'force'), |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
40 ('skip_build', 'skip_build'), |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
41 ) |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
42 |
|
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
43 def run (self): |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
44 if not self.skip_build: |
|
12783
b91b35c1d4c0
Some far-reaching naming changes:
Greg Ward <gward@python.net>
parents:
12778
diff
changeset
|
45 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
|
46 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
|
47 if os.name == 'posix': |
|
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
48 # Set the executable bits (owner, group, and world) on |
|
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
49 # 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
|
50 for file in self.get_outputs(): |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
51 if self.dry_run: |
|
23672
edc423940cd6
Fix bug in recent change to logging code.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
52 log.info("changing mode of %s", file) |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
53 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
|
54 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
|
55 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
|
56 os.chmod(file, mode) |
|
12675
de435a59a4d5
Patch from Bastien Kleineidam:
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
57 |
|
12702
58ad6196d81f
Added 'get_inputs()' methods, needed by the "install" command's
Gregory P. Smith <greg@mad-scientist.com>
parents:
12682
diff
changeset
|
58 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
|
59 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
|
60 |
|
12744
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
61 def get_outputs(self): |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
62 return self.outfiles or [] |
|
eeafab8c925b
Bastian Kleineidam: the "build_scripts" command and changes
Greg Ward <gward@python.net>
parents:
12702
diff
changeset
|
63 |
|
12678
875e677236a7
Deleted some cruft.
Gregory P. Smith <greg@mad-scientist.com>
parents:
12675
diff
changeset
|
64 # class install_scripts |
