Skip to content

Commit e9133a1

Browse files
committed
Remove 'dry run' functionality throughout.
1 parent c11a494 commit e9133a1

16 files changed

+93
-141
lines changed

setuptools/_vendor/wheel/bdist_wheel.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,10 @@ def run(self):
440440

441441
if not self.keep_temp:
442442
log.info(f"removing {self.bdist_dir}")
443-
if not self.dry_run:
444-
if sys.version_info < (3, 12):
445-
rmtree(self.bdist_dir, onerror=remove_readonly)
446-
else:
447-
rmtree(self.bdist_dir, onexc=remove_readonly_exc)
443+
if sys.version_info < (3, 12):
444+
rmtree(self.bdist_dir, onerror=remove_readonly)
445+
else:
446+
rmtree(self.bdist_dir, onexc=remove_readonly_exc)
448447

449448
def write_wheelfile(
450449
self, wheelfile_base, generator="bdist_wheel (" + wheel_version + ")"

setuptools/command/alias.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def run(self) -> None:
6161
alias = self.args[0]
6262
command = ' '.join(map(shquote, self.args[1:]))
6363

64-
edit_config(self.filename, {'aliases': {alias: command}}, self.dry_run)
64+
edit_config(self.filename, {'aliases': {alias: command}})
6565

6666

6767
def format_alias(name, aliases):

setuptools/command/bdist_egg.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ def call_command(self, cmdname, **kw):
158158
for dirname in INSTALL_DIRECTORY_ATTRS:
159159
kw.setdefault(dirname, self.bdist_dir)
160160
kw.setdefault('skip_build', self.skip_build)
161-
kw.setdefault('dry_run', self.dry_run)
162161
cmd = self.reinitialize_command(cmdname, **kw)
163162
self.run_command(cmdname)
164163
return cmd
@@ -185,8 +184,7 @@ def run(self): # noqa: C901 # is too complex (14) # FIXME
185184
pyfile = os.path.join(self.bdist_dir, strip_module(filename) + '.py')
186185
self.stubs.append(pyfile)
187186
log.info("creating stub loader for %s", ext_name)
188-
if not self.dry_run:
189-
write_stub(os.path.basename(ext_name), pyfile)
187+
write_stub(os.path.basename(ext_name), pyfile)
190188
to_compile.append(pyfile)
191189
ext_outputs[p] = ext_name.replace(os.sep, '/')
192190

@@ -208,15 +206,13 @@ def run(self): # noqa: C901 # is too complex (14) # FIXME
208206
native_libs = os.path.join(egg_info, "native_libs.txt")
209207
if all_outputs:
210208
log.info("writing %s", native_libs)
211-
if not self.dry_run:
212-
ensure_directory(native_libs)
213-
with open(native_libs, 'wt', encoding="utf-8") as libs_file:
214-
libs_file.write('\n'.join(all_outputs))
215-
libs_file.write('\n')
209+
ensure_directory(native_libs)
210+
with open(native_libs, 'wt', encoding="utf-8") as libs_file:
211+
libs_file.write('\n'.join(all_outputs))
212+
libs_file.write('\n')
216213
elif os.path.isfile(native_libs):
217214
log.info("removing %s", native_libs)
218-
if not self.dry_run:
219-
os.unlink(native_libs)
215+
os.unlink(native_libs)
220216

221217
write_safety_flag(os.path.join(archive_root, 'EGG-INFO'), self.zip_safe())
222218

@@ -234,11 +230,10 @@ def run(self): # noqa: C901 # is too complex (14) # FIXME
234230
self.egg_output,
235231
archive_root,
236232
verbose=self.verbose,
237-
dry_run=self.dry_run,
238233
mode=self.gen_header(),
239234
)
240235
if not self.keep_temp:
241-
remove_tree(self.bdist_dir, dry_run=self.dry_run)
236+
remove_tree(self.bdist_dir)
242237

