summaryrefslogtreecommitdiff
path: root/efl/utils
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2015-01-02 21:36:21 +0100
committerDave Andreoli <dave@gurumeditation.it>2015-01-02 21:36:21 +0100
commit5c8bb29d784c494ea0f86323583ed0476ede7f45 (patch)
tree7a3a06debecbd99df96e42653af927ed1e80a214 /efl/utils
parenta4f2cc37cc4445831b675885f51a757a70624b66 (diff)
New distutils command: uninstall
Diffstat (limited to 'efl/utils')
-rw-r--r--efl/utils/setup.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/efl/utils/setup.py b/efl/utils/setup.py
index 4564d53..ec4f799 100644
--- a/efl/utils/setup.py
+++ b/efl/utils/setup.py
@@ -170,6 +170,46 @@ class build_i18n(distutils.cmd.Command):
170 _data_files_append(self.distribution, target, mo_file) 170 _data_files_append(self.distribution, target, mo_file)
171 171
172 172
173class uninstall(distutils.cmd.Command):
174 description = 'remove all the installed files recorded at installation time'
175 user_options = [('record=', None, 'filename with list of files '
176 '(default: installed_files.txt)')]
177
178 def initialize_options(self):
179 self.record = None
180
181 def finalize_options(self):
182 if self.record is None:
183 self.record = 'installed_files.txt'
184
185 def remove_entry(self, entry):
186 if os.path.isfile(entry):
187 try:
188 info("removing file %s" % entry)
189 os.unlink(entry)
190 except OSError as e:
191 error(e)
192
193 directory = os.path.dirname(entry)
194 while os.listdir(directory) == []:
195 try:
196 info("removing empty directory %s" % directory)
197 os.rmdir(directory)
198 except OSError as e:
199 error(e)
200 directory = os.path.dirname(directory)
201
202 def run(self):
203 if not os.path.exists(self.record):
204 warn('Warning: No record file found!')
205 warn(' To make this command works you must add:')
206 warn(' "install": {"record": ("setup.py", "installed_files.txt")}')
207 warn(' to your command_options dict in setup.py')
208 return
209 for entry in open(self.record).read().split():
210 self.remove_entry(entry)
211
212
173def _data_files_append(distribution, target, files): 213def _data_files_append(distribution, target, files):
174 """ Tiny util to append to data_files, ensuring data_file is defined """ 214 """ Tiny util to append to data_files, ensuring data_file is defined """
175 if not isinstance(files, (list, tuple)): 215 if not isinstance(files, (list, tuple)):