]> jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/setuptools/_distutils/command/bdist_dumb.py
init: venv aand flask
[dlqueue.git] / venv / lib / python3.11 / site-packages / setuptools / _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 import os
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
14
15
16 class bdist_dumb(Command):
17 description = "create a \"dumb\" built distribution"
18
19 user_options = [
20 ('bdist-dir=', 'd', "temporary directory for creating the distribution"),
21 (
22 'plat-name=',
23 'p',
24 "platform name to embed in generated filenames "
25 "(default: %s)" % get_platform(),
26 ),
27 (
28 'format=',
29 'f',
30 "archive format to create (tar, gztar, bztar, xztar, " "ztar, zip)",
31 ),
32 (
33 'keep-temp',
34 'k',
35 "keep the pseudo-installation tree around after "
36 + "creating the distribution archive",
37 ),
38 ('dist-dir=', 'd', "directory to put final built distributions in"),
39 ('skip-build', None, "skip rebuilding everything (for testing/debugging)"),
40 (
41 'relative',
42 None,
43 "build the archive using relative paths " "(default: false)",
44 ),
45 (
46 'owner=',
47 'u',
48 "Owner name used when creating a tar file" " [default: current user]",
49 ),
50 (
51 'group=',
52 'g',
53 "Group name used when creating a tar file" " [default: current group]",
54 ),
55 ]
56
57 boolean_options = ['keep-temp', 'skip-build', 'relative']
58
59 default_format = {'posix': 'gztar', 'nt': 'zip'}
60
61 def initialize_options(self):
62 self.bdist_dir = None
63 self.plat_name = None
64 self.format = None
65 self.keep_temp = 0
66 self.dist_dir = None
67 self.skip_build = None
68 self.relative = 0
69 self.owner = None
70 self.group = None
71
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')
76
77 if self.format is None:
78 try:
79 self.format = self.default_format[os.name]
80 except KeyError:
81 raise DistutilsPlatformError(
82 "don't know how to create dumb built distributions "
83 "on platform %s" % os.name
84 )
85
86 self.set_undefined_options(
87 'bdist',
88 ('dist_dir', 'dist_dir'),
89 ('plat_name', 'plat_name'),
90 ('skip_build', 'skip_build'),
91 )
92
93 def run(self):
94 if not self.skip_build:
95 self.run_command('build')
96
97 install = self.reinitialize_command('install', reinit_subcommands=1)
98 install.root = self.bdist_dir
99 install.skip_build = self.skip_build
100 install.warn_dir = 0
101
102 log.info("installing to %s", self.bdist_dir)
103 self.run_command('install')
104
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
109 )
110
111 pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
112 if not self.relative:
113 archive_root = self.bdist_dir
114 else:
115 if self.distribution.has_ext_modules() and (
116 install.install_base != install.install_platbase
117 ):
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))
122 )
123 else:
124 archive_root = os.path.join(
125 self.bdist_dir, ensure_relative(install.install_base)
126 )
127
128 # Make the archive
129 filename = self.make_archive(
130 pseudoinstall_root,
131 self.format,
132 root_dir=archive_root,
133 owner=self.owner,
134 group=self.group,
135 )
136 if self.distribution.has_ext_modules():
137 pyversion = get_python_version()
138 else:
139 pyversion = 'any'
140 self.distribution.dist_files.append(('bdist_dumb', pyversion, filename))
141
142 if not self.keep_temp:
143 remove_tree(self.bdist_dir, dry_run=self.dry_run)