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
8 from ..core
import Command
9 from ..util
import get_platform
10 from ..dir_util
import remove_tree
, ensure_relative
11 from ..errors
import DistutilsPlatformError
12 from ..sysconfig
import get_python_version
13 from distutils
._log
import log
16 class bdist_dumb(Command
):
17 description
= "create a \"dumb\" built distribution"
20 ('bdist-dir=', 'd', "temporary directory for creating the distribution"),
24 "platform name to embed in generated filenames "
25 "(default: %s)" % get_platform(),
30 "archive format to create (tar, gztar, bztar, xztar, " "ztar, zip)",
35 "keep the pseudo-installation tree around after "
36 + "creating the distribution archive",
38 ('dist-dir=', 'd', "directory to put final built distributions in"),
39 ('skip-build', None, "skip rebuilding everything (for testing/debugging)"),
43 "build the archive using relative paths " "(default: false)",
48 "Owner name used when creating a tar file" " [default: current user]",
53 "Group name used when creating a tar file" " [default: current group]",
57 boolean_options
= ['keep-temp', 'skip-build', 'relative']
59 default_format
= {'posix': 'gztar', 'nt': 'zip'}
61 def initialize_options(self
):
67 self
.skip_build
= None
72 def finalize_options(self
):
73 if self
.bdist_dir
is None:
74 bdist_base
= self
.get_finalized_command('bdist').bdist_base
75 self
.bdist_dir
= os
.path
.join(bdist_base
, 'dumb')
77 if self
.format
is None:
79 self
.format
= self
.default_format
[os
.name
]
81 raise DistutilsPlatformError(
82 "don't know how to create dumb built distributions "
83 "on platform %s" % os
.name
86 self
.set_undefined_options(
88 ('dist_dir', 'dist_dir'),
89 ('plat_name', 'plat_name'),
90 ('skip_build', 'skip_build'),
94 if not self
.skip_build
:
95 self
.run_command('build')
97 install
= self
.reinitialize_command('install', reinit_subcommands
=1)
98 install
.root
= self
.bdist_dir
99 install
.skip_build
= self
.skip_build
102 log
.info("installing to %s", self
.bdist_dir
)
103 self
.run_command('install')
105 # And make an archive relative to the root of the
106 # pseudo-installation tree.
107 archive_basename
= "{}.{}".format(
108 self
.distribution
.get_fullname(), self
.plat_name
111 pseudoinstall_root
= os
.path
.join(self
.dist_dir
, archive_basename
)
112 if not self
.relative
:
113 archive_root
= self
.bdist_dir
115 if self
.distribution
.has_ext_modules() and (
116 install
.install_base
!= install
.install_platbase
118 raise DistutilsPlatformError(
119 "can't make a dumb built distribution where "
120 "base and platbase are different (%s, %s)"
121 % (repr(install
.install_base
), repr(install
.install_platbase
))
124 archive_root
= os
.path
.join(
125 self
.bdist_dir
, ensure_relative(install
.install_base
)
129 filename
= self
.make_archive(
132 root_dir
=archive_root
,
136 if self
.distribution
.has_ext_modules():
137 pyversion
= get_python_version()
140 self
.distribution
.dist_files
.append(('bdist_dumb', pyversion
, filename
))
142 if not self
.keep_temp
:
143 remove_tree(self
.bdist_dir
, dry_run
=self
.dry_run
)