Author: bugman Date: Wed Sep 2 22:11:08 2009 New Revision: 9436 URL: http://svn.gna.org/viewcvs/relax?rev=9436&view=rev Log: Made the profile module optional, removing the dependency on the Python development packages. This was in response to Tiago Pais's <tpais att itqb dot unl dot pt> message at https://mail.gna.org/public/relax-users/2009-08/msg00040.html (Message-id: <A3A9E765436240CDA75B3045C405BED6@Mercurio>). Modified: 1.3/dep_check.py 1.3/relax Modified: 1.3/dep_check.py URL: http://svn.gna.org/viewcvs/relax/1.3/dep_check.py?rev=9436&r1=9435&r2=9436&view=diff ============================================================================== --- 1.3/dep_check.py (original) +++ 1.3/dep_check.py Wed Sep 2 22:11:08 2009 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2008 Edward d'Auvergne # +# Copyright (C) 2008-2009 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -71,6 +71,14 @@ except ImportError: readline_module = False +# profile module (python development packages required). +try: + import profile + del profile + profile_module = True +except ImportError: + profile_module = False + # BZ2 compression module. try: import bz2 Modified: 1.3/relax URL: http://svn.gna.org/viewcvs/relax/1.3/relax?rev=9436&r1=9435&r2=9436&view=diff ============================================================================== --- 1.3/relax (original) +++ 1.3/relax Wed Sep 2 22:11:08 2009 @@ -41,7 +41,8 @@ from optparse import Option, OptionParser from os import F_OK, access, getpid, putenv import platform -import profile +if dep_check.profile_module: + import profile import pstats from re import match from string import split, strip @@ -411,14 +412,23 @@ if __name__ == "__main__": - # Change this flag to 1 for code profiling. - profile_flag = 0 - + # Change this flag to True for code profiling. + profile_flag = False + + # Normal relax operation. if not profile_flag: Relax() + + # relax in profiling mode. else: def print_stats(stats, status=0): pstats.Stats(stats).sort_stats('cumulative', 'name').print_stats() + # No profile module. + if not dep_check.profile_module: + sys.stderr.write("The profile module is not available, please install the Python development packages for profiling.\n\n") + sys.exit() + + # Run relax in profiling mode. profile.Profile.print_stats = print_stats profile.run('Relax()')