]> git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/command/bdist_dumb.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / distutils / command / bdist_dumb.py
1 """distutils.command.bdist_dumb
2
3 Implements the Distutils 'bdist_dumb' command (create a "dumb" built
4 distribution -- i.e., just an archive to be unpacked under $prefix or
5 $exec_prefix)."""
6
7 __revision__ = "$Id$"
8
9 import os
10
11 from sysconfig import get_python_version
12
13 from distutils.util import get_platform
14 from distutils.core import Command
15 from distutils.dir_util import remove_tree, ensure_relative
16 from distutils.errors import DistutilsPlatformError
17 from distutils import log
18
19 class bdist_dumb (Command):
20
21 description = 'create a "dumb" built distribution'
22
23 user_options = [('bdist-dir=', 'd',
24 "temporary directory for creating the distribution"),
25 ('plat-name=', 'p',
26 "platform name to embed in generated filenames "
27 "(default: %s)" % get_platform()),
28 ('format=', 'f',
29 "archive format to create (tar, ztar, gztar, zip)"),
30 ('keep-temp', 'k',
31 "keep the pseudo-installation tree around after " +
32 "creating the distribution archive"),
33 ('dist-dir=', 'd',
34 "directory to put final built distributions in"),
35 ('skip-build', None,
36 "skip rebuilding everything (for testing/debugging)"),
37 ('relative', None,
38 "build the archive using relative paths"
39 "(default: false)"),
40 ('owner=', 'u',
41 "Owner name used when creating a tar file"
42 " [default: current user]"),
43 ('group=', 'g',
44 "Group name used when creating a tar file"
45 " [default: current group]"),
46 ]
47
48 boolean_options = ['keep-temp', 'skip-build', 'relative']
49
50 default_format = { 'posix': 'gztar',
51 'nt': 'zip',
52 'os2': 'zip' }
53
54
55 def initialize_options (self):
56 self.bdist_dir = None
57 self.plat_name = None
58 self.format = None
59 self.keep_temp = 0
60 self.dist_dir = None
61 self.skip_build = 0
62 self.relative = 0
63 self.owner = None
64 self.group = None
65
66 def finalize_options(self):
67 if self.bdist_dir is None:
68 bdist_base = self.get_finalized_command('bdist').bdist_base
69 self.bdist_dir = os.path.join(bdist_base, 'dumb')
70
71 if self.format is None:
72 try:
73 self.format = self.default_format[os.name]
74 except KeyError:
75 raise DistutilsPlatformError, \
76 ("don't know how to create dumb built distributions " +
77 "on platform %s") % os.name
78
79 self.set_undefined_options('bdist',
80 ('dist_dir', 'dist_dir'),
81 ('plat_name', 'plat_name'))
82
83 def run(self):
84 if not self.skip_build:
85 self.run_command('build')
86
87 install = self.reinitialize_command('install', reinit_subcommands=1)
88 install.root = self.bdist_dir
89 install.skip_build = self.skip_build
90 install.warn_dir = 0
91
92 log.info("installing to %s" % self.bdist_dir)
93 self.run_command('install')
94
95 # And make an archive relative to the root of the
96 # pseudo-installation tree.
97 archive_basename = "%s.%s" % (self.distribution.get_fullname(),
98 self.plat_name)
99
100 # OS/2 objects to any ":" characters in a filename (such as when
101 # a timestamp is used in a version) so change them to hyphens.
102 if os.name == "os2":
103 archive_basename = archive_basename.replace(":", "-")
104
105 pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
106 if not self.relative:
107 archive_root = self.bdist_dir
108 else:
109 if (self.distribution.has_ext_modules() and
110 (install.install_base != install.install_platbase)):
111 raise DistutilsPlatformError, \
112 ("can't make a dumb built distribution where "
113 "base and platbase are different (%s, %s)"
114 % (repr(install.install_base),
115 repr(install.install_platbase)))
116 else:
117 archive_root = os.path.join(self.bdist_dir,
118 ensure_relative(install.install_base))
119
120 # Make the archive
121 filename = self.make_archive(pseudoinstall_root,
122 self.format, root_dir=archive_root,
123 owner=self.owner, group=self.group)
124 if self.distribution.has_ext_modules():
125 pyversion = get_python_version()
126 else:
127 pyversion = 'any'
128 self.distribution.dist_files.append(('bdist_dumb', pyversion,
129 filename))
130
131 if not self.keep_temp:
132 remove_tree(self.bdist_dir, dry_run=self.dry_run)