From 625503bf118ded35227ea4506afe342ce4cb0c21 Mon Sep 17 00:00:00 2001 From: Dave Andreoli Date: Sun, 4 Jan 2015 16:00:15 +0100 Subject: [PATCH] Provide the uninstall command for python-efl itself --- INSTALL | 35 ++++++++++++++++++----------------- setup.py | 44 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/INSTALL b/INSTALL index 5f02597..07dc37e 100644 --- a/INSTALL +++ b/INSTALL @@ -6,7 +6,7 @@ - Tested with Python 2.6 / 2.7 / 3.2 / 3.3 / 3.4 * Cython 0.19 or higher (http://cython.org/) - - Tested with Cython 0.19.1 + - Tested with Cython 0.21.2 * EFL core library - eo, evas, ecore, edje, emotion and elementary @@ -26,7 +26,9 @@ ====================== Once EFL is built and installed in your desired destination, proceed with - building the wrapper. + building the wrapper using: + + python setup.py build Distribution tarballs include pre-generated C source files, so cython usage is disabled by default, while is enabled in development git @@ -48,10 +50,17 @@ 3. CLEANUP ========== - * For cleaning up + * For cleaning up: + python setup.py clean --all + + * To also remove all the C/HTML files generated by Cython: + python setup.py clean_generated_files + WARNING: you will need cython to regenerate the C files, do not use this + command in distribution tarballs, unless you know what are you doing. + 4. INSTALLATION @@ -59,7 +68,7 @@ * For system-wide installation (needs administrator privileges): - python setup.py install + (sido) python setup.py install * For user installation: @@ -67,12 +76,15 @@ * To install for python3: - python3 setup.py install (also cython need to be installed with py3) + (sudo) python3 setup.py install (also cython need to be installed with py3) * Install with a custom prefix: - python setup.py install --prefix=/MY_PREFIX + (sudo) python setup.py install --prefix=/MY_PREFIX + * You can also uninstall using: + + (sudo) python setup.py uninstall 5. DOCUMENTATION @@ -105,14 +117,3 @@ The scripts in examples/ folder must be run by the user as they require user interaction. - - -7. UNINSTALL -============ - - Unfortunately setup.py does not provide a way to remove the installed packages, - - To completely remove the installed stuff just remove the 'efl' folder in - your python installation, usually /usr/(local/)lib/pythonX.X/dist-packages/efl - - diff --git a/setup.py b/setup.py index 81b7263..d834649 100755 --- a/setup.py +++ b/setup.py @@ -128,6 +128,42 @@ class CleanGenerated(Command): os.remove(fullpath) +# === setup.py uninstall command === +class Uninstall(Command): + description = 'remove all the installed files recorded at installation time' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def remove_entry(self, entry): + if os.path.isfile(entry): + try: + print("removing file %s" % entry) + os.unlink(entry) + except OSError as e: + error(e) + + directory = os.path.dirname(entry) + while os.listdir(directory) == []: + try: + print("removing empty directory %s" % directory) + os.rmdir(directory) + except OSError as e: + error(e) + directory = os.path.dirname(directory) + + def run(self): + if not os.path.exists("installed_files.txt"): + print('Warning: No installed_files.txt file found!') + else: + for entry in open("installed_files.txt").read().split(): + self.remove_entry(entry) + + # === use cython or pre-generated C files === USE_CYTHON = False if os.getenv("DISABLE_CYTHON") is not None: @@ -439,12 +475,16 @@ setup( ], cmdclass={ 'build_doc': BuildDoc, - 'clean_generated_files': CleanGenerated + 'clean_generated_files': CleanGenerated, + 'uninstall': Uninstall, }, command_options={ 'build_doc': { 'version': ('setup.py', VERSION), - 'release': ('setup.py', RELEASE) + 'release': ('setup.py', RELEASE), + }, + 'install': { + 'record': ('setup.py', 'installed_files.txt'), } }, packages=packages,