243238
# Add to 'Distribution.dist_files' so that the "upload" command works
244239
getattr(self.distribution, 'dist_files', []).append((
@@ -443,7 +438,6 @@ def make_zipfile(
443438
zip_filename: StrPathT,
444439
base_dir,
445440
verbose: bool = False,
446-
dry_run: bool = False,
447441
compress=True,
448442
mode: _ZipFileMode = 'w',
449443
) -> StrPathT:
@@ -455,25 +449,20 @@ def make_zipfile(
455449
"""
456450
import zipfile
457451

458-
mkpath(os.path.dirname(zip_filename), dry_run=dry_run) # type: ignore[arg-type] # python/mypy#18075
452+
mkpath(os.path.dirname(zip_filename)) # type: ignore[arg-type] # python/mypy#18075
459453
log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir)
460454

461455
def visit(z, dirname, names):
462456
for name in names:
463457
path = os.path.normpath(os.path.join(dirname, name))
464458
if os.path.isfile(path):
465459
p = path[len(base_dir) + 1 :]
466-
if not dry_run:
467-
z.write(path, p)
460+
z.write(path, p)
468461
log.debug("adding '%s'", p)
469462

470463
compression = zipfile.ZIP_DEFLATED if compress else zipfile.ZIP_STORED
471-
if not dry_run:
472-
z = zipfile.ZipFile(zip_filename, mode, compression=compression)
473-
for dirname, dirs, files in sorted_walk(base_dir):
474-
visit(z, dirname, files)
475-
z.close()
476-
else:
477-
for dirname, dirs, files in sorted_walk(base_dir):
478-
visit(None, dirname, files)
464+
z = zipfile.ZipFile(zip_filename, mode, compression=compression)
465+
for dirname, dirs, files in sorted_walk(base_dir):
466+
visit(z, dirname, files)
467+
z.close()
479468
return zip_filename

setuptools/command/bdist_wheel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,7 @@ def run(self):
448448

449449
if not self.keep_temp:
450450
log.info(f"removing {self.bdist_dir}")
451-
if not self.dry_run:
452-
_shutil.rmtree(self.bdist_dir)
451+
_shutil.rmtree(self.bdist_dir)
453452

454453
def write_wheelfile(
455454
self, wheelfile_base: str, generator: str = f"setuptools ({__version__})"

setuptools/command/build_ext.py

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def finalize_options(self) -> None:
225225

226226
def setup_shlib_compiler(self):
227227
compiler = self.shlib_compiler = new_compiler(
228-
compiler=self.compiler, dry_run=self.dry_run, force=self.force
228+
compiler=self.compiler, force=self.force
229229
)
230230
_customize_compiler_for_shlib(compiler)
231231

@@ -353,49 +353,47 @@ def _write_stub_file(self, stub_file: str, ext: Extension, compile=False):
353353
log.info("writing stub loader for %s to %s", ext._full_name, stub_file)
354354
if compile and os.path.exists(stub_file):
355355
raise BaseError(stub_file + " already exists! Please delete.")
356-
if not self.dry_run:
357-
with open(stub_file, 'w', encoding="utf-8") as f:
358-
content = '\n'.join([
359-
"def __bootstrap__():",
360-
" global __bootstrap__, __file__, __loader__",
361-
" import sys, os, pkg_resources, importlib.util" + if_dl(", dl"),
362-
" __file__ = pkg_resources.resource_filename"
363-
f"(__name__,{os.path.basename(ext._file_name)!r})",
364-
" del __bootstrap__",
365-
" if '__loader__' in globals():",
366-
" del __loader__",
367-
if_dl(" old_flags = sys.getdlopenflags()"),
368-
" old_dir = os.getcwd()",
369-
" try:",
370-
" os.chdir(os.path.dirname(__file__))",
371-
if_dl(" sys.setdlopenflags(dl.RTLD_NOW)"),
372-
" spec = importlib.util.spec_from_file_location(",
373-
" __name__, __file__)",
374-
" mod = importlib.util.module_from_spec(spec)",
375-
" spec.loader.exec_module(mod)",
376-
" finally:",
377-
if_dl(" sys.setdlopenflags(old_flags)"),
378-
" os.chdir(old_dir)",
379-
"__bootstrap__()",
380-
"", # terminal \n
381-
])
382-
f.write(content)
356+
with open(stub_file, 'w', encoding="utf-8") as f:
357+
content = '\n'.join([
358+
"def __bootstrap__():",
359+
" global __bootstrap__, __file__, __loader__",
360+
" import sys, os, pkg_resources, importlib.util" + if_dl(", dl"),
361+
" __file__ = pkg_resources.resource_filename"
362+
f"(__name__,{os.path.basename(ext._file_name)!r})",
363+
" del __bootstrap__",
364+
" if '__loader__' in globals():",
365+
" del __loader__",
366+
if_dl(" old_flags = sys.getdlopenflags()"),
367+
" old_dir = os.getcwd()",
368+
" try:",
369+
" os.chdir(os.path.dirname(__file__))",
370+
if_dl(" sys.setdlopenflags(dl.RTLD_NOW)"),
371+
" spec = importlib.util.spec_from_file_location(",
372+
" __name__, __file__)",
373+
" mod = importlib.util.module_from_spec(spec)",
374+
" spec.loader.exec_module(mod)",
375+
" finally:",
376+
if_dl(" sys.setdlopenflags(old_flags)"),
377+
" os.chdir(old_dir)",
378+
"__bootstrap__()",
379+
"", # terminal \n
380+
])
381+
f.write(content)
383382
if compile:
384383
self._compile_and_remove_stub(stub_file)
385384

386385
def _compile_and_remove_stub(self, stub_file: str):
387386
from distutils.util import byte_compile
388387

389-
byte_compile([stub_file], optimize=0, force=True, dry_run=self.dry_run)
388+
byte_compile([stub_file], optimize=0, force=True)
390389
optimize = self.get_finalized_command('install_lib').optimize
391390
if optimize > 0:
392391
byte_compile(
393392
[stub_file],
394393
optimize=optimize,
395394
force=True,
396-
dry_run=self.dry_run,
397395
)
398-
if os.path.exists(stub_file) and not self.dry_run:
396+
if os.path.exists(stub_file):
399397
os.unlink(stub_file)
400398

401399

setuptools/command/develop.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,8 @@ def install_for_development(self) -> None:
119119

120120
# create an .egg-link in the installation dir, pointing to our egg
121121
log.info("Creating %s (link to %s)", self.egg_link, self.egg_base)
122-
if not self.dry_run:
123-
with open(self.egg_link, "w", encoding="utf-8") as f:
124-
f.write(self.egg_path + "\n" + self.setup_path)
122+
with open(self.egg_link, "w", encoding="utf-8") as f:
123+
f.write(self.egg_path + "\n" + self.setup_path)
125124
# postprocess the installed distro, fixing up .pth, installing scripts,
126125
# and handling requirements
127126
self.process_distribution(None, self.dist, not self.no_deps)
@@ -138,10 +137,8 @@ def uninstall_link(self) -> None:
138137
if contents not in ([self.egg_path], [self.egg_path, self.setup_path]):
139138
log.warn("Link points to %s: uninstall aborted", contents)
140139
return
141-
if not self.dry_run:
142-
os.unlink(self.egg_link)
143-
if not self.dry_run:
144-
self.update_pth(self.dist) # remove any .pth link to us
140+
os.unlink(self.egg_link)
141+
self.update_pth(self.dist) # remove any .pth link to us
145142
if self.distribution.scripts:
146143
# XXX should also check for entry point scripts!
147144
log.warn("Note: you must uninstall or replace scripts manually!")

setuptools/command/easy_install.py

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ def initialize_options(self):
205205
# always come from the standard configuration file(s)' "easy_install"
206206
# section, even if this is a "develop" or "install" command, or some
207207
# other embedding.
208-
self._dry_run = None
209208
self.verbose = self.distribution.verbose
210209
self.distribution._set_command_options(
211210
self, self.distribution.get_option_dict('easy_install')
@@ -221,8 +220,6 @@ def delete_blockers(self, blockers) -> None:
221220

222221
def _delete_path(self, path):
223222
log.info("Deleting %s", path)
224-
if self.dry_run:
225-
return
226223

227224
is_tree = os.path.isdir(path) and not os.path.islink(path)
228225
remover = _rmtree if is_tree else os.unlink
@@ -868,9 +865,6 @@ def write_script(self, script_name, contents, mode: str = "t", blockers=()) -> N
868865
target = os.path.join(self.script_dir, script_name)
869866
self.add_output(target)
870867

871-
if self.dry_run:
872-
return
873-
874868
mask = current_umask()
875869
ensure_directory(target)
876870
if os.path.exists(target):
@@ -945,15 +939,14 @@ def install_egg(self, egg_path, tmpdir):
945939
os.path.basename(egg_path),
946940
)
947941
destination = os.path.abspath(destination)
948-
if not self.dry_run:
949-
ensure_directory(destination)
942+
ensure_directory(destination)
950943

951944
dist = self.egg_distribution(egg_path)
952945
if not (
953946
os.path.exists(destination) and os.path.samefile(egg_path, destination)
954947
):
955948
if os.path.isdir(destination) and not os.path.islink(destination):
956-
dir_util.remove_tree(destination, dry_run=self.dry_run)
949+
dir_util.remove_tree(destination)
957950
elif os.path.exists(destination):
958951
self.execute(
959952
os.unlink,
@@ -1036,7 +1029,6 @@ def install_exe(self, dist_filename, tmpdir):
10361029
egg_path,
10371030
egg_tmp,
10381031
verbose=self.verbose,
1039-
dry_run=self.dry_run,
10401032
)
10411033
# install the .egg
10421034
return self.install_egg(egg_path, tmpdir)
@@ -1099,10 +1091,9 @@ def install_wheel(self, wheel_path, tmpdir):
10991091
assert wheel.is_compatible()
11001092
destination = os.path.join(self.install_dir, wheel.egg_name())
11011093
destination = os.path.abspath(destination)
1102-
if not self.dry_run:
1103-
ensure_directory(destination)
1094+
ensure_directory(destination)
11041095
if os.path.isdir(destination) and not os.path.islink(destination):
1105-
dir_util.remove_tree(destination, dry_run=self.dry_run)
1096+
dir_util.remove_tree(destination)
11061097
elif os.path.exists(destination):
11071098
self.execute(
11081099
os.unlink,
@@ -1185,8 +1176,6 @@ def run_setup(self, setup_script, setup_base, args) -> None:
11851176
args.insert(0, '-' + v)
11861177
elif self.verbose < 2:
11871178
args.insert(0, '-q')
1188-
if self.dry_run:
1189-
args.insert(0, '-n')
11901179
log.info("Running %s %s", setup_script[len(setup_base) + 1 :], ' '.join(args))
11911180
try:
11921181
run_setup(setup_script, args)
@@ -1210,7 +1199,7 @@ def build_and_install(self, setup_script, setup_base):
12101199
for key in all_eggs
12111200
for dist in all_eggs[key]
12121201
]
1213-
if not eggs and not self.dry_run:
1202+
if not eggs:
12141203
log.warn("No eggs found in %s (setup script problem?)", dist_dir)
12151204
return eggs
12161205
finally:
@@ -1244,7 +1233,7 @@ def _set_fetcher_options(self, base):
12441233
cfg_filename = os.path.join(base, 'setup.cfg')
12451234
setopt.edit_config(cfg_filename, settings)
12461235

1247-
def update_pth(self, dist) -> None: # noqa: C901 # is too complex (11) # FIXME
1236+
def update_pth(self, dist) -> None:
12481237
if self.pth_file is None:
12491238
return
12501239

@@ -1269,9 +1258,6 @@ def update_pth(self, dist) -> None: # noqa: C901 # is too complex (11) # FIXM
12691258
if dist.location not in self.shadow_path:
12701259
self.shadow_path.append(dist.location)
12711260

1272-
if self.dry_run:
1273-
return
1274-
12751261
self.pth_file.save()
12761262

12771263
if dist.key != 'setuptools':
@@ -1303,14 +1289,13 @@ def pf(src, dst):
13031289
elif dst.endswith('.dll') or dst.endswith('.so'):
13041290
to_chmod.append(dst)
13051291
self.unpack_progress(src, dst)
1306-
return not self.dry_run and dst or None
1292+
return dst or None
13071293

13081294
unpack_archive(egg_path, destination, pf)
13091295
self.byte_compile(to_compile)
1310-
if not self.dry_run:
1311-
for f in to_chmod:
1312-
mode = ((os.stat(f)[stat.ST_MODE]) | 0o555) & 0o7755
1313-
chmod(f, mode)
1296+
for f in to_chmod:
1297+
mode = ((os.stat(f)[stat.ST_MODE]) | 0o555) & 0o7755
1298+
chmod(f, mode)
13141299

13151300
def byte_compile(self, to_compile) -> None:
13161301
if sys.dont_write_bytecode:
@@ -1322,13 +1307,12 @@ def byte_compile(self, to_compile) -> None:
13221307
# try to make the byte compile messages quieter
13231308
log.set_verbosity(self.verbose - 1)
13241309

1325-
byte_compile(to_compile, optimize=0, force=True, dry_run=self.dry_run)
1310+
byte_compile(to_compile, optimize=0, force=True)
13261311
if self.optimize:
13271312
byte_compile(
13281313
to_compile,
13291314
optimize=self.optimize,
13301315
force=True,
1331-
dry_run=self.dry_run,
13321316
)
13331317
finally:
13341318
log.set_verbosity(self.verbose) # restore original verbosity

setuptools/command/editable_wheel.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,6 @@ def __init__(self, distribution, installation_dir, editable_name, src_root) -> N
785785
self.installation_dir = installation_dir
786786
self.editable_name = editable_name
787787
self.outputs: list[str] = []
788-
self.dry_run = False
789788

790789
def _get_nspkg_file(self):
791790
"""Installation target."""

0 commit comments

Comments
 (0)