def __init__(self, options, args): """ Initialization. INPUT: - options -- either options generated from the command line by sage-runtests or a DocTestDefaults object (possibly with some entries modified) - args -- a list of filenames to doctest EXAMPLES:: sage: from sage.doctest.control import DocTestDefaults, DocTestController sage: DC = DocTestController(DocTestDefaults(), []) sage: DC DocTest Controller """ # First we modify options to take environment variables into # account and check compatibility of the user's specified # options. if options.timeout < 0: if options.gdb or options.debug: # Interactive debuggers: "infinite" timeout options.timeout = 0 elif options.valgrind or options.massif or options.cachegrind or options.omega: # Non-interactive debuggers: 48 hours options.timeout = int( os.getenv('SAGE_TIMEOUT_VALGRIND', 48 * 60 * 60)) elif options.long: options.timeout = int(os.getenv('SAGE_TIMEOUT_LONG', 30 * 60)) else: options.timeout = int(os.getenv('SAGE_TIMEOUT', 5 * 60)) # For non-default GC options, double the timeout if options.gc: options.timeout *= 2 if options.nthreads == 0: options.nthreads = int(os.getenv('SAGE_NUM_THREADS_PARALLEL', 1)) if options.failed and not (args or options.new): # If the user doesn't specify any files then we rerun all failed files. options.all = True if options.global_iterations == 0: options.global_iterations = int( os.environ.get('SAGE_TEST_GLOBAL_ITER', 1)) if options.file_iterations == 0: options.file_iterations = int(os.environ.get('SAGE_TEST_ITER', 1)) if options.debug: if options.nthreads > 1: print( "Debugging requires single-threaded operation, setting number of threads to 1." ) if options.logfile: print( "Debugging is not compatible with logging, disabling logfile." ) options.serial = True options.logfile = None if options.serial: options.nthreads = 1 if options.verbose: options.show_skipped = True if isinstance(options.optional, str): s = options.optional.lower() options.optional = set(s.split(',')) if "all" in options.optional: # Special case to run all optional tests options.optional = True else: # We replace the 'optional' tag by all optional # packages for which the installed version matches the # latest available version (this implies in particular # that the package is actually installed). if 'optional' in options.optional: options.optional.discard('optional') from sage.misc.package import list_packages for pkg in list_packages('optional', local=True).values(): if pkg['installed'] and pkg[ 'installed_version'] == pkg['remote_version']: options.optional.add(pkg['name']) from sage.features import package_systems options.optional.update(system.name for system in package_systems()) # Check that all tags are valid for o in options.optional: if not optionaltag_regex.search(o): raise ValueError('invalid optional tag {!r}'.format(o)) options.optional |= auto_optional_tags self.options = options self.files = args if options.logfile: try: self.logfile = open(options.logfile, 'a') except IOError: print( "Unable to open logfile {!r}\nProceeding without logging.". format(options.logfile)) self.logfile = None else: self.logfile = None # Flush any diagnostic messages we just printed sys.stdout.flush() sys.stderr.flush() # In serial mode, we run just one process. Then the doctests # will interfere with the output logging (both use stdout). # To solve this, we create real_stdout which will always # write to the actual standard output, regardless of # redirections. if options.serial: self._real_stdout = os.fdopen(os.dup(sys.stdout.fileno()), "w") self._close_stdout = True else: # Parallel mode: no special tricks needed self._real_stdout = sys.stdout self._close_stdout = False if self.logfile is None: self.logger = self._real_stdout else: self.logger = Logger(self._real_stdout, self.logfile) self.stats = {} self.load_stats(options.stats_path) self._init_warn_long() if self.options.random_seed is None: self.options.random_seed = 0
def __init__(self, options, args): """ Initialization. INPUT: - options -- either options generated from the command line by SAGE_LOCAL/bin/sage-runtests or a DocTestDefaults object (possibly with some entries modified) - args -- a list of filenames to doctest EXAMPLES:: sage: from sage.doctest.control import DocTestDefaults, DocTestController sage: DC = DocTestController(DocTestDefaults(), []) sage: DC DocTest Controller """ # First we modify options to take environment variables into # account and check compatibility of the user's specified # options. if options.timeout < 0: if options.gdb or options.debug: # Interactive debuggers: "infinite" timeout options.timeout = 0 elif options.valgrind or options.massif or options.cachegrind or options.omega: # Non-interactive debuggers: 48 hours options.timeout = int(os.getenv('SAGE_TIMEOUT_VALGRIND', 48 * 60 * 60)) elif options.long: options.timeout = int(os.getenv('SAGE_TIMEOUT_LONG', 30 * 60)) else: options.timeout = int(os.getenv('SAGE_TIMEOUT', 5 * 60)) # For non-default GC options, double the timeout if options.gc: options.timeout *= 2 if options.nthreads == 0: options.nthreads = int(os.getenv('SAGE_NUM_THREADS_PARALLEL',1)) if options.failed and not (args or options.new or options.sagenb): # If the user doesn't specify any files then we rerun all failed files. options.all = True if options.global_iterations == 0: options.global_iterations = int(os.environ.get('SAGE_TEST_GLOBAL_ITER', 1)) if options.file_iterations == 0: options.file_iterations = int(os.environ.get('SAGE_TEST_ITER', 1)) if options.debug: if options.nthreads > 1: print("Debugging requires single-threaded operation, setting number of threads to 1.") if options.logfile: print("Debugging is not compatible with logging, disabling logfile.") options.serial = True options.logfile = None if options.serial: options.nthreads = 1 if options.verbose: options.show_skipped = True if isinstance(options.optional, six.string_types): s = options.optional.lower() options.optional = set(s.split(',')) if "all" in options.optional: # Special case to run all optional tests options.optional = True else: # We replace the 'optional' tag by all optional # packages for which the installed version matches the # latest available version (this implies in particular # that the package is actually installed). if 'optional' in options.optional: options.optional.discard('optional') from sage.misc.package import list_packages for pkg in list_packages('optional', local=True).values(): if pkg['installed_version'] == pkg['remote_version']: options.optional.add(pkg['name']) # Check that all tags are valid for o in options.optional: if not optionaltag_regex.search(o): raise ValueError('invalid optional tag {!r}'.format(o)) options.optional |= auto_optional_tags self.options = options if options.memlimit > 0: # Allow tests that require a virtual memory limit to be set options.optional.add('memlimit') self.files = args if options.logfile: try: self.logfile = open(options.logfile, 'a') except IOError: print("Unable to open logfile {!r}\nProceeding without logging.".format(options.logfile)) self.logfile = None else: self.logfile = None # Flush any diagnostic messages we just printed sys.stdout.flush() sys.stderr.flush() # In serial mode, we run just one process. Then the doctests # will interfere with the output logging (both use stdout). # To solve this, we create real_stdout which will always # write to the actual standard output, regardless of # redirections. if options.serial: self._real_stdout = os.fdopen(os.dup(sys.stdout.fileno()), "w") self._close_stdout = True else: # Parallel mode: no special tricks needed self._real_stdout = sys.stdout self._close_stdout = False if self.logfile is None: self.logger = self._real_stdout else: self.logger = Logger(self._real_stdout, self.logfile) self.stats = {} self.load_stats(options.stats_path) self._init_warn_long()
#***************************************************************************** # Copyright (C) 2015 Jeroen Demeyer <*****@*****.**> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # http://www.gnu.org/licenses/ #***************************************************************************** from distutils.extension import Extension from sage.misc.package import list_packages all_packages = list_packages(local=True) class CythonizeExtension(Extension): """ A class for extensions which are only cythonized, but not built. The file ``src/setup.py`` contains some logic to check the ``skip_build`` attribute of extensions. EXAMPLES:: sage: from sage_setup.optional_extension import CythonizeExtension sage: ext = CythonizeExtension("foo", ["foo.c"]) sage: ext.skip_build True
#***************************************************************************** # Copyright (C) 2015 Jeroen Demeyer <*****@*****.**> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # http://www.gnu.org/licenses/ #***************************************************************************** from distutils.extension import Extension from sage.misc.package import is_package_installed, list_packages all_packages = list_packages(local=True) class CythonizeExtension(Extension): """ A class for extensions which are only cythonized, but not built. The file ``src/setup.py`` contains some logic to check the ``skip_build`` attribute of extensions. EXAMPLES:: sage: from sage_setup.optional_extension import CythonizeExtension sage: ext = CythonizeExtension("foo", ["foo.c"]) sage: ext.skip_build True