summaryrefslogtreecommitdiff
path: root/distutils2/command
diff options
context:
space:
mode:
Diffstat (limited to 'distutils2/command')
-rw-r--r--distutils2/command/build_scripts.py1
-rw-r--r--distutils2/command/cmd.py16
2 files changed, 16 insertions, 1 deletions
diff --git a/distutils2/command/build_scripts.py b/distutils2/command/build_scripts.py
index a274e3a..9275378 100644
--- a/distutils2/command/build_scripts.py
+++ b/distutils2/command/build_scripts.py
@@ -56,6 +56,7 @@ class build_scripts(Command, Mixin2to3):
ie. starts with "\#!" and contains "python"), then adjust the first
line to refer to the current Python interpreter as we copy.
"""
+ self.rmpath(self.build_dir)
self.mkpath(self.build_dir)
outfiles = []
for script in self.scripts:
diff --git a/distutils2/command/cmd.py b/distutils2/command/cmd.py
index 1cdae14..3dc6e0f 100644
--- a/distutils2/command/cmd.py
+++ b/distutils2/command/cmd.py
@@ -5,7 +5,7 @@ import re
from distutils2 import util
from distutils2 import logger
from distutils2.errors import PackagingOptionError
-from distutils2._backport.shutil import copyfile, move, make_archive
+from distutils2._backport.shutil import copyfile, move, make_archive, rmtree
class Command(object):
@@ -365,6 +365,20 @@ class Command(object):
return
os.makedirs(name, mode)
+ def rmpath(self, name, dry_run=None):
+ if dry_run is None:
+ dry_run = self.dry_run
+ name = os.path.normpath(name)
+ if not os.path.isdir(name) or name == '':
+ return
+ if dry_run:
+ head = ''
+ for part in name.split(os.sep):
+ logger.info("removing directory %s%s", head, part)
+ head += part + os.sep
+ return
+ rmtree(name)
+
def copy_file(self, infile, outfile,
preserve_mode=True, preserve_times=True, link=None, level=1):
"""Copy a file respecting dry-run and force flags.