1 """distutils.command.bdist_dumb
3 Implements the Distutils 'bdist_dumb' command (create a "dumb" built
4 distribution -- i.e., just an archive to be unpacked under $prefix or
10 from distutils
.core
import Command
11 from distutils
.util
import get_platform
12 from distutils
.dir_util
import remove_tree
, ensure_relative
13 from distutils
.errors
import *
14 from distutils
.sysconfig
import get_python_version
15 from distutils
import log
17 class bdist_dumb (Command
):
19 description
= "create a \"dumb\" built distribution"
21 user_options
= [('bdist-dir=', 'd',
22 "temporary directory for creating the distribution"),
24 "platform name to embed in generated filenames "
25 "(default: %s)" % get_platform()),
27 "archive format to create (tar, ztar, gztar, zip)"),
29 "keep the pseudo-installation tree around after " +
30 "creating the distribution archive"),
32 "directory to put final built distributions in"),
34 "skip rebuilding everything (for testing/debugging)"),
36 "build the archive using relative paths"
40 boolean_options
= ['keep-temp', 'skip-build', 'relative']
42 default_format
= { 'posix': 'gztar',
47 def initialize_options (self
):
56 # initialize_options()
59 def finalize_options (self
):
61 if self
.bdist_dir
is None:
62 bdist_base
= self
.get_finalized_command('bdist').bdist_base
63 self
.bdist_dir
= os
.path
.join(bdist_base
, 'dumb')
65 if self
.format
is None:
67 self
.format
= self
.default_format
[os
.name
]
69 raise DistutilsPlatformError
, \
70 ("don't know how to create dumb built distributions " +
71 "on platform %s") % os
.name
73 self
.set_undefined_options('bdist',
74 ('dist_dir', 'dist_dir'),
75 ('plat_name', 'plat_name'))
82 if not self
.skip_build
:
83 self
.run_command('build')
85 install
= self
.reinitialize_command('install', reinit_subcommands
=1)
86 install
.root
= self
.bdist_dir
87 install
.skip_build
= self
.skip_build
90 log
.info("installing to %s" % self
.bdist_dir
)
91 self
.run_command('install')
93 # And make an archive relative to the root of the
94 # pseudo-installation tree.
95 archive_basename
= "%s.%s" % (self
.distribution
.get_fullname(),
98 # OS/2 objects to any ":" characters in a filename (such as when
99 # a timestamp is used in a version) so change them to hyphens.
101 archive_basename
= archive_basename
.replace(":", "-")
103 pseudoinstall_root
= os
.path
.join(self
.dist_dir
, archive_basename
)
104 if not self
.relative
:
105 archive_root
= self
.bdist_dir
107 if (self
.distribution
.has_ext_modules() and
108 (install
.install_base
!= install
.install_platbase
)):
109 raise DistutilsPlatformError
, \
110 ("can't make a dumb built distribution where "
111 "base and platbase are different (%s, %s)"
112 % (repr(install
.install_base
),
113 repr(install
.install_platbase
)))
115 archive_root
= os
.path
.join(self
.bdist_dir
,
116 ensure_relative(install
.install_base
))
119 filename
= self
.make_archive(pseudoinstall_root
,
120 self
.format
, root_dir
=archive_root
)
121 if self
.distribution
.has_ext_modules():
122 pyversion
= get_python_version()
125 self
.distribution
.dist_files
.append(('bdist_dumb', pyversion
,
128 if not self
.keep_temp
:
129 remove_tree(self
.bdist_dir
, dry_run
=self
.dry_run
